Build: add kotlin.build.useIRForLibraries to enable JVM IR for libraries separately

The next step for JVM IR adoption in our project is going to be enabling
`kotlin.build.useIR`, but keeping `kotlin.build.useIRForLibraries`
disabled until we fix all remaining ABI incompatibility issues for
library code.
This commit is contained in:
Alexander Udalov
2020-10-14 22:11:24 +02:00
parent 29d8730964
commit 4c09906235
12 changed files with 39 additions and 0 deletions
+5
View File
@@ -8,7 +8,12 @@ defaultSnapshotVersion=1.4.255-SNAPSHOT
kotlin.compiler.effectSystemEnabled=true kotlin.compiler.effectSystemEnabled=true
kotlin.compiler.newInferenceEnabled=true kotlin.compiler.newInferenceEnabled=true
# Enable JVM IR backend for all modules except libraries such as kotlin-stdlib, kotlin-reflect, kotlin-test.
#kotlin.build.useIR=true #kotlin.build.useIR=true
# Enable JVM IR backend for the libraries mentioned above.
#kotlin.build.useIRForLibraries=true
#maven.repository.mirror=http://repository.jetbrains.com/remote-repos/ #maven.repository.mirror=http://repository.jetbrains.com/remote-repos/
#bootstrap.kotlin.repo=https://dl.bintray.com/kotlin/kotlin-dev #bootstrap.kotlin.repo=https://dl.bintray.com/kotlin/kotlin-dev
#bootstrap.kotlin.version=1.1.50-dev-1451 #bootstrap.kotlin.version=1.1.50-dev-1451
+15
View File
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
ext.configureJavaOnlyJvm6Project = { Project project -> ext.configureJavaOnlyJvm6Project = { Project project ->
project.tasks.withType(JavaCompile) { project.tasks.withType(JavaCompile) {
sourceCompatibility = 1.6 sourceCompatibility = 1.6
@@ -193,6 +195,19 @@ ext.configureLegacyPublishing = { Project project ->
} }
} }
ext.configureJvmIrBackend = { Project project ->
project.tasks.withType(KotlinCompile.class) { task ->
task.kotlinOptions {
if (CommonUtilKt.getBooleanProperty(project, "kotlin.build.useIRForLibraries")) {
useIR = true
freeCompilerArgs += ["-Xir-binary-with-stable-abi"]
} else {
useIR = false
}
}
}
}
allprojects { project -> allprojects { project ->
project.ext.configureSourcesJar = { lambda = {} -> project.ext.configureSourcesJar = { lambda = {} ->
ArtifactsKt.sourcesJar(project) { task -> ArtifactsKt.sourcesJar(project) { task ->
+2
View File
@@ -38,6 +38,8 @@ compileTestKotlin {
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"] kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
} }
configureJvmIrBackend(project)
if (includeJava9) { if (includeJava9) {
compileJava9Sources(project, 'kotlin.test.junit') compileJava9Sources(project, 'kotlin.test.junit')
} }
@@ -48,6 +48,8 @@ compileTestKotlin {
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"] kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
} }
configureJvmIrBackend(project)
if (includeJava9) { if (includeJava9) {
compileJava9Sources(project, 'kotlin.test.junit5') compileJava9Sources(project, 'kotlin.test.junit5')
} }
+2
View File
@@ -53,6 +53,8 @@ compileTestKotlin {
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"] kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
} }
configureJvmIrBackend(project)
if (includeJava9) { if (includeJava9) {
compileJava9Sources(project, 'kotlin.test') compileJava9Sources(project, 'kotlin.test')
} }
@@ -41,6 +41,8 @@ compileTestKotlin {
kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"] kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package"]
} }
configureJvmIrBackend(project)
if (includeJava9) { if (includeJava9) {
compileJava9Sources(project, 'kotlin.test.testng') compileJava9Sources(project, 'kotlin.test.testng')
} }
+2
View File
@@ -52,6 +52,8 @@ compileKotlin {
} }
} }
configureJvmIrBackend(project)
jar { jar {
manifestAttributes(manifest, project, "internal") manifestAttributes(manifest, project, "internal")
} }
+2
View File
@@ -91,6 +91,8 @@ compileTestKotlin {
] ]
} }
configureJvmIrBackend(project)
compileJava9Sources(project, 'kotlin.stdlib.jdk7') compileJava9Sources(project, 'kotlin.stdlib.jdk7')
test { test {
+2
View File
@@ -84,6 +84,8 @@ compileTestKotlin {
] ]
} }
configureJvmIrBackend(project)
compileJava9Sources(project, 'kotlin.stdlib.jdk8') compileJava9Sources(project, 'kotlin.stdlib.jdk8')
test { test {
+2
View File
@@ -145,6 +145,8 @@ compileLongRunningTestKotlin {
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.ExperimentalStdlibApi" kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.ExperimentalStdlibApi"
} }
configureJvmIrBackend(project)
task longRunningTest(type: Test, dependsOn: longRunningTestClasses) { task longRunningTest(type: Test, dependsOn: longRunningTestClasses) {
group = "verification" group = "verification"
testClassesDirs = sourceSets.longRunningTest.output.classesDirs testClassesDirs = sourceSets.longRunningTest.output.classesDirs
@@ -33,3 +33,4 @@ compileKotlin {
] ]
} }
configureJvmIrBackend(project)
@@ -39,3 +39,5 @@ compileKotlin {
"-module-name", project.name "-module-name", project.name
] ]
} }
configureJvmIrBackend(project)