Skip to content

Commit

Permalink
[infra] Use same version as apiVersion for stdlib & friends (#6293)
Browse files Browse the repository at this point in the history
* Use same version as apiVersion for stdlib & friends

See https://youtrack.jetbrains.com/issue/KT-58999/

* Do not conflict with KGP dependency handling

* Keep JS stdlib aligned with the compiler

* fixed parallel forks

* Revert "fixed parallel forks"

This reverts commit 479651f.

* more heap size
  • Loading branch information
martinbonnin authored and BoD committed Nov 28, 2024
1 parent dd9cb83 commit 01c0eb5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
8 changes: 5 additions & 3 deletions build-logic/src/main/kotlin/CompilerOptions.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import com.android.build.gradle.BaseExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.artifacts.ExternalDependency
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test
Expand Down Expand Up @@ -29,6 +29,7 @@ fun KotlinCommonCompilerOptions.configure(target: Int, kotlinCompilerOptions: Ko
// D8 can dex Java17 bytecode
17
}

else -> target
}

Expand Down Expand Up @@ -67,7 +68,7 @@ fun KotlinCommonCompilerOptions.configure(target: Int, kotlinCompilerOptions: Ko
}

private fun Int.toJvmTarget(): JvmTarget {
return when(this) {
return when (this) {
8 -> JvmTarget.JVM_1_8
else -> JvmTarget.fromTarget(this.toString())
}
Expand Down Expand Up @@ -107,7 +108,7 @@ val Project.androidExtensionOrNull: BaseExtension?

fun Project.configureJavaAndKotlinCompilers(jvmTarget: Int?, kotlinCompilerOptions: KotlinCompilerOptions) {
@Suppress("NAME_SHADOWING")
val jvmTarget = jvmTarget?: 8
val jvmTarget = jvmTarget ?: 8

kotlinExtensionOrNull?.forEachCompilerOptions { isAndroid ->
configure(jvmTarget, kotlinCompilerOptions, isAndroid)
Expand Down Expand Up @@ -147,6 +148,7 @@ fun Project.configureJavaAndKotlinCompilers(jvmTarget: Int?, kotlinCompilerOptio
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

kotlinExtensionOrNull?.coreLibrariesVersion = "${kotlinCompilerOptions.version.version}.0"
/**
* Required because of:
*
Expand Down
24 changes: 12 additions & 12 deletions gradle/libraries.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ junit = "4.13.2"
kotlin-plugin-min = "1.9.0"
kotlin-plugin = "2.1.0"
kotlin-plugin-max = "2.1.0"
kotlin-stdlib = "2.0.0"
kotlinx-coroutines = "1.9.0"
kotlinx-datetime = "0.5.0"
kotlinx-serialization-runtime = "1.6.2"
Expand Down Expand Up @@ -118,24 +117,25 @@ intellij-changelog = "org.jetbrains.intellij.plugins:gradle-changelog-plugin:2.0
jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version.ref = "jetbrains-annotations" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
kotlin-allopen = { group = "org.jetbrains.kotlin", name = "kotlin-allopen", version.ref = "kotlin-plugin" }
kotlin-compiletesting = { group = "dev.zacsweers.kctfork", name = "core", version = "0.4.0" }
kotlin-compiletesting = { group = "dev.zacsweers.kctfork", name = "core", version = "0.6.0" }
graphql-java = "com.graphql-java:graphql-java:20.4"
# The main kotlin version for build-logic and Gradle tests
kotlin-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin-plugin" }
kotlin-plugin-compose = { group = "org.jetbrains.kotlin", name = "compose-compiler-gradle-plugin", version.ref = "kotlin-plugin" }
# For Gradle integration tests to make sure we stay compatible with 1.5.0
kotlin-plugin-min = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin-plugin-min" }
kotlin-plugin-max = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin-plugin-max" }
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect" } # the Kotlin plugin resolves the version
kotlin-stdlib-common = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-common", version.ref = "kotlin-stdlib" }
kotlin-stdlib-jvm = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin-stdlib" }
kotlin-stdlib-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-js", version.ref = "kotlin-stdlib" }
kotlin-stdlib-wasm-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-wasm-js", version.ref = "kotlin-stdlib" }
kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test" } # the Kotlin plugin resolves the version
kotlin-test-js = { group = "org.jetbrains.kotlin", name = "kotlin-test-js" } # the Kotlin plugin resolves the version
kotlin-test-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit" } # the Kotlin plugin resolves the version
kotlin-test-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.ref = "kotlin-stdlib" } # use the same version as the stdlib
kotlin-test-junit-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit", version.ref = "kotlin-stdlib" } # use the same version as the stdlib
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect" } # use same version as apiVersion
kotlin-stdlib-common = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-common" } # use same version as apiVersion
kotlin-stdlib-jvm = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib" } # use same version as apiVersion
kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test" } # use same version as apiVersion
kotlin-test-js = { group = "org.jetbrains.kotlin", name = "kotlin-test-js" } # use same version as apiVersion
kotlin-test-junit = { group = "org.jetbrains.kotlin", name = "kotlin-test-junit" } # use same version as apiVersion
# Kotlin/JS has no apiVersion:
# The Kotlin/JS standard library has an older version (2.0.20-release-360) than the compiler (2.1.0). Such a configuration is not supported.
# Please, make sure that the standard library has the version in the range [2.1.0 .. 2.1.255]. Adjust your project's settings if necessary.
kotlin-stdlib-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-js", version.ref = "kotlin-plugin" }
kotlin-stdlib-wasm-js = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-wasm-js", version.ref = "kotlin-plugin" }
kotlinx-benchmark-runtime = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.4.8"
kotlinx-benchmark = "org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.4.12"
kotlinx-browser = "org.jetbrains.kotlinx:kotlinx-browser:0.2"
Expand Down
11 changes: 1 addition & 10 deletions libraries/apollo-compiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ dependencies {
testImplementation(libs.kotlin.compiletesting)
testImplementation(libs.google.testing.compile)
testImplementation(libs.truth)
testImplementation(libs.kotlin.test.junit.stdlib) {
because("We compile the generated code with Kotlin 1.9, which doesn't understand classes compiled with 2.1")
}
testImplementation(libs.kotlin.test.junit)
testImplementation(libs.google.testparameterinjector)
testImplementation(project(":apollo-api-java")) {
because("Generated Java code references Java and Guava Optionals")
Expand Down Expand Up @@ -84,10 +82,3 @@ tasks.withType<Test>().configureEach {
addRelativeInput("usedtypesDir","src/test/usedtypes")
addRelativeInput("validationDir", "src/test/validation")
}

configurations.all {
resolutionStrategy {
// We compile the generated code with Kotlin 1.9, which doesn't understand classes compiled with 2.1
force(libs.kotlin.test.stdlib.get())
}
}
2 changes: 2 additions & 0 deletions libraries/apollo-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ tasks.withType<Test> {
addRelativeInput("testFiles", "testFiles")
addRelativeInput("testProjects", "testProjects")

maxHeapSize = "1g"

maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
}

Expand Down

0 comments on commit 01c0eb5

Please sign in to comment.