Skip to content

Commit 9422d1b

Browse files
authored
Test and fix example-gradle-task against latest code (#459)
Updates the test case that verifies running the example Kotlin **plugin project** (a Gradle task which uses the API, added in #452) against the current library code, i.e. a SNAPSHOT artifact compiled just before the tests and published to Maven local. To fix #404, language version had been downgraded to 1.8. To fully restore compatibility of the latest code, which has since been updated to use Kotlin plugin 2.2.x (with 1.8 language version, but 2.2.x stdlib), stdlib and okhttp are downgraded. This restores compatibility with Gradle 8.11 <= v < 9.0.0. This [build scan][1] demonstrates the compiler version (not language version) incompatibility that is now fixed: ``` e: file:///Users/gfeo/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp-jvm/5.1.0/c17340f19b33c1d28a47b8dc4ae15018aff6dc10/okhttp-jvm-5.1.0.jar!/META-INF/okhttp.kotlin_module Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.2.0, expected version is 2.0.0. e: file:///Users/gfeo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.2.10/30de6faa127a4a012db8e71bf1b9c0a99b1402b2/kotlin-stdlib-2.2.10.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.2.0, expected version is 2.0.0. e: file:///Users/gfeo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.2.10/30de6faa127a4a012db8e71bf1b9c0a99b1402b2/kotlin-stdlib-2.2.10.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.2.0, expected version is 2.0.0. e: file:///Users/gfeo/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.2.10/30de6faa127a4a012db8e71bf1b9c0a99b1402b2/kotlin-stdlib-2.2.10.jar!/META-INF/kotlin-stdlib.kotlin_module Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.2.0, expected version is 2.0.0. ``` Prevents regressions like #404. Follow-up to #432, #456 and #458 for example-gradle-task. ExampleProjectTest is also refactored to use the init script introduced here. A smoke test verifying that the example is properly forced to use the published `SNAPSHOT` is added to both tests. `buildSrc` is used in `example-gradle-task` because `pluginManagement.repositories.exclusiveContent` set via init script rules don't seem to apply to build dependencies resolved from included builds. [1]: https://scans.gradle.com/s/hxgfny2ssyugo/tests/task/:library:examplesTest/details/com.gabrielfeo.develocity.api.example.gradle.ExampleGradleTaskTest/smokeTest()?focused-execution=1&top-execution=1#L0-L3
1 parent 6e2605f commit 9422d1b

File tree

15 files changed

+103
-33
lines changed

15 files changed

+103
-33
lines changed

build-logic/src/main/kotlin/com/gabrielfeo/examples-test-suite.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ val examples = fileTree(rootDir) {
2727
exclude {
2828
it.isDirectory
2929
&& (it.name == "build" || it.name.startsWith("."))
30-
&& !it.path.endsWith("build-logic/src/main/kotlin/build")
30+
&& !it.path.endsWith("buildSrc/src/main/kotlin/build")
3131
}
3232
}
3333

examples/example-gradle-task/build-logic/settings.gradle.kts

Lines changed: 0 additions & 8 deletions
This file was deleted.

examples/example-gradle-task/build-logic/build.gradle.kts renamed to examples/example-gradle-task/buildSrc/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ dependencies {
66
implementation("com.gabrielfeo:develocity-api-kotlin:2024.3.0")
77
implementation("org.apache.commons:commons-math3:3.6.1")
88
}
9+
10+
repositories {
11+
mavenCentral()
12+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = "dak-example-gradle-task-build-src"
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
pluginManagement {
2-
includeBuild("build-logic")
3-
}
4-
51
rootProject.name = "dak-example-gradle-task-main-build"

gradle/libs.versions.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[versions]
22
kotlin = "2.2.10"
3+
kotlin-stdlib = "2.0.0"
34
dokka = "2.0.0"
45
openapi-generator = "7.14.0"
56
jupyter = "0.15.0-594"
67
okio = "3.16.0"
78
moshi = "1.15.2"
8-
okhttp = "5.1.0"
9+
okhttp = "4.12.0"
910
retrofit = "3.0.0"
1011
kotlin-coroutines = "1.10.2"
1112
kotlin-binary-compatibility-validator = "0.18.1"
@@ -28,6 +29,7 @@ kotlin-jupyter-api = { module = "org.jetbrains.kotlinx:kotlin-jupyter-api", vers
2829
kotlin-jupyter-testkit = { module = "org.jetbrains.kotlinx:kotlin-jupyter-test-kit", version.ref = "jupyter" }
2930
kotlin-binary-compatibility-validator-plugin = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version.ref = "kotlin-binary-compatibility-validator" }
3031
kotlin-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
32+
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin-stdlib" }
3133
dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
3234
openapi-generator-plugin = { module = "org.openapitools:openapi-generator-gradle-plugin", version.ref = "openapi-generator" }
3335
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }

library/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ dependencies {
1313
constraints {
1414
implementation(libs.okio)
1515
}
16+
// Set fixed version of stdlib for compatibility with the version of Kotlin
17+
// embedded in earlier versions of Gradle
18+
implementation(libs.kotlin.stdlib)
1619
api(libs.okhttp)
1720
implementation(libs.okhttp.logging.interceptor)
1821
api(libs.retrofit)
@@ -101,6 +104,10 @@ tasks.named("compileKotlin", KotlinCompile::class) {
101104
}
102105

103106
tasks.withType<Test>().configureEach {
107+
systemProperty(
108+
"junit.jupiter.tempdir.cleanup.mode.default",
109+
System.getProperty("junit.jupiter.tempdir.cleanup.mode.default") ?: "always",
110+
)
104111
environment("DEVELOCITY_API_LOG_LEVEL", "DEBUG")
105112
providers.environmentVariablesPrefixedBy("DEVELOCITY_API_").get().forEach { (name, value) ->
106113
inputs.property("${name}.hashCode", value.hashCode())

0 commit comments

Comments
 (0)