From 6bbc34b54dd2ee29c2244576dc3f6a82dfdcb67f Mon Sep 17 00:00:00 2001 From: Johannes Zick Date: Fri, 9 Aug 2024 15:16:16 +0200 Subject: [PATCH] Upgrade Gradle to the latest version 8.9 The newest version of Gradle broke parts of the current build. Some deprecated features were also still in use. This PR tries to fix some of those. Importing and applying scripts directly has been discouraged for a while. The same is true for using a `subprojects` block to share configuration. The recommended way to do this are convention plugins. It is straightforward for the most part to convert the existing scripts to convention plugins. The contents of the `subprojects` block can also be applied in a convention plugin. To make fixing the remaining issues easier, and help in future development, the convention plugins are then converted to Kotlin. The code completion and better typing help find and fix issues. Some small simplifications have been made, where a direct API is available instead of workarounds. A bigger change of this kind is changing dependencies from `implementation` to `api` directly instead of rewriting their scope later directly in the Maven POM. --- build.gradle | 134 +++--------------- buildSrc/build.gradle.kts | 18 +++ .../unit-api.java-conventions.gradle.kts | 69 +++++++++ .../main/kotlin/unit-api.javadoc.gradle.kts | 15 ++ .../kotlin/unit-api.publishing.gradle.kts | 72 ++++++++++ .../unit-api.spring-conventions.gradle.kts | 26 ++++ .../src/main/kotlin/unit-api.test.gradle.kts | 27 ++++ .../kotlin/unit-api.version-class.gradle.kts | 51 ++++--- gradle/scripts/javadoc.gradle | 25 ---- gradle/scripts/publishing.gradle | 79 ----------- gradle/scripts/release.gradle | 17 --- gradle/scripts/test.gradle | 16 --- gradle/scripts/updateMkdocsConfig.gradle | 7 - gradle/wrapper/gradle-wrapper.properties | 2 +- spring-boot-core-starter/build.gradle | 18 +-- spring-boot-jackson-starter/build.gradle | 17 +-- spring-boot-jpa-starter/build.gradle | 14 +- spring-boot-springdoc-starter/build.gradle | 18 ++- unit-api-core/build.gradle | 6 +- unit-api-jackson/build.gradle | 6 +- unit-api-kotlin/build.gradle.kts | 15 +- unit-api-validation/build.gradle | 4 + 22 files changed, 329 insertions(+), 327 deletions(-) create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/unit-api.java-conventions.gradle.kts create mode 100644 buildSrc/src/main/kotlin/unit-api.javadoc.gradle.kts create mode 100644 buildSrc/src/main/kotlin/unit-api.publishing.gradle.kts create mode 100644 buildSrc/src/main/kotlin/unit-api.spring-conventions.gradle.kts create mode 100644 buildSrc/src/main/kotlin/unit-api.test.gradle.kts rename gradle/scripts/versionClass.gradle => buildSrc/src/main/kotlin/unit-api.version-class.gradle.kts (52%) delete mode 100644 gradle/scripts/javadoc.gradle delete mode 100644 gradle/scripts/publishing.gradle delete mode 100644 gradle/scripts/release.gradle delete mode 100644 gradle/scripts/test.gradle delete mode 100644 gradle/scripts/updateMkdocsConfig.gradle diff --git a/build.gradle b/build.gradle index 20df3aa7..2de7ae77 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,3 @@ -import static org.owasp.dependencycheck.reporting.ReportGenerator.Format.HTML -import static org.owasp.dependencycheck.reporting.ReportGenerator.Format.JSON - buildscript { repositories { mavenCentral() @@ -8,129 +5,42 @@ buildscript { } plugins { - id 'java-library' - id 'signing' - id 'maven-publish' - id 'org.springframework.boot' version '3.2.5' - id 'io.spring.dependency-management' version '1.1.4' - // Auto Update Versions id 'se.patrikerdes.use-latest-versions' version '0.2.18' id 'com.github.ben-manes.versions' version '0.51.0' - // Auto Release - id('net.researchgate.release') version '3.0.2' - - // Linting - id 'checkstyle' - id 'pmd' - id 'com.github.spotbugs' version '6.0.12' - id 'org.owasp.dependencycheck' version '9.1.0' + id 'maven-publish' + id "net.researchgate.release" version "3.0.2" } +evaluationDependsOnChildren() + allprojects { group = 'com.raynigon.unit-api' - // version = project.version - sourceCompatibility = JavaLanguageVersion.of(17) - repositories { - mavenCentral() - } } -subprojects { - apply plugin: 'org.springframework.boot' - apply plugin: 'io.spring.dependency-management' - apply plugin: 'java-library' - apply plugin: 'java' - apply plugin: 'groovy' - apply plugin: 'maven-publish' - apply plugin: 'jacoco' - apply plugin: 'signing' - apply plugin: 'net.researchgate.release' - apply plugin: 'checkstyle' - apply plugin: 'pmd' - apply plugin: 'com.github.spotbugs' - - sourceCompatibility = JavaLanguageVersion.of(17) - targetCompatibility = JavaLanguageVersion.of(17) - compileJava.options.encoding = 'UTF-8' - compileTestJava.options.encoding = 'UTF-8' - - - apply from: "$rootDir/gradle/scripts/versionClass.gradle" - apply from: "$rootDir/gradle/scripts/javadoc.gradle" - apply from: "$rootDir/gradle/scripts/test.gradle" - apply from: "$rootDir/gradle/scripts/publishing.gradle" - - bootJar { - enabled = false - } - - jar { - enabled = true - archiveClassifier.set("") - } +release { + preTagCommitMessage = "[Release] Version:" + tagCommitMessage = "[Release] Version:" + newVersionCommitMessage = "[Release] Update Version:" + tagTemplate = 'v${version}' + buildTasks = ['publish'] - sourceSets { - main { - java.srcDirs += "build/generated/sources/version/java" - } + git { + requireBranch.set("release") } +} - dependencies { - compileOnly 'org.projectlombok:lombok:1.18.32' - implementation 'javax.measure:unit-api:2.2' - implementation 'org.apache.commons:commons-lang3:3.14.0' - implementation 'org.slf4j:slf4j-api:2.0.13' - implementation 'org.jetbrains:annotations:24.1.0' - annotationProcessor 'org.projectlombok:lombok:1.18.32' - - testCompileOnly 'org.projectlombok:lombok:1.18.32' - testImplementation 'org.apache.groovy:groovy:4.0.21' - testImplementation 'org.spockframework:spock-core:2.4-M4-groovy-4.0' - testRuntimeOnly "net.bytebuddy:byte-buddy:1.14.13" - testAnnotationProcessor 'org.projectlombok:lombok:1.18.32' - - } - - - tasks.withType(Checkstyle) { - configFile = new File(rootProject.projectDir, "gradle/config/checkstyle.xml") - reports { - xml.required = true - html.required = true - } - } - - - pmd { - consoleOutput = true - ignoreFailures = true - toolVersion = "6.41.0" - rulesMinimumPriority = 3 - } - - spotbugs { - ignoreFailures = true - } - - dependencyCheck { - autoUpdate = false - skipTestGroups = true - suppressionFile = "${parent.projectDir}/gradle/config/dependency-check-suppression.xml" - formats = [JSON, HTML] - - analyzers.nodeEnabled = false - analyzers.nuspecEnabled = false - analyzers.nugetconfEnabled = false - analyzers.assemblyEnabled = false - analyzers.retirejs.enabled = false +def updateMkdocsConfig = tasks.register("updateMkdocsConfig") { + doFirst { + def cfg = project.file(project.file('mkdocs.yml')) + cfg.text = cfg.text.replaceAll(/(?m)latest_version:.*/, "latest_version: ${project.version}") } } -bootJar { - enabled = false +tasks.named("afterReleaseBuild").configure { + dependsOn( + subprojects.collect { it.tasks.named("publish") }, + updateMkdocsConfig + ) } - -apply from: "$rootDir/gradle/scripts/updateMkdocsConfig.gradle" -apply from: "$rootDir/gradle/scripts/release.gradle" diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..20a3bc41 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,18 @@ +plugins { + `kotlin-dsl` +} + +repositories { + mavenCentral() + maven { + url = uri("https://plugins.gradle.org/m2/") + } +} + +dependencies { + implementation("io.spring.gradle:dependency-management-plugin:1.1.6") + implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:6.0.1") + implementation("org.owasp:dependency-check-gradle:10.0.3") + + implementation("org.springframework.boot:spring-boot-gradle-plugin:3.2.5") +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/unit-api.java-conventions.gradle.kts b/buildSrc/src/main/kotlin/unit-api.java-conventions.gradle.kts new file mode 100644 index 00000000..27ed7bb9 --- /dev/null +++ b/buildSrc/src/main/kotlin/unit-api.java-conventions.gradle.kts @@ -0,0 +1,69 @@ +import org.gradle.kotlin.dsl.withType +import org.owasp.dependencycheck.reporting.ReportGenerator.Format + +plugins { + java + `java-library` + id("io.spring.dependency-management") + + checkstyle + pmd + id("com.github.spotbugs") + id("org.owasp.dependencycheck") + + id("unit-api.version-class") + id("unit-api.javadoc") + id("unit-api.test") + id("unit-api.publishing") +} + +repositories { + mavenCentral() +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} + +tasks.withType().configureEach { + configFile = File(rootProject.projectDir, "gradle/config/checkstyle.xml") + reports { + xml.required = true + html.required = true + } +} + +pmd { + isConsoleOutput = true + isIgnoreFailures = true + toolVersion = "6.41.0" + rulesMinimumPriority = 3 +} + +spotbugs { + ignoreFailures = true +} + +dependencyCheck { + autoUpdate = false + skipTestGroups = true + suppressionFile = "${parent!!.projectDir}/gradle/config/dependency-check-suppression.xml" + formats = listOf(Format.JSON.toString(), Format.HTML.toString()) + + analyzers.nodeEnabled = false + analyzers.nuspecEnabled = false + analyzers.nugetconfEnabled = false + analyzers.assemblyEnabled = false + analyzers.retirejs.enabled = false +} + +dependencies { + compileOnly("org.projectlombok:lombok:1.18.32") + api("javax.measure:unit-api:2.2") + api("org.apache.commons:commons-lang3:3.14.0") + api("org.slf4j:slf4j-api:2.0.13") + api("org.jetbrains:annotations:24.1.0") + annotationProcessor("org.projectlombok:lombok:1.18.32") +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/unit-api.javadoc.gradle.kts b/buildSrc/src/main/kotlin/unit-api.javadoc.gradle.kts new file mode 100644 index 00000000..da14851c --- /dev/null +++ b/buildSrc/src/main/kotlin/unit-api.javadoc.gradle.kts @@ -0,0 +1,15 @@ +plugins { + java +} + +tasks.javadoc { +// options.addBooleanOption('html5', true) +} + +tasks.register("globalJavadoc") { + dependsOn(tasks.javadoc) + group = "documentation" + val branchName = (System.getenv("GITHUB_REF") ?: "refs/heads/master").split("/")[2] + from(layout.buildDirectory.dir("docs/javadoc")) + into(parent!!.layout.buildDirectory.dir("javadoc/$branchName/${project.name}")) +} diff --git a/buildSrc/src/main/kotlin/unit-api.publishing.gradle.kts b/buildSrc/src/main/kotlin/unit-api.publishing.gradle.kts new file mode 100644 index 00000000..f97150bd --- /dev/null +++ b/buildSrc/src/main/kotlin/unit-api.publishing.gradle.kts @@ -0,0 +1,72 @@ +import groovy.util.Node +import groovy.util.NodeList + +plugins { + `java-library` + `maven-publish` + signing +} + +java { + withJavadocJar() + withSourcesJar() +} + +signing { + val signingKey = findProperty("signingKey").toString() + val signingPassword = findProperty("signingPassword").toString() + useInMemoryPgpKeys(signingKey, signingPassword) + sign(publishing.publications) +} + +publishing { + repositories { + maven { + name = "OSSRH" // OSS Repository Hosting + url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") + credentials { + username = System.getenv("OSSRH_USERNAME") ?: null + password = System.getenv("OSSRH_PASSWORD") ?: null + } + + } + } + publications { + create("maven") { + artifactId = project.name + from(components["java"]) + + pom { + name = project.name + description = "The ${project.name} is a part of the unit-api" + url = "https://unit-api.raynigon.com/" + issueManagement { + system = "GitHub" + url = "https://github.com/raynigon/unit-api/issues" + } + licenses { + license { + name = "Apache-2.0" + url = "https://opensource.org/licenses/Apache-2.0" + } + } + scm { + url = "https://github.com/raynigon/unit-api/" + connection = "scm:git:git://github.com/raynigon/unit-api.git" + developerConnection = "scm:git:ssh://git@github.com/raynigon/unit-api.git" + } + developers { + developer { + id = "raynigon" + name = "Simon Schneider" + email = "opensource@raynigon.de" + } + } + } + pom.withXml { + val rootNode = asNode() + rootNode.remove((rootNode.get("dependencyManagement") as NodeList)[0] as Node) + } + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/unit-api.spring-conventions.gradle.kts b/buildSrc/src/main/kotlin/unit-api.spring-conventions.gradle.kts new file mode 100644 index 00000000..61054501 --- /dev/null +++ b/buildSrc/src/main/kotlin/unit-api.spring-conventions.gradle.kts @@ -0,0 +1,26 @@ +import org.springframework.boot.gradle.tasks.bundling.BootJar + +plugins { + id("unit-api.java-conventions") + + id("org.springframework.boot") +} + +tasks.named("bootJar") { + enabled = false +} + +dependencies { + compileOnly("org.springframework.boot:spring-boot-starter") + compileOnly("org.springframework:spring-context-support") + compileOnly("org.springframework.boot:spring-boot-autoconfigure") + annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") + + testImplementation("org.springframework.boot:spring-boot-starter") + testImplementation("org.springframework:spring-context-support") + testImplementation("org.springframework.boot:spring-boot-autoconfigure") + testImplementation("org.springframework.boot:spring-boot-starter-test") { + exclude(group = "org.junit.vintage", module = "junit-vintage-engine") + } + testImplementation("org.spockframework:spock-spring:2.4-M4-groovy-4.0") +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/unit-api.test.gradle.kts b/buildSrc/src/main/kotlin/unit-api.test.gradle.kts new file mode 100644 index 00000000..217be0d5 --- /dev/null +++ b/buildSrc/src/main/kotlin/unit-api.test.gradle.kts @@ -0,0 +1,27 @@ +plugins { + java + groovy + jacoco +} + +tasks.test { + useJUnitPlatform() + finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run +} + +tasks.jacocoTestReport { + dependsOn(tasks.test) // tests are required to run before generating the report + reports { + xml.required = true + html.required = true + csv.required = false + } +} + +dependencies { + testCompileOnly("org.projectlombok:lombok:1.18.32") + testImplementation("org.apache.groovy:groovy:4.0.21") + testImplementation("org.spockframework:spock-core:2.4-M4-groovy-4.0") + testRuntimeOnly("net.bytebuddy:byte-buddy:1.14.13") + testAnnotationProcessor("org.projectlombok:lombok:1.18.32") +} \ No newline at end of file diff --git a/gradle/scripts/versionClass.gradle b/buildSrc/src/main/kotlin/unit-api.version-class.gradle.kts similarity index 52% rename from gradle/scripts/versionClass.gradle rename to buildSrc/src/main/kotlin/unit-api.version-class.gradle.kts index 09227c51..ed8bc07c 100644 --- a/gradle/scripts/versionClass.gradle +++ b/buildSrc/src/main/kotlin/unit-api.version-class.gradle.kts @@ -1,21 +1,28 @@ import java.time.OffsetDateTime import java.util.regex.Pattern -task generateVersionClass() { - mustRunAfter(clean) - group = 'build' - doFirst { - def targetDirectory = projectDir.toPath().resolve("build/generated/sources/version/java") +plugins { + java +} + +val generateVersionClass = tasks.register("generateVersionClass") { + val outputDir = layout.buildDirectory.dir("generated/sources/version/java/main") + outputs.dir(outputDir) + outputs.cacheIf { false } // Always regenerate for current time + mustRunAfter(tasks.named("clean")) + group = "build" + + doLast { // change package name - def packageName = project.group.replace("-", "_") + "." + project.name.replace("-", "_") - targetDirectory = targetDirectory.resolve(packageName.replace(".", "/")) - targetDirectory.toFile().mkdirs() - String version = project.version - Pattern versionPattern = Pattern.compile("^[0-9]+\\.[0-9]+\\.[0-9]+(?>-SNAPSHOT)?\$") + val packageName = project.group.toString().replace("-", "_") + "." + project.name.replace("-", "_") + val targetDirectory = outputDir.get().dir(packageName.replace(".", "/")).asFile + targetDirectory.mkdirs() + var version = project.version.toString() + val versionPattern = Pattern.compile("^[0-9]+\\.[0-9]+\\.[0-9]+(?>-SNAPSHOT)?\$") if (!versionPattern.matcher(version).find()) { version = "0.0.1-SNAPSHOT" } - new File(targetDirectory.toFile(), "BuildVersion.java").text = """package ${packageName}; + File(targetDirectory, "BuildVersion.java").writeText("""package ${packageName}; import java.time.OffsetDateTime; /** @@ -42,17 +49,17 @@ public class BuildVersion { /** * The major part for the version of this artifact as an integer */ - public static final int MAJOR_VERSION = ${version.split("\\.")[0]}; + public static final int MAJOR_VERSION = ${version.split(".")[0]}; /** * The minor part for the version of this artifact as an integer */ - public static final int MINOR_VERSION = ${version.split("\\.")[1]}; + public static final int MINOR_VERSION = ${version.split(".")[1]}; /** * The patch part for the version of this artifact as an integer */ - public static final int PATCH_VERSION = ${version.split("\\.")[2].split('-')[0]}; + public static final int PATCH_VERSION = ${version.split(".")[2].split('-')[0]}; /** * Indicates if this artifact is a snapshot version @@ -62,10 +69,20 @@ public class BuildVersion { /** * The date time when this artifact was created */ - public static final OffsetDateTime BUILD_DATE = OffsetDateTime.parse("${OffsetDateTime.now().toString()}"); + public static final OffsetDateTime BUILD_DATE = OffsetDateTime.parse("${OffsetDateTime.now()}"); +} +""") + } } -""" + +sourceSets { + main { + java { + srcDir(generateVersionClass) + } } } -tasks.getByName('compileJava').dependsOn(generateVersionClass) \ No newline at end of file +tasks.named("compileJava") { + dependsOn(generateVersionClass) +} diff --git a/gradle/scripts/javadoc.gradle b/gradle/scripts/javadoc.gradle deleted file mode 100644 index f0d7d18e..00000000 --- a/gradle/scripts/javadoc.gradle +++ /dev/null @@ -1,25 +0,0 @@ -import org.gradle.internal.jvm.Jvm - -javadoc { - if (!Jvm.current().javaVersion.isJava8()) { - options.addBooleanOption('html5', true) - } -} - -task sourcesJar(type: Jar) { - from sourceSets.main.allJava - archiveClassifier.set('sources') -} - -task javadocJar(type: Jar) { - from javadoc - archiveClassifier.set('javadoc') -} - -task globalJavadoc(type: Copy) { - dependsOn javadoc - group = 'documentation' - String branchName = (System.getenv("GITHUB_REF") ?: "refs/heads/master").split("/")[2] - from(buildDir.toString() + "/docs/javadoc/") - into(parent.buildDir.toString() + "/javadoc/$branchName/" + project.name + "/") -} diff --git a/gradle/scripts/publishing.gradle b/gradle/scripts/publishing.gradle deleted file mode 100644 index 917d586b..00000000 --- a/gradle/scripts/publishing.gradle +++ /dev/null @@ -1,79 +0,0 @@ - -signing { - required { - findProperty("signingKey") != null - } - String signingKey = findProperty("signingKey") - String signingPassword = findProperty("signingPassword") - useInMemoryPgpKeys(signingKey, signingPassword) - sign publishing.publications -} - -publishing { - repositories { - maven { - name = "OSSRH" // OSS Repository Hosting - url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") - credentials { - username = System.getenv("OSSRH_USERNAME") ?: null - password = System.getenv("OSSRH_PASSWORD") ?: null - } - - } - } - publications { - basic(MavenPublication) { - artifactId = project.name - - artifact project.tasks.jar - artifact sourcesJar - artifact javadocJar - - pom.withXml { - def rootNode = asNode() - rootNode.children().last() + { - resolveStrategy = Closure.DELEGATE_FIRST - - name project.name - description "The ${project.name} is a part of the unit-api" - url 'https://unit-api.raynigon.com/' - issueManagement { - system 'GitHub' - url 'https://github.com/raynigon/unit-api/issues' - } - licenses { - license { - name 'Apache-2.0' - url 'https://opensource.org/licenses/Apache-2.0' - } - } - scm { - url 'https://github.com/raynigon/unit-api/' - connection 'scm:git:git://github.com/raynigon/unit-api.git' - developerConnection 'scm:git:ssh://git@github.com/raynigon/unit-api.git' - } - developers { - developer { - id 'raynigon' - name 'Simon Schneider' - email 'opensource@raynigon.de' - } - } - } - - rootNode.remove((Node) ((Node) rootNode).get("dependencyManagement").get(0)) - def dependenciesNode = rootNode.appendNode('dependencies') - - def addDependency = { dependency, scope -> - dependenciesNode.appendNode('dependency').with { - appendNode('groupId', dependency.group) - appendNode('artifactId', dependency.name) - appendNode('version', dependency.version) - appendNode('scope', scope) - } - } - project.configurations.implementation.dependencies.each { addDependency(it, 'compile') } - } - } - } -} \ No newline at end of file diff --git a/gradle/scripts/release.gradle b/gradle/scripts/release.gradle deleted file mode 100644 index 72e610da..00000000 --- a/gradle/scripts/release.gradle +++ /dev/null @@ -1,17 +0,0 @@ -release { - - preTagCommitMessage = "[Release] Version:" - tagCommitMessage = "[Release] Version:" - newVersionCommitMessage = "[Release] Update Version:" - tagTemplate = 'v${version}' - buildTasks = ['publish'] - - git { - requireBranch.set("release") - } -} - -tasks.getByName("afterReleaseBuild").dependsOn( - subprojects.collect {it.tasks.getByName("publish")}, - tasks.getByName("updateMkdocsConfig") -) diff --git a/gradle/scripts/test.gradle b/gradle/scripts/test.gradle deleted file mode 100644 index 06c02f12..00000000 --- a/gradle/scripts/test.gradle +++ /dev/null @@ -1,16 +0,0 @@ -test { - useJUnitPlatform() -} - -tasks.test { - finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run -} - -tasks.jacocoTestReport { - dependsOn(tasks.test) // tests are required to run before generating the report - reports { - xml.enabled = true - html.enabled = true - csv.enabled = false - } -} diff --git a/gradle/scripts/updateMkdocsConfig.gradle b/gradle/scripts/updateMkdocsConfig.gradle deleted file mode 100644 index ec280de2..00000000 --- a/gradle/scripts/updateMkdocsConfig.gradle +++ /dev/null @@ -1,7 +0,0 @@ - -task updateMkdocsConfig() { - doFirst { - def cfg = project.file(project.file('mkdocs.yml')) - cfg.text = cfg.text.replaceAll(/(?m)latest_version:.*/, "latest_version: ${project.version}") - } -} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 070cb702..19cfad96 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-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/spring-boot-core-starter/build.gradle b/spring-boot-core-starter/build.gradle index 92b3ee8a..c87238f6 100644 --- a/spring-boot-core-starter/build.gradle +++ b/spring-boot-core-starter/build.gradle @@ -1,15 +1,7 @@ -dependencies { - compileOnly 'org.springframework.boot:spring-boot-starter' - compileOnly 'org.springframework:spring-context-support' - compileOnly 'org.springframework.boot:spring-boot-autoconfigure' - annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' - implementation project(":unit-api-core") +plugins { + id 'unit-api.spring-conventions' +} - testImplementation 'org.springframework.boot:spring-boot-starter' - testImplementation 'org.springframework:spring-context-support' - testImplementation 'org.springframework.boot:spring-boot-autoconfigure' - testImplementation('org.springframework.boot:spring-boot-starter-test') { - exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' - } - testImplementation 'org.spockframework:spock-spring:2.4-M4-groovy-4.0' +dependencies { + api project(":unit-api-core") } \ No newline at end of file diff --git a/spring-boot-jackson-starter/build.gradle b/spring-boot-jackson-starter/build.gradle index b4ec4e36..b51af595 100644 --- a/spring-boot-jackson-starter/build.gradle +++ b/spring-boot-jackson-starter/build.gradle @@ -1,15 +1,12 @@ +plugins { + id 'unit-api.spring-conventions' +} + dependencies { - compileOnly 'org.springframework.boot:spring-boot-starter' compileOnly 'org.springframework.boot:spring-boot-starter-web' - annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' - implementation project(':unit-api-jackson') - implementation project(":unit-api-core") - implementation project(":spring-boot-core-starter") + api project(':unit-api-jackson') + api project(":unit-api-core") + api project(":spring-boot-core-starter") - testImplementation 'org.springframework.boot:spring-boot-starter' testImplementation 'org.springframework.boot:spring-boot-starter-web' - testImplementation('org.springframework.boot:spring-boot-starter-test') { - exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' - } - testImplementation 'org.spockframework:spock-spring:2.4-M4-groovy-4.0' } \ No newline at end of file diff --git a/spring-boot-jpa-starter/build.gradle b/spring-boot-jpa-starter/build.gradle index 09b0adcf..87b15d1c 100644 --- a/spring-boot-jpa-starter/build.gradle +++ b/spring-boot-jpa-starter/build.gradle @@ -1,15 +1,13 @@ +plugins { + id 'unit-api.spring-conventions' +} + dependencies { - compileOnly 'org.springframework.boot:spring-boot-starter' compileOnly 'org.springframework.boot:spring-boot-starter-data-jpa' - implementation project(":unit-api-core") - implementation project(":spring-boot-core-starter") + api project(":unit-api-core") + api project(":spring-boot-core-starter") - testImplementation 'org.springframework.boot:spring-boot-starter' testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa' - testImplementation('org.springframework.boot:spring-boot-starter-test') { - exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' - } testImplementation("org.postgresql:postgresql:42.7.3") testImplementation("org.testcontainers:postgresql:1.19.7") - testImplementation 'org.spockframework:spock-spring:2.4-M4-groovy-4.0' } diff --git a/spring-boot-springdoc-starter/build.gradle b/spring-boot-springdoc-starter/build.gradle index fcc1b12e..5a7f93de 100644 --- a/spring-boot-springdoc-starter/build.gradle +++ b/spring-boot-springdoc-starter/build.gradle @@ -1,15 +1,13 @@ +plugins { + id 'unit-api.spring-conventions' +} + dependencies { - compileOnly 'org.springframework.boot:spring-boot-starter' compileOnly 'org.springdoc:springdoc-openapi-webmvc-core:1.8.0' - implementation project(":unit-api-core") - implementation project(":unit-api-jackson") - implementation project(":unit-api-validation") - implementation project(":spring-boot-core-starter") + api project(":unit-api-core") + api project(":unit-api-jackson") + api project(":unit-api-validation") + api project(":spring-boot-core-starter") testImplementation 'org.springdoc:springdoc-openapi-webmvc-core:1.8.0' - testImplementation 'org.springframework.boot:spring-boot-starter' - testImplementation('org.springframework.boot:spring-boot-starter-test') { - exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' - } - testImplementation 'org.spockframework:spock-spring:2.4-M4-groovy-4.0' } \ No newline at end of file diff --git a/unit-api-core/build.gradle b/unit-api-core/build.gradle index f5bdfc5b..a46cc9c0 100644 --- a/unit-api-core/build.gradle +++ b/unit-api-core/build.gradle @@ -1,3 +1,7 @@ +plugins { + id 'unit-api.java-conventions' +} + dependencies { - implementation("org.reflections:reflections:0.10.2") + api("org.reflections:reflections:0.10.2") } \ No newline at end of file diff --git a/unit-api-jackson/build.gradle b/unit-api-jackson/build.gradle index 61f38d63..04781bfb 100644 --- a/unit-api-jackson/build.gradle +++ b/unit-api-jackson/build.gradle @@ -1,6 +1,10 @@ +plugins { + id 'unit-api.java-conventions' +} + dependencies { compileOnly 'com.fasterxml.jackson.core:jackson-databind:2.17.0' - implementation project(":unit-api-core") + api project(":unit-api-core") testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.17.0' } \ No newline at end of file diff --git a/unit-api-kotlin/build.gradle.kts b/unit-api-kotlin/build.gradle.kts index 8821935e..ae24b926 100644 --- a/unit-api-kotlin/build.gradle.kts +++ b/unit-api-kotlin/build.gradle.kts @@ -1,10 +1,11 @@ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") version "1.9.23" id("org.jlleitschuh.gradle.ktlint") version "12.1.0" + id("unit-api.java-conventions") + // Auto Update Versions id("se.patrikerdes.use-latest-versions") id("com.github.ben-manes.versions") @@ -16,14 +17,8 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") } -tasks.test { - useJUnitPlatform() -} - -tasks.withType().all { - kotlinOptions { - jvmTarget = "17" - } +kotlin { + jvmToolchain(17) } /** @@ -35,7 +30,7 @@ tasks.withType().all { * @return true if the version is stable, false if not * */ fun isNonStable(version: String): Boolean { - val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) } + val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase().contains(it) } val regex = "^[0-9,.v-]+(-r)?$".toRegex() val isStable = stableKeyword || regex.matches(version) return isStable.not() diff --git a/unit-api-validation/build.gradle b/unit-api-validation/build.gradle index cb5e4ec3..7b198442 100644 --- a/unit-api-validation/build.gradle +++ b/unit-api-validation/build.gradle @@ -1,3 +1,7 @@ +plugins { + id 'unit-api.java-conventions' +} + dependencies { implementation("jakarta.validation:jakarta.validation-api:3.0.2") implementation project(":unit-api-core")