Ant task: support "compilerarg" element in withKotlin as in kotlinc
This commit is contained in:
@@ -23,10 +23,12 @@ import org.apache.tools.ant.MagicNames;
|
||||
import org.apache.tools.ant.taskdefs.Javac;
|
||||
import org.apache.tools.ant.taskdefs.compilers.Javac13;
|
||||
import org.apache.tools.ant.taskdefs.condition.AntVersion;
|
||||
import org.apache.tools.ant.types.Commandline;
|
||||
import org.apache.tools.ant.types.Path;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,6 +38,7 @@ public class KotlinCompilerAdapter extends Javac13 {
|
||||
private static final List<String> KOTLIN_EXTENSIONS = Arrays.asList("kt", "kts");
|
||||
|
||||
private Path externalAnnotations;
|
||||
public List<Commandline.Argument> additionalArguments = new ArrayList<Commandline.Argument>(0);
|
||||
|
||||
public void setExternalAnnotations(Path externalAnnotations) {
|
||||
this.externalAnnotations = externalAnnotations;
|
||||
@@ -48,6 +51,12 @@ public class KotlinCompilerAdapter extends Javac13 {
|
||||
return externalAnnotations.createPath();
|
||||
}
|
||||
|
||||
public Commandline.Argument createCompilerArg() {
|
||||
Commandline.Argument argument = new Commandline.Argument();
|
||||
additionalArguments.add(argument);
|
||||
return argument;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSupportedFileExtensions() {
|
||||
List<String> result = KotlinPackage.plus(Arrays.asList(super.getSupportedFileExtensions()), KOTLIN_EXTENSIONS);
|
||||
@@ -76,6 +85,8 @@ public class KotlinCompilerAdapter extends Javac13 {
|
||||
|
||||
kotlinc.setExternalAnnotations(externalAnnotations);
|
||||
|
||||
kotlinc.getAdditionalArguments().addAll(additionalArguments);
|
||||
|
||||
kotlinc.execute();
|
||||
if (!Integer.valueOf(0).equals(kotlinc.getExitCode())) {
|
||||
// Don't run javac if failOnError = false and there were errors on Kotlin sources
|
||||
|
||||
@@ -3,6 +3,10 @@ Buildfile: [TestData]/build.xml
|
||||
|
||||
build:
|
||||
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
|
||||
[javac] Compiling 1 source file to [Temp]
|
||||
[javac] Compiling [[TestData]] => [[Temp]]
|
||||
[javac] INFO: Kotlin Compiler version [KotlinVersion]
|
||||
[javac] Running javac...
|
||||
|
||||
BUILD SUCCESSFUL
|
||||
Total time: [time]
|
||||
|
||||
@@ -7,5 +7,11 @@
|
||||
<compilerarg line="-Xno-call-assertions -Xno-param-assertions"/>
|
||||
<compilerarg value="-Xno-optimize"/>
|
||||
</kotlinc>
|
||||
|
||||
<javac srcdir="${test.data}" destdir="${temp}" includeantruntime="false">
|
||||
<withKotlin>
|
||||
<compilerarg value="-version"/>
|
||||
</withKotlin>
|
||||
</javac>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user