Skip to content

Commit

Permalink
Migrate deprecated compilerOptions DSL
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Spiegl <[email protected]>
  • Loading branch information
rspiegl committed Jun 11, 2024
1 parent db56a85 commit 9a22554
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.gradle.jvm.toolchain.JavaToolchainSpec
import org.jetbrains.kotlin.allopen.gradle.AllOpenExtension
import org.jetbrains.kotlin.allopen.gradle.SpringGradleSubplugin
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.internal.Kapt3GradleSubplugin
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
Expand Down Expand Up @@ -71,12 +72,14 @@ class KotlinConfigurePlugin : Plugin<Project> {
}

project.afterEvaluate {
val kotlinVersion = kotlinConfigureExtension.kotlinVersion.get()
val kotlinMajorMinor = kotlinVersion.toMajorMinor()
val kotlinMajorMinor = kotlinConfigureExtension.kotlinVersion.get().toMajorMinor()
val kotlinVersion = KotlinVersion.fromVersion(kotlinMajorMinor)

tasks.withType(KotlinCompile::class.java).configureEach {
it.kotlinOptions.apiVersion = kotlinMajorMinor
it.kotlinOptions.languageVersion = kotlinMajorMinor
it.compilerOptions {
apiVersion.set(kotlinVersion)
languageVersion.set(kotlinVersion)
}
}
}
}
Expand All @@ -88,4 +91,4 @@ class KotlinConfigurePlugin : Plugin<Project> {
private fun String.toMajorMinor(): String {
return this.substringBeforeLast(".")
}
}
}

0 comments on commit 9a22554

Please sign in to comment.