Fix classpath calculation for scripts, e.g. in JSR-223 setting

#KT-25814 fixed
This commit is contained in:
Ilya Chernikov
2018-07-31 11:36:34 +02:00
parent a406f1b361
commit f71909ee73
2 changed files with 9 additions and 4 deletions
@@ -94,10 +94,14 @@ fun scriptCompilationClasspathFromContextOrNull(
classLoader: ClassLoader = Thread.currentThread().contextClassLoader,
wholeClasspath: Boolean = false
): List<File>? {
fun List<File>.takeAndFilter() = if (wholeClasspath) takeIfContainsAll(*keyNames) else filterIfContainsAll(*keyNames)
fun List<File>.takeAndFilter() = when {
isEmpty() -> null
wholeClasspath -> takeIfContainsAll(*keyNames)
else -> filterIfContainsAll(*keyNames)
}
return System.getProperty(KOTLIN_SCRIPT_CLASSPATH_PROPERTY)?.split(File.pathSeparator)?.map(::File)
?: classpathFromClassloader(classLoader)?.takeAndFilter()
?: classpathFromClasspathProperty()?.takeAndFilter()
?: classpathFromClassloader(classLoader)?.takeAndFilter()
?: classpathFromClasspathProperty()?.takeAndFilter()
}
fun scriptCompilationClasspathFromContextOrStlib(