kotlin-maven-plugin, ant:withKotlin: skip compilation for empty sources

#KT-7618 Fixed
This commit is contained in:
Michael Nedzelsky
2015-05-28 10:14:01 +03:00
parent 0ddfedba49
commit 3ac1bdcdc8
3 changed files with 42 additions and 23 deletions
@@ -87,16 +87,26 @@ public class KotlinCompilerAdapter extends Javac13 {
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
return false;
// Javac13#execute passes everything in compileList to javac, which doesn't recognize .kt files
File[] compileListForJavac = filterOutKotlinSources(compileList);
boolean hasKotlinFilesInSources = compileListForJavac.length < compileList.length;
if (hasKotlinFilesInSources) {
kotlinc.execute();
if (!Integer.valueOf(0).equals(kotlinc.getExitCode())) {
// Don't run javac if failOnError = false and there were errors on Kotlin sources
return false;
}
}
else {
// This is needed for addRuntimeToJavacClasspath, where kotlinc arguments will be used.
kotlinc.fillArguments();
}
javac.log("Running javac...");
// Javac13#execute passes everything in compileList to javac, which doesn't recognize .kt files
compileList = filterOutKotlinSources(compileList);
compileList = compileListForJavac;
addRuntimeToJavacClasspath(kotlinc);
@@ -65,7 +65,7 @@ public abstract class KotlinCompilerBaseTask : Task() {
abstract fun fillSpecificArguments()
private fun fillArguments() {
public fun fillArguments() {
val sourcePaths = src ?: throw BuildException("\"src\" should be specified")
args.addAll(sourcePaths.list().map { File(it).canonicalPath })