Apply -Xklib-relative-path-base to all KotlinCompile tasks

As absolute paths were also revealed in
   atomicfu.jar
   kotlin-stdlib-wasm
   kotlin-test-wasm

Use solution from Alexander Likhachev (avoid accessing
buildDir, projectDir in doFirst()) to prevent breaking the configuration
cache.

Should be removed after fixing KT-50876

KTI-729
This commit is contained in:
Nikolay Krasko
2022-04-05 16:30:23 +03:00
committed by teamcity
parent 81b1ed9ad4
commit 405e90abee
3 changed files with 11 additions and 12 deletions
+11
View File
@@ -494,6 +494,17 @@ allprojects {
apiVersion = kotlinLanguageVersion
freeCompilerArgs = commonCompilerArgs
}
val relativePathBaseArg: String? =
"-Xklib-relative-path-base=$buildDir,$projectDir".takeIf {
!kotlinBuildProperties.getBoolean("kotlin.build.use.absolute.paths.in.klib")
}
doFirst {
if (relativePathBaseArg != null) {
kotlinOptions.freeCompilerArgs += relativePathBaseArg
}
}
}
val jvmCompilerArgs = listOf(
@@ -52,12 +52,6 @@ tasks.withType<KotlinCompile<*>>().configureEach {
"-opt-in=kotlin.ExperimentalMultiplatform",
"-opt-in=kotlin.contracts.ExperimentalContracts"
)
doFirst {
kotlinOptions.freeCompilerArgs += listOfNotNull(
"-Xklib-relative-path-base=$buildDir,$projectDir".takeIf { !kotlinBuildProperties.getBoolean("kotlin.build.use.absolute.paths.in.klib") }
)
}
}
tasks.named("compileKotlinJs") {
-6
View File
@@ -143,12 +143,6 @@ tasks.withType<KotlinCompile<*>>().configureEach {
"-opt-in=kotlin.ExperimentalUnsignedTypes",
"-opt-in=kotlin.ExperimentalStdlibApi"
)
doFirst {
kotlinOptions.freeCompilerArgs += listOfNotNull(
"-Xklib-relative-path-base=$buildDir,$projectDir".takeIf { !kotlinBuildProperties.getBoolean("kotlin.build.use.absolute.paths.in.klib") }
)
}
}
val compileKotlinJs by tasks.existing(KotlinCompile::class) {