Skip to content

Commit 91e9a2a

Browse files
Goooleregorikftp
authored andcommitted
Constraint Kotlin language version for the Gradle plugin
1 parent e55e8ad commit 91e9a2a

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import com.diffplug.gradle.spotless.SpotlessExtension
22
import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformDependenciesExtension
33
import org.jetbrains.intellij.platform.gradle.extensions.intellijPlatform
44
import org.jetbrains.intellij.platform.gradle.plugins.project.IntelliJPlatformBasePlugin
5+
import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
6+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
7+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
58

69
plugins {
710
alias(libs.plugins.kotlin.jvm) apply false
@@ -70,6 +73,17 @@ allprojects {
7073
}
7174
}
7275

76+
tasks.withType<JavaCompile>().configureEach {
77+
options.release = libs.versions.jdkRelease.get().toInt()
78+
}
79+
80+
tasks.withType<KotlinCompile>().configureEach {
81+
compilerOptions {
82+
jvmTarget = JvmTarget.fromTarget(libs.versions.jdkRelease.get())
83+
freeCompilerArgs.add("-Xjdk-release=${libs.versions.jdkRelease.get()}")
84+
}
85+
}
86+
7387
tasks.withType<Test>().configureEach {
7488
useJUnitPlatform()
7589
}

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ jacoco = "0.8.13"
66
kotlin = "2.2.20"
77
kover = "0.9.3"
88
leviathan = "3.1.0-1.8.2"
9+
jdkRelease = "17"
910

1011
[libraries]
1112
android-build-tools = "com.android.tools:sdk-common:31.13.0"

tools/cli/build.gradle.kts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@ application {
1717
version = versionName
1818
}
1919

20-
java {
21-
sourceCompatibility = JavaVersion.VERSION_21
22-
targetCompatibility = JavaVersion.VERSION_21
23-
}
24-
25-
kotlin {
26-
compilerOptions {
27-
jvmTarget = JvmTarget.JVM_21
28-
}
29-
}
30-
3120
sourceSets {
3221
test {
3322
resources.srcDir("$rootDir/components/test/sharedTestResources")

tools/gradle-plugin/build.gradle.kts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import java.nio.file.Paths
22
import java.util.Properties
33
import kotlin.io.path.exists
4+
import org.gradle.api.plugins.JavaPlugin.API_ELEMENTS_CONFIGURATION_NAME
5+
import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
6+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
7+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
48

59
plugins {
610
alias(libs.plugins.kotlin.jvm)
@@ -15,6 +19,14 @@ tasks.validatePlugins {
1519
enableStricterValidation = true
1620
}
1721

22+
kotlin {
23+
compilerOptions {
24+
// https://docs.gradle.org/current/userguide/compatibility.html#kotlin
25+
apiVersion = KotlinVersion.KOTLIN_2_2
26+
languageVersion = apiVersion
27+
}
28+
}
29+
1830
gradlePlugin {
1931
vcsUrl = "https://github.com/ComposeGears/Valkyrie"
2032
website = "https://github.com/ComposeGears/Valkyrie"
@@ -30,6 +42,14 @@ gradlePlugin {
3042
}
3143
}
3244

45+
configurations.named(API_ELEMENTS_CONFIGURATION_NAME) {
46+
attributes.attribute(
47+
// TODO: https://github.com/gradle/gradle/issues/24608
48+
GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE,
49+
objects.named("9.0.0"),
50+
)
51+
}
52+
3353
val sharedTestResourcesDir: File =
3454
project(projects.components.test.path)
3555
.layout

0 commit comments

Comments
 (0)