maven plugin: exclude kotlin-runtime jar from classpath passed to compiler
This commit is contained in:
+22
-1
@@ -180,7 +180,13 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
|
|||||||
final ArrayList<String> classpathList = new ArrayList<String>(classpath);
|
final ArrayList<String> classpathList = new ArrayList<String>(classpath);
|
||||||
|
|
||||||
if (classpathList.remove(output)) {
|
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);
|
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);
|
log.debug("Using jdk headers from " + arguments.jdkHeaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Make a better runtime detection or get rid of it entirely
|
||||||
|
private String getRuntimeFromClassPath(List<String> 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;
|
private File jdkHeadersPath;
|
||||||
|
|
||||||
protected File getJdkHeaders() {
|
protected File getJdkHeaders() {
|
||||||
|
|||||||
Reference in New Issue
Block a user