Use reflection in Ant task to invoke compiler
This will allow a more controlled management of the runtime that the compiler is linked against. Incidentally this also allows Ant task to use any of compiler arguments via <compilerarg> because Ant task is now just a facade for the CLI compiler. The test "wrongArguments" is deleted because the full compiler usage is now printed out on a wrong <compilerarg>, and this will become inconvenient to update with each change in compiler arguments #KT-5618 Fixed
This commit is contained in:
@@ -58,6 +58,12 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
||||
return exec(errStream, services, MessageRenderer.TAGS, args);
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration") // Used via reflection in KotlinCompilerBaseTask
|
||||
@NotNull
|
||||
public ExitCode execFullPathsInMessages(@NotNull PrintStream errStream, @NotNull String[] args) {
|
||||
return exec(errStream, Services.EMPTY, MessageRenderer.PLAIN, args);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private A parseArguments(@NotNull PrintStream errStream, @NotNull MessageRenderer messageRenderer, @NotNull String[] args) {
|
||||
try {
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
package org.jetbrains.kotlin;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestName;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class AntTaskJvmTest extends AntTaskBaseTest {
|
||||
private static final String JVM_OUT_FILE = "hello.jar";
|
||||
@@ -44,7 +46,11 @@ public class AntTaskJvmTest extends AntTaskBaseTest {
|
||||
}
|
||||
|
||||
private static String getClassPathForAnt() {
|
||||
return getCompilerLib() + File.separator + "kotlin-ant.jar" + File.pathSeparator + getKotlinRuntimePath();
|
||||
return UtilsPackage.join(Arrays.asList(
|
||||
getCompilerLib() + File.separator + "kotlin-ant.jar",
|
||||
getCompilerLib() + File.separator + "kotlin-compiler.jar",
|
||||
getKotlinRuntimePath()
|
||||
), File.pathSeparator);
|
||||
}
|
||||
|
||||
private static String getIdeaSdkHome() {
|
||||
@@ -61,11 +67,6 @@ public class AntTaskJvmTest extends AntTaskBaseTest {
|
||||
doJvmAntTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wrongArguments() throws Exception {
|
||||
doAntTest(FAILED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jvmClasspath() throws Exception {
|
||||
doJvmAntTest();
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
OUT:
|
||||
Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
|
||||
ERR:
|
||||
|
||||
BUILD FAILED
|
||||
[TestData]/build.xml:5: Invalid argument: -option-never-to-be-supported
|
||||
|
||||
Total time: [time]
|
||||
|
||||
Return code: 1
|
||||
@@ -1,9 +0,0 @@
|
||||
<project name="Ant Task Test" default="build">
|
||||
<taskdef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
||||
|
||||
<target name="build">
|
||||
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar">
|
||||
<compilerarg value="-option-never-to-be-supported"/>
|
||||
</kotlinc>
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,4 +0,0 @@
|
||||
package hello
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
}
|
||||
Reference in New Issue
Block a user