From bf1463d3146cd0d76fdc0120452830cbbb174615 Mon Sep 17 00:00:00 2001 From: higan Date: Fri, 4 Aug 2023 18:20:44 +0800 Subject: [PATCH] :arrow_up: Upgrade to Spring Boot 3, Gradle 8.2.1 and Kotlin 1.9 --- build.gradle.kts | 4 +- gradle/libs.versions.toml | 17 ++++----- gradle/wrapper/gradle-wrapper.properties | 2 +- .../java/JavaDependenciesReplacePlugin.kt | 2 +- .../gradle/publishing/ProjectSigningPlugin.kt | 2 - .../threepart/SisyphusAntlrKotlinPlugin.kt | 38 ++++++------------- .../gradle/threepart/SisyphusDockerPlugin.kt | 2 +- .../kotlin/dsl/SisyphusDevelopmentLayer.kt | 2 +- 8 files changed, 26 insertions(+), 43 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 1f39332..a4577da 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "com.bybutter.sisyphus.tools" -version = "1.7.3" +version = "2.0.0" description = "Plugin for easy configuring Gradle and plugins in Sisyphus Framework" repositories { @@ -49,5 +49,5 @@ tasks.test { } kotlin { - jvmToolchain(8) + jvmToolchain(17) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3fe97c5..33b7ea4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,13 +1,12 @@ [versions] -kotlin = "1.8.10" -spring-boot = "2.7.9" -nebula-contacts = "7.0.0" -nebula-info = "12.0.1" -nebula-publishing = "20.1.0" -gradle-docker = "9.2.1" -plugin-publishing = "1.1.0" -kubernetes = "15.0.1" -ktlint = "11.3.1" +kotlin = "1.9.0" +spring-boot = "3.1.2" +nebula-contacts = "7.0.1" +nebula-info = "12.1.6" +nebula-publishing = "20.3.0" +gradle-docker = "9.3.2" +plugin-publishing = "1.2.0" +ktlint = "11.5.0" [libraries] nebula-info = { module = "com.netflix.nebula:gradle-info-plugin", version.ref = "nebula-info" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3796d3c..a1f2792 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/com/bybutter/sisyphus/project/gradle/java/JavaDependenciesReplacePlugin.kt b/src/main/kotlin/com/bybutter/sisyphus/project/gradle/java/JavaDependenciesReplacePlugin.kt index d7cb3d9..8b74c81 100644 --- a/src/main/kotlin/com/bybutter/sisyphus/project/gradle/java/JavaDependenciesReplacePlugin.kt +++ b/src/main/kotlin/com/bybutter/sisyphus/project/gradle/java/JavaDependenciesReplacePlugin.kt @@ -10,7 +10,7 @@ class JavaDependenciesReplacePlugin : Plugin { target.configurations.all { it.resolutionStrategy.eachDependency { detail -> - extension.managedDependencies.getting("${detail.requested.group}:${detail.requested.name}")?.orNull?.let { moduleStringNotation -> + extension.managedDependencies.getting("${detail.requested.group}:${detail.requested.name}").orNull?.let { moduleStringNotation -> detail.useVersion(moduleStringNotation.version) detail.because("The version of current dependency managed by Sisyphus Property") } diff --git a/src/main/kotlin/com/bybutter/sisyphus/project/gradle/publishing/ProjectSigningPlugin.kt b/src/main/kotlin/com/bybutter/sisyphus/project/gradle/publishing/ProjectSigningPlugin.kt index dc30f20..36c28e3 100644 --- a/src/main/kotlin/com/bybutter/sisyphus/project/gradle/publishing/ProjectSigningPlugin.kt +++ b/src/main/kotlin/com/bybutter/sisyphus/project/gradle/publishing/ProjectSigningPlugin.kt @@ -1,6 +1,5 @@ package com.bybutter.sisyphus.project.gradle.publishing -import com.bybutter.sisyphus.project.gradle.SisyphusExtension import com.bybutter.sisyphus.project.gradle.ensurePlugin import org.gradle.api.Plugin import org.gradle.api.Project @@ -16,7 +15,6 @@ class ProjectSigningPlugin : Plugin { if (!it) return } - val sisyphus = target.extensions.getByType(SisyphusExtension::class.java) val publishing = target.extensions.getByType(PublishingExtension::class.java) if (target.hasProperty("signing.gnupg.keyName")) { diff --git a/src/main/kotlin/com/bybutter/sisyphus/project/gradle/threepart/SisyphusAntlrKotlinPlugin.kt b/src/main/kotlin/com/bybutter/sisyphus/project/gradle/threepart/SisyphusAntlrKotlinPlugin.kt index 25752b7..f8fe6a4 100644 --- a/src/main/kotlin/com/bybutter/sisyphus/project/gradle/threepart/SisyphusAntlrKotlinPlugin.kt +++ b/src/main/kotlin/com/bybutter/sisyphus/project/gradle/threepart/SisyphusAntlrKotlinPlugin.kt @@ -4,9 +4,8 @@ import com.bybutter.sisyphus.project.gradle.ensurePlugin import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.antlr.AntlrTask -import org.gradle.api.tasks.bundling.Jar -import org.jetbrains.kotlin.gradle.dsl.KotlinCompile -import org.jlleitschuh.gradle.ktlint.tasks.KtLintCheckTask +import org.gradle.api.tasks.SourceSetContainer +import org.gradle.util.internal.GUtil class SisyphusAntlrKotlinPlugin : Plugin { override fun apply(target: Project) { @@ -15,33 +14,20 @@ class SisyphusAntlrKotlinPlugin : Plugin { }.let { if (it) applyBasic(target) } - target.ensurePlugin("org.gradle.antlr", "kotlin") { - applyWithKotlin(it) - }.let { - if (it) applyWithKotlin(target) - } - target.ensurePlugin("org.gradle.antlr", "org.jlleitschuh.gradle.ktlint") { - applyWithKtlint(it) - }.let { - if (it) applyWithKtlint(target) - } } private fun applyBasic(target: Project) { - target.tasks.withType(Jar::class.java).configureEach { - it.mustRunAfter(target.tasks.withType(AntlrTask::class.java)) - } - } - - private fun applyWithKotlin(target: Project) { - target.tasks.withType(KotlinCompile::class.java).configureEach { - it.mustRunAfter(target.tasks.withType(AntlrTask::class.java)) - } - } + val sourceSets = target.extensions.getByType(SourceSetContainer::class.java) - private fun applyWithKtlint(target: Project) { - target.tasks.withType(KtLintCheckTask::class.java).configureEach { - it.mustRunAfter(target.tasks.withType(AntlrTask::class.java)) + sourceSets.forEach { + val generateTaskName = when (it.name) { + "main" -> "generateGrammarSource" + else -> "generate${GUtil.toCamelCase(it.name)}GrammarSource" + } + target.tasks.named(generateTaskName, AntlrTask::class.java).configure { task -> + it.java.setSrcDirs(it.java.srcDirs.filter { task.outputDirectory.absolutePath != it.absolutePath }) + it.java.srcDir(task) + } } } } diff --git a/src/main/kotlin/com/bybutter/sisyphus/project/gradle/threepart/SisyphusDockerPlugin.kt b/src/main/kotlin/com/bybutter/sisyphus/project/gradle/threepart/SisyphusDockerPlugin.kt index 6fe3ea2..93671df 100644 --- a/src/main/kotlin/com/bybutter/sisyphus/project/gradle/threepart/SisyphusDockerPlugin.kt +++ b/src/main/kotlin/com/bybutter/sisyphus/project/gradle/threepart/SisyphusDockerPlugin.kt @@ -68,7 +68,7 @@ class SisyphusDockerPlugin : Plugin { it.instructions.add(instruction) } - bootJar.layered.layerOrder.forEach { layer -> + bootJar.layered.layerOrder.get().forEach { layer -> it.copyFile("$layer/", "./") it.runCommand("true") } diff --git a/src/main/kotlin/org/gradle/kotlin/dsl/SisyphusDevelopmentLayer.kt b/src/main/kotlin/org/gradle/kotlin/dsl/SisyphusDevelopmentLayer.kt index 4fa3522..4b346ff 100644 --- a/src/main/kotlin/org/gradle/kotlin/dsl/SisyphusDevelopmentLayer.kt +++ b/src/main/kotlin/org/gradle/kotlin/dsl/SisyphusDevelopmentLayer.kt @@ -83,4 +83,4 @@ fun Project.layer(dependency: Provider, layer: SisyphusDevel return dependency.map { layer(it, layer) } -} \ No newline at end of file +}