Skip to content

Commit 3969489

Browse files
authored
Update ASM (#173)
* Update ASM to 9.6 * Added Java versions compatibility test
1 parent 4367cb7 commit 3969489

File tree

6 files changed

+179
-5
lines changed

6 files changed

+179
-5
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ javaDiffUtils = "4.12"
66
junit = "5.9.2"
77
kotest = "5.5.5"
88
kotlinx-bcv = "0.13.1"
9-
ow2Asm = "9.2"
9+
ow2Asm = "9.6"
1010

1111
gradlePluginPublishPlugin = "1.1.0"
1212
androidGradlePlugin = "7.2.2"

src/functionalTest/kotlin/kotlinx/validation/api/TestDsl.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import org.intellij.lang.annotations.Language
1212

1313
public val API_DIR: String = ApiValidationExtension().apiDumpDirectory
1414

15-
internal fun BaseKotlinGradleTest.test(fn: BaseKotlinScope.() -> Unit): GradleRunner {
15+
internal fun BaseKotlinGradleTest.test(
16+
gradleVersion: String = "7.4.2",
17+
injectPluginClasspath: Boolean = true,
18+
fn: BaseKotlinScope.() -> Unit
19+
): GradleRunner {
1620
val baseKotlinScope = BaseKotlinScope()
1721
fn(baseKotlinScope)
1822

@@ -29,12 +33,17 @@ internal fun BaseKotlinGradleTest.test(fn: BaseKotlinScope.() -> Unit): GradleRu
2933
}
3034
}
3135

32-
return GradleRunner.create() //
36+
val runner = GradleRunner.create()
3337
.withProjectDir(rootProjectDir)
3438
.withPluginClasspath()
3539
.withArguments(baseKotlinScope.runner.arguments)
36-
.withGradleVersion("7.4.2")
37-
.addPluginTestRuntimeClasspath()
40+
.withGradleVersion(gradleVersion)
41+
if (injectPluginClasspath) {
42+
// The hack dating back to https://docs.gradle.org/6.0/userguide/test_kit.html#sub:test-kit-classpath-injection
43+
// Currently, some tests won't work without it because some classes are missing on the classpath.
44+
runner.addPluginTestRuntimeClasspath()
45+
}
46+
return runner
3847
// disabled because of: https://github.com/gradle/gradle/issues/6862
3948
// .withDebug(baseKotlinScope.runner.debug)
4049
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright 2016-2024 JetBrains s.r.o.
3+
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4+
*/
5+
6+
package kotlinx.validation.test
7+
8+
import kotlinx.validation.api.*
9+
import kotlinx.validation.api.buildGradleKts
10+
import kotlinx.validation.api.resolve
11+
import kotlinx.validation.api.test
12+
import org.junit.Test
13+
14+
class JavaVersionsCompatibilityTest : BaseKotlinGradleTest() {
15+
private fun checkCompatibility(useMaxVersion: Boolean) {
16+
val runner = test(gradleVersion = "8.5", injectPluginClasspath = false) {
17+
buildGradleKts {
18+
resolve("/examples/gradle/base/jdkCompatibility.gradle.kts")
19+
}
20+
settingsGradleKts {
21+
resolve("/examples/gradle/settings/jdk-provisioning.gradle.kts")
22+
}
23+
kotlin("AnotherBuildConfig.kt") {
24+
resolve("/examples/classes/AnotherBuildConfig.kt")
25+
}
26+
apiFile(projectName = rootProjectDir.name) {
27+
resolve("/examples/classes/AnotherBuildConfig.dump")
28+
}
29+
30+
runner {
31+
arguments.add("-PuseMaxVersion=$useMaxVersion")
32+
arguments.add(":apiCheck")
33+
}
34+
}
35+
36+
runner.build().apply {
37+
assertTaskSuccess(":apiCheck")
38+
}
39+
}
40+
41+
private fun checkCompatibility(jdkVersion: String) {
42+
val runner = test(gradleVersion = "8.5", injectPluginClasspath = false) {
43+
buildGradleKts {
44+
resolve("/examples/gradle/base/jdkCompatibilityWithExactVersion.gradle.kts")
45+
}
46+
settingsGradleKts {
47+
resolve("/examples/gradle/settings/jdk-provisioning.gradle.kts")
48+
}
49+
kotlin("AnotherBuildConfig.kt") {
50+
resolve("/examples/classes/AnotherBuildConfig.kt")
51+
}
52+
apiFile(projectName = rootProjectDir.name) {
53+
resolve("/examples/classes/AnotherBuildConfig.dump")
54+
}
55+
56+
runner {
57+
arguments.add("-PjdkVersion=$jdkVersion")
58+
arguments.add(":apiCheck")
59+
}
60+
}
61+
62+
runner.build().apply {
63+
assertTaskSuccess(":apiCheck")
64+
}
65+
}
66+
67+
@Test
68+
fun testMaxSupportedVersion() {
69+
checkCompatibility(true)
70+
}
71+
72+
@Test
73+
fun testMinSupportedVersion() {
74+
checkCompatibility(false)
75+
}
76+
77+
@Test
78+
fun testLts8() {
79+
checkCompatibility("1.8")
80+
}
81+
82+
@Test
83+
fun testLts11() {
84+
checkCompatibility("11")
85+
}
86+
87+
@Test
88+
fun testLts17() {
89+
checkCompatibility("17")
90+
}
91+
92+
@Test
93+
fun testLts21() {
94+
checkCompatibility("21")
95+
}
96+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2016-2024 JetBrains s.r.o.
3+
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4+
*/
5+
6+
import org.jetbrains.kotlin.config.JvmTarget
7+
8+
plugins {
9+
kotlin("jvm") version "1.9.22"
10+
id("org.jetbrains.kotlinx.binary-compatibility-validator")
11+
}
12+
13+
repositories {
14+
mavenCentral()
15+
}
16+
17+
val minTarget = JvmTarget.supportedValues().minBy { it.majorVersion }
18+
val maxTarget = JvmTarget.supportedValues().maxBy { it.majorVersion }
19+
20+
val useMax = (project.properties["useMaxVersion"]?.toString() ?: "false").toBoolean()
21+
val target = (if (useMax) maxTarget else minTarget).toString()
22+
23+
val toolchainVersion = target.split('.').last().toInt()
24+
25+
kotlin {
26+
jvmToolchain(toolchainVersion)
27+
}
28+
29+
tasks.compileKotlin {
30+
compilerOptions {
31+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(target))
32+
}
33+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2016-2024 JetBrains s.r.o.
3+
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4+
*/
5+
6+
import org.jetbrains.kotlin.config.JvmTarget
7+
8+
plugins {
9+
kotlin("jvm") version "1.9.22"
10+
id("org.jetbrains.kotlinx.binary-compatibility-validator")
11+
}
12+
13+
repositories {
14+
mavenCentral()
15+
}
16+
17+
val target = project.properties["jdkVersion"]!!.toString()
18+
val toolchainVersion = target.split('.').last().toInt()
19+
20+
kotlin {
21+
jvmToolchain(toolchainVersion)
22+
}
23+
24+
tasks.compileKotlin {
25+
compilerOptions {
26+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(target))
27+
}
28+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* Copyright 2016-2024 JetBrains s.r.o.
3+
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4+
*/
5+
6+
plugins {
7+
id("org.gradle.toolchains.foojay-resolver-convention") version ("0.7.0")
8+
}

0 commit comments

Comments
 (0)