From 606ea7bb70cfe58d9de757da3ed52ed98a39a18a Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Fri, 15 May 2015 19:41:24 +0300 Subject: [PATCH] Do not pass non-existing source roots to the compiler #KT-3679 Fixed Maven build fails when some source directories don't exist --- .../kotlin/maven/KotlinCompileMojoBase.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java index a23e705eab0..7190c647fd2 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.config.Services; import java.io.File; import java.lang.reflect.Field; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -240,7 +241,16 @@ public abstract class KotlinCompileMojoBase e arguments.verbose = true; } - List sources = getSources(); + List sources = new ArrayList(); + for (String source : getSources()) { + if (new File(source).exists()) { + sources.add(source); + } + else { + LOG.warn("Source root doesn't exist: " + source); + } + } + if (sources == null || sources.isEmpty()) { throw new MojoExecutionException("No source roots to compile"); } @@ -248,7 +258,7 @@ public abstract class KotlinCompileMojoBase e arguments.suppressWarnings = nowarn; arguments.freeArgs.addAll(sources); - LOG.info("Compiling Kotlin sources from " + sources ); + LOG.info("Compiling Kotlin sources from " + sources); configureSpecificCompilerArguments(arguments);