diff --git a/build.gradle b/build.gradle index 76c2c1a5..0850aae9 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { id 'checkstyle' id 'jacoco' id 'codenarc' - id "org.jetbrains.kotlin.jvm" version "1.8.0" // Must match the version included with gradle. + alias(libs.plugins.kotlin) id "com.diffplug.spotless" version "6.18.0" id "org.gradle.test-retry" version "1.5.2" } @@ -34,6 +34,12 @@ if (ENV.BUILD_NUMBER) { version = baseVersion + '.local' } +// We must build against the version of Kotlin Gradle ships with. +def kotlinVersion = KotlinDslVersion.current().getKotlinVersion() +if (libs.versions.kotlin.get() != kotlinVersion) { + throw new IllegalStateException("Requires Kotlin version: ${kotlinVersion}") +} + repositories { maven { name = 'Fabric' @@ -100,7 +106,7 @@ dependencies { } // Kapt integration - compileOnly('org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0') // Must match the version included with gradle. + compileOnly libs.kotlin.gradle.plugin // Testing testImplementation(gradleTestKit()) @@ -216,6 +222,7 @@ test { } } +import org.gradle.launcher.cli.KotlinDslVersion import org.gradle.util.GradleVersion import org.w3c.dom.Document import org.w3c.dom.Element diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..a8f38ae5 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,8 @@ +[versions] +kotlin = "1.8.10" + +[libraries] +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } + +[plugins] +kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } \ No newline at end of file