Implement proper collection of script compilation classpath, use it in the JSR223 example factories
Fixes #KT-14713
This commit is contained in:
+4
-10
@@ -100,7 +100,7 @@ done
|
||||
|
||||
val scriptClass = compileScript("args-junit-hello-world.kts", StandardScriptTemplateWithAnnotatedResolving::class)
|
||||
if (scriptClass == null) {
|
||||
val resolver = ContextAndAnnotationsBasedResolver()
|
||||
val resolver = AnnotationsBasedResolver()
|
||||
System.err.println(resolver.baseClassPath)
|
||||
}
|
||||
Assert.assertNotNull(scriptClass)
|
||||
@@ -148,8 +148,9 @@ done
|
||||
}
|
||||
else {
|
||||
// attempt to workaround some maven quirks
|
||||
addJvmClasspathRoots(
|
||||
Thread.currentThread().contextClassLoader.manifestClassPath().toList())
|
||||
manifestClassPath(Thread.currentThread().contextClassLoader)?.let {
|
||||
addJvmClasspathRoots(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
put(CommonConfigurationKeys.MODULE_NAME, "kotlin-script-util-test")
|
||||
@@ -178,13 +179,6 @@ done
|
||||
}
|
||||
}
|
||||
|
||||
private fun ClassLoader.manifestClassPath() =
|
||||
getResources("META-INF/MANIFEST.MF")
|
||||
.asSequence()
|
||||
.mapNotNull { ifFailed(null) { it.openStream().use { Manifest().apply { read(it) } } } }
|
||||
.flatMap { it.mainAttributes?.getValue("Class-Path")?.splitToSequence(" ") ?: emptySequence() }
|
||||
.mapNotNull { ifFailed(null) { File(URI.create(it)) } }
|
||||
|
||||
private inline fun <R> ifFailed(default: R, block: () -> R) = try {
|
||||
block()
|
||||
} catch (t: Throwable) {
|
||||
|
||||
Reference in New Issue
Block a user