Skip to content

Commit 6228805

Browse files
committed
Fix resources path on MacOS #4
1 parent e6de1c9 commit 6228805

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main/kotlin/com/tschuchort/compiletesting/KotlinCompilation.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import java.net.URI
3737
import java.net.URLClassLoader
3838
import java.nio.file.Files
3939
import java.nio.file.Path
40+
import java.nio.file.Paths
4041
import javax.annotation.processing.Processor
4142
import javax.tools.*
4243

@@ -471,18 +472,18 @@ class KotlinCompilation {
471472
)
472473

473474
val resourcesPath = when(resourcesUri.scheme) {
474-
"jar" -> resourcesUri.schemeSpecificPart.removeSurrounding("file:", "!")
475-
"file" -> resourcesUri.schemeSpecificPart
475+
"jar" -> Paths.get(URI.create(resourcesUri.schemeSpecificPart.removeSuffix("!")))
476+
"file" -> Paths.get(resourcesUri)
476477
else -> throw IllegalStateException(
477478
"Don't know how to handle protocol of ComponentRegistrar plugin. " +
478479
"Did you include this library in a weird way? Only jar and file path are supported."
479480
)
480-
}.removePrefix("/")
481+
}.toAbsolutePath()
481482

482483
val k2JvmArgs = commonK2JVMArgs().also {
483484
it.freeArgs = sourcePaths
484485

485-
it.pluginClasspaths = (it.pluginClasspaths?.toList() ?: emptyList<String>() + resourcesPath)
486+
it.pluginClasspaths = (it.pluginClasspaths?.toList() ?: emptyList<String>() + resourcesPath.toString())
486487
.distinct().toTypedArray()
487488
}
488489

0 commit comments

Comments
 (0)