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 93442bec1f9..34dc2de6552 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 @@ -180,7 +180,13 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { final ArrayList classpathList = new ArrayList(classpath); if (classpathList.remove(output)) { - log.debug("Removed target directory from classpath (" + output + ")"); + log.debug("Removed target directory from compiler classpath (" + output + ")"); + } + + final String runtime = getRuntimeFromClassPath(classpath); + if (runtime != null) { + log.debug("Removed Kotlin runtime from compiler classpath (" + runtime + ")"); + classpathList.remove(runtime); } final String classPathString = Joiner.on(File.pathSeparator).join(classpathList); @@ -194,6 +200,21 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { log.debug("Using jdk headers from " + arguments.jdkHeaders); } + // TODO: Make a better runtime detection or get rid of it entirely + private String getRuntimeFromClassPath(List classpath) { + for (String item : classpath) { + final int lastSeparatorIndex = item.lastIndexOf(File.separator); + + if (lastSeparatorIndex < 0) + continue; + + if (item.startsWith("kotlin-runtime-", lastSeparatorIndex + 1) && item.endsWith(".jar")) + return item; + } + + return null; + } + private File jdkHeadersPath; protected File getJdkHeaders() {