Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ASM #173

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -11,7 +11,11 @@ import org.intellij.lang.annotations.Language

public const val API_DIR: String = "api"

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 @@ -28,12 +32,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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quite unusual to see copyrights in settings.gradle )

* 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")
}