Use NIO Files for creating temp files: scripting, daemon, main-kts
This commit is contained in:
@@ -4,7 +4,9 @@ plugins {
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
val JDK_16: String by project
|
||||
jvmTarget = "1.6"
|
||||
javaHome = JDK_16
|
||||
|
||||
dependencies {
|
||||
compile(project(":kotlin-script-runtime"))
|
||||
@@ -22,6 +24,10 @@ tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xallow-kotlin-package"
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
executable = "$JDK_16/bin/java"
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
runtimeJar()
|
||||
|
||||
+17
-4
@@ -59,9 +59,18 @@ class ClasspathExtractionException(message: String) : Exception(message)
|
||||
fun classpathFromClassloader(currentClassLoader: ClassLoader, unpackJarCollections: Boolean = false): List<File>? {
|
||||
val processedJars = hashSetOf<File>()
|
||||
val unpackJarCollectionsDir by lazy {
|
||||
createTempDir("unpackedJarCollections").canonicalFile.also {
|
||||
File.createTempFile("unpackedJarCollections", null).canonicalFile.apply {
|
||||
delete()
|
||||
mkdir()
|
||||
setReadable(false, false)
|
||||
setWritable(false, false)
|
||||
setExecutable(false, false)
|
||||
setReadable(true, true)
|
||||
setWritable(true, true)
|
||||
setExecutable(true, true)
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(Thread {
|
||||
it.deleteRecursively()
|
||||
deleteRecursively()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -144,8 +153,12 @@ fun ClassLoader.classPathFromTypicalResourceUrls(): Sequence<File> =
|
||||
.distinct()
|
||||
.filter { it.isValidClasspathFile() }
|
||||
|
||||
private fun File.unpackJarCollection(rootTempDir: File?): Sequence<File> {
|
||||
val targetDir = createTempDir(nameWithoutExtension, directory = rootTempDir)
|
||||
private fun File.unpackJarCollection(rootTempDir: File): Sequence<File> {
|
||||
val targetDir = File.createTempFile(nameWithoutExtension, null, rootTempDir).apply {
|
||||
delete()
|
||||
mkdir()
|
||||
}
|
||||
|
||||
return try {
|
||||
ArrayList<File>().apply {
|
||||
JarInputStream(FileInputStream(this@unpackJarCollection)).use { jarInputStream ->
|
||||
|
||||
Reference in New Issue
Block a user