Skip to content

Commit

Permalink
Manage buildSrc JDK Version in libs.versions.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
mrclrchtr committed Nov 15, 2023
1 parent 4081bf2 commit 1c0920e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

val libs: VersionCatalog = extensions.getByType<VersionCatalogsExtension>().named("libs")

plugins {
Expand All @@ -12,6 +15,34 @@ repositories {
mavenCentral()
}

kotlin {
jvmToolchain {
languageVersion.set(
JavaLanguageVersion.of(libs.findVersion("jdk").get().toString())
)
}
compilerOptions {
@Suppress("SpellCheckingInspection")
freeCompilerArgs.add("-Xjsr305=strict")
allWarningsAsErrors = false
jvmTarget.set(JvmTarget.valueOf("JVM_${libs.findVersion("jdk").get()}"))
languageVersion.set(
KotlinVersion.valueOf(
"KOTLIN_${
libs.findVersion("kotlin").get().toString().substringBeforeLast(".").replace(".", "_")
}"
)
)
apiVersion.set(
KotlinVersion.valueOf(
"KOTLIN_${
libs.findVersion("kotlin").get().toString().substringBeforeLast(".").replace(".", "_")
}"
)
)
}
}

dependencies {
// buildSrc in combination with this plugin ensures that the version set here
// will be set to the same for all other Kotlin dependencies / plugins in the project.
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
kotlin-logging = "3.0.5"
lorem = "2.2"
j2html = "1.6.0"
jdk = "17"
kotlin = "1.9.20"
kotlinForDetekt = "1.9.10"
springBoot = "3.1.5"
Expand Down

0 comments on commit 1c0920e

Please sign in to comment.