Skip to content

Commit

Permalink
Update ASM (#173)
Browse files Browse the repository at this point in the history
* Update ASM to 9.6
* Added Java versions compatibility test
  • Loading branch information
fzhinkin authored Jan 24, 2024
1 parent 4367cb7 commit 3969489
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ javaDiffUtils = "4.12"
junit = "5.9.2"
kotest = "5.5.5"
kotlinx-bcv = "0.13.1"
ow2Asm = "9.2"
ow2Asm = "9.6"

gradlePluginPublishPlugin = "1.1.0"
androidGradlePlugin = "7.2.2"
Expand Down
17 changes: 13 additions & 4 deletions src/functionalTest/kotlin/kotlinx/validation/api/TestDsl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import org.intellij.lang.annotations.Language

public val API_DIR: String = ApiValidationExtension().apiDumpDirectory

internal fun BaseKotlinGradleTest.test(fn: BaseKotlinScope.() -> Unit): GradleRunner {
internal fun BaseKotlinGradleTest.test(
gradleVersion: String = "7.4.2",
injectPluginClasspath: Boolean = true,
fn: BaseKotlinScope.() -> Unit
): GradleRunner {
val baseKotlinScope = BaseKotlinScope()
fn(baseKotlinScope)

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

return GradleRunner.create() //
val runner = GradleRunner.create()
.withProjectDir(rootProjectDir)
.withPluginClasspath()
.withArguments(baseKotlinScope.runner.arguments)
.withGradleVersion("7.4.2")
.addPluginTestRuntimeClasspath()
.withGradleVersion(gradleVersion)
if (injectPluginClasspath) {
// The hack dating back to https://docs.gradle.org/6.0/userguide/test_kit.html#sub:test-kit-classpath-injection
// Currently, some tests won't work without it because some classes are missing on the classpath.
runner.addPluginTestRuntimeClasspath()
}
return runner
// disabled because of: https://github.com/gradle/gradle/issues/6862
// .withDebug(baseKotlinScope.runner.debug)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright 2016-2024 JetBrains s.r.o.
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
*/

package kotlinx.validation.test

import kotlinx.validation.api.*
import kotlinx.validation.api.buildGradleKts
import kotlinx.validation.api.resolve
import kotlinx.validation.api.test
import org.junit.Test

class JavaVersionsCompatibilityTest : BaseKotlinGradleTest() {
private fun checkCompatibility(useMaxVersion: Boolean) {
val runner = test(gradleVersion = "8.5", injectPluginClasspath = false) {
buildGradleKts {
resolve("/examples/gradle/base/jdkCompatibility.gradle.kts")
}
settingsGradleKts {
resolve("/examples/gradle/settings/jdk-provisioning.gradle.kts")
}
kotlin("AnotherBuildConfig.kt") {
resolve("/examples/classes/AnotherBuildConfig.kt")
}
apiFile(projectName = rootProjectDir.name) {
resolve("/examples/classes/AnotherBuildConfig.dump")
}

runner {
arguments.add("-PuseMaxVersion=$useMaxVersion")
arguments.add(":apiCheck")
}
}

runner.build().apply {
assertTaskSuccess(":apiCheck")
}
}

private fun checkCompatibility(jdkVersion: String) {
val runner = test(gradleVersion = "8.5", injectPluginClasspath = false) {
buildGradleKts {
resolve("/examples/gradle/base/jdkCompatibilityWithExactVersion.gradle.kts")
}
settingsGradleKts {
resolve("/examples/gradle/settings/jdk-provisioning.gradle.kts")
}
kotlin("AnotherBuildConfig.kt") {
resolve("/examples/classes/AnotherBuildConfig.kt")
}
apiFile(projectName = rootProjectDir.name) {
resolve("/examples/classes/AnotherBuildConfig.dump")
}

runner {
arguments.add("-PjdkVersion=$jdkVersion")
arguments.add(":apiCheck")
}
}

runner.build().apply {
assertTaskSuccess(":apiCheck")
}
}

@Test
fun testMaxSupportedVersion() {
checkCompatibility(true)
}

@Test
fun testMinSupportedVersion() {
checkCompatibility(false)
}

@Test
fun testLts8() {
checkCompatibility("1.8")
}

@Test
fun testLts11() {
checkCompatibility("11")
}

@Test
fun testLts17() {
checkCompatibility("17")
}

@Test
fun testLts21() {
checkCompatibility("21")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2016-2024 JetBrains s.r.o.
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
*/

import org.jetbrains.kotlin.config.JvmTarget

plugins {
kotlin("jvm") version "1.9.22"
id("org.jetbrains.kotlinx.binary-compatibility-validator")
}

repositories {
mavenCentral()
}

val minTarget = JvmTarget.supportedValues().minBy { it.majorVersion }
val maxTarget = JvmTarget.supportedValues().maxBy { it.majorVersion }

val useMax = (project.properties["useMaxVersion"]?.toString() ?: "false").toBoolean()
val target = (if (useMax) maxTarget else minTarget).toString()

val toolchainVersion = target.split('.').last().toInt()

kotlin {
jvmToolchain(toolchainVersion)
}

tasks.compileKotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(target))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2016-2024 JetBrains s.r.o.
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
*/

import org.jetbrains.kotlin.config.JvmTarget

plugins {
kotlin("jvm") version "1.9.22"
id("org.jetbrains.kotlinx.binary-compatibility-validator")
}

repositories {
mavenCentral()
}

val target = project.properties["jdkVersion"]!!.toString()
val toolchainVersion = target.split('.').last().toInt()

kotlin {
jvmToolchain(toolchainVersion)
}

tasks.compileKotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(target))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright 2016-2024 JetBrains s.r.o.
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
*/

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version ("0.7.0")
}

0 comments on commit 3969489

Please sign in to comment.