From 584de37fcbab64433225581d1eb07822ee43d46c Mon Sep 17 00:00:00 2001 From: Taeik Lim Date: Sat, 27 Apr 2024 13:18:43 +0900 Subject: [PATCH] Use convention in gradle project structure Signed-off-by: Taeik Lim --- build.gradle | 160 ------------------ buildSrc/build.gradle | 16 ++ .../spring.jdbc.plus.java-conventions.gradle | 36 ++++ ...jdbc.plus.maven-publish-conventions.gradle | 87 ++++++++++ ...ng.jdbc.plus.spring-bom-conventions.gradle | 13 ++ gradle.properties | 1 - .../plus-repository-guide/build.gradle | 5 + .../plus-sql-java-groovy-guide/build.gradle | 7 +- .../plus-sql-java-kotlin-guide/build.gradle | 19 +-- .../plus-sql-kotlin-guide/build.gradle.kts | 27 +-- settings.gradle | 9 + .../build.gradle | 6 + .../build.gradle | 6 + .../build.gradle | 6 + spring-data-jdbc-plus-repository/build.gradle | 6 + spring-data-jdbc-plus-sql/build.gradle | 6 + spring-data-jdbc-plus-support/build.gradle | 6 + spring-data-plus-sql-gen/build.gradle | 6 + spring-jdbc-plus-commons/build.gradle | 6 + spring-jdbc-plus-support/build.gradle | 6 + 20 files changed, 233 insertions(+), 201 deletions(-) delete mode 100644 build.gradle create mode 100644 buildSrc/build.gradle create mode 100644 buildSrc/src/main/groovy/spring.jdbc.plus.java-conventions.gradle create mode 100644 buildSrc/src/main/groovy/spring.jdbc.plus.maven-publish-conventions.gradle create mode 100644 buildSrc/src/main/groovy/spring.jdbc.plus.spring-bom-conventions.gradle diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 67952759..00000000 --- a/build.gradle +++ /dev/null @@ -1,160 +0,0 @@ -import org.springframework.boot.gradle.plugin.SpringBootPlugin - -buildscript { - repositories { - mavenCentral() - mavenLocal() - maven { - url "https://repo.spring.io/milestone/" - } - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") - } -} - -allprojects { - group = "com.navercorp.spring" - version = "3.3.0-SNAPSHOT" -} - -subprojects { - apply plugin: "java" - apply plugin: "java-library" - apply plugin: "idea" - apply plugin: "checkstyle" - apply plugin: "io.spring.dependency-management" - apply plugin: "maven-publish" - apply plugin: "signing" - - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - - repositories { - mavenCentral() - maven { - url "https://repo.spring.io/milestone/" - } - } - - dependencies { - compileOnly("com.google.code.findbugs:jsr305:3.0.2") - testCompileOnly("com.google.code.findbugs:jsr305:3.0.2") - } - - dependencyManagement { - imports { - mavenBom("${SpringBootPlugin.BOM_COORDINATES}") { - bomProperties([ - 'spring-data-bom.version': "${springDataBomVersion}" - ]) - } - } - } - - checkstyle { - configFile = file("${project.rootDir}/rule/naver-checkstyle-rules.xml") - configProperties = ["suppressionFile": "${project.rootDir}/tool/naver-checkstyle-suppressions.xml"] - toolVersion = "9.1" - ignoreFailures = true // TODO: return to false - maxErrors = 0 - maxWarnings = 0 - } - - test { - useJUnitPlatform() - } - - tasks.withType(Javadoc).all { enabled = false } - tasks.withType(JavaCompile).configureEach { - options.compilerArgs << '-parameters' - } - - java { - withJavadocJar() - withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - - publishing { - publications { - mavenJava(MavenPublication) { - from components.java - - repositories { - maven { - def ossrhUsername = project.hasProperty("ossrhUsername") ? ossrhUsername : "" - def ossrhPassword = project.hasProperty("ossrhPassword") ? ossrhPassword : "" - - credentials { - username ossrhUsername - password ossrhPassword - } - - def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" - def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/" - url = version.endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl - } - } - - versionMapping { - usage('java-api') { - fromResolutionOf('runtimeClasspath') - } - usage('java-runtime') { - fromResolutionResult() - } - } - - pom { - name = "Spring JDBC Plus" - description = "Spring JDBC Plus" - url = "http://github.com/naver/spring-jdbc-plus" - licenses { - license { - name = "The Apache License, Version 2.0" - url = "http://www.apache.org/licenses/LICENSE-2.0.txt" - } - } - developers { - developer { - id = "mhyeon-lee" - name = "Myeonghyeon Lee" - email = "mheyon.lee@gmail.com" - } - developer { - id = "yd-2" - name = "Youngdae Lee" - email = "yd.2@navercorp.com" - } - developer { - id = "chanhyeong" - name = "Chanhyeong Cho" - email = "chu7825@gmail.com" - } - developer { - id = "wool0826" - name = "Chanwool Jo" - email = "chanwool94@gmail.com" - } - } - scm { - connection = "scm:git:git://github.com/naver/spring-jdbc-plus.git" - developerConnection = "scm:git:git://github.com/naver/spring-jdbc-plus.git" - url = "https://github.com/naver/spring-jdbc-plus" - } - } - } - } - } - - - signing { - sign publishing.publications.mavenJava - } - - tasks.withType(Sign) { - onlyIf { !version.endsWith("SNAPSHOT") } - } -} diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 00000000..1b83ba93 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,16 @@ +plugins { + id "groovy-gradle-plugin" +} + +repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() // give access to gradle community plugins + maven { + url "https://repo.spring.io/milestone/" + } +} + +dependencies { + implementation "io.spring.gradle:dependency-management-plugin:1.1.5" +} diff --git a/buildSrc/src/main/groovy/spring.jdbc.plus.java-conventions.gradle b/buildSrc/src/main/groovy/spring.jdbc.plus.java-conventions.gradle new file mode 100644 index 00000000..e96c3d5f --- /dev/null +++ b/buildSrc/src/main/groovy/spring.jdbc.plus.java-conventions.gradle @@ -0,0 +1,36 @@ +plugins { + id "java-library" + id "checkstyle" + id "idea" +} + +java { + withJavadocJar() + withSourcesJar() + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +tasks.withType(Javadoc).configureEach { enabled = false } + +tasks.withType(JavaCompile).configureEach { + options.compilerArgs << '-parameters' +} + +test { + useJUnitPlatform() +} + +checkstyle { + configFile = file("${project.rootDir}/rule/naver-checkstyle-rules.xml") + configProperties = ["suppressionFile": "${project.rootDir}/tool/naver-checkstyle-suppressions.xml"] + toolVersion = "9.1" + ignoreFailures = true // TODO: return to false + maxErrors = 0 + maxWarnings = 0 +} + +dependencies { + compileOnly("com.google.code.findbugs:jsr305:3.0.2") + testCompileOnly("com.google.code.findbugs:jsr305:3.0.2") +} diff --git a/buildSrc/src/main/groovy/spring.jdbc.plus.maven-publish-conventions.gradle b/buildSrc/src/main/groovy/spring.jdbc.plus.maven-publish-conventions.gradle new file mode 100644 index 00000000..c93166f4 --- /dev/null +++ b/buildSrc/src/main/groovy/spring.jdbc.plus.maven-publish-conventions.gradle @@ -0,0 +1,87 @@ +plugins { + id "maven-publish" + id "signing" +} + +group = "com.navercorp.spring" +version = "3.3.0-SNAPSHOT" + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + + repositories { + maven { + def ossrhUsername = project.hasProperty("ossrhUsername") ? ossrhUsername : "" + def ossrhPassword = project.hasProperty("ossrhPassword") ? ossrhPassword : "" + + credentials { + username ossrhUsername + password ossrhPassword + } + + def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/" + url = version.endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl + } + } + + versionMapping { + usage('java-api') { + fromResolutionOf('runtimeClasspath') + } + usage('java-runtime') { + fromResolutionResult() + } + } + + pom { + name = "Spring JDBC Plus" + description = "Spring JDBC Plus" + url = "http://github.com/naver/spring-jdbc-plus" + licenses { + license { + name = "The Apache License, Version 2.0" + url = "http://www.apache.org/licenses/LICENSE-2.0.txt" + } + } + developers { + developer { + id = "mhyeon-lee" + name = "Myeonghyeon Lee" + email = "mheyon.lee@gmail.com" + } + developer { + id = "yd-2" + name = "Youngdae Lee" + email = "yd.2@navercorp.com" + } + developer { + id = "chanhyeong" + name = "Chanhyeong Cho" + email = "chu7825@gmail.com" + } + developer { + id = "wool0826" + name = "Chanwool Jo" + email = "chanwool94@gmail.com" + } + } + scm { + connection = "scm:git:git://github.com/naver/spring-jdbc-plus.git" + developerConnection = "scm:git:git://github.com/naver/spring-jdbc-plus.git" + url = "https://github.com/naver/spring-jdbc-plus" + } + } + } + } +} + +signing { + sign publishing.publications.mavenJava +} + +tasks.withType(Sign) { + onlyIf { !version.endsWith("SNAPSHOT") } +} diff --git a/buildSrc/src/main/groovy/spring.jdbc.plus.spring-bom-conventions.gradle b/buildSrc/src/main/groovy/spring.jdbc.plus.spring-bom-conventions.gradle new file mode 100644 index 00000000..a6b28b72 --- /dev/null +++ b/buildSrc/src/main/groovy/spring.jdbc.plus.spring-bom-conventions.gradle @@ -0,0 +1,13 @@ +plugins { + id "io.spring.dependency-management" +} + +dependencyManagement { + imports { + mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") { + bomProperties([ + "spring-data-bom.version": "${springDataBomVersion}" + ]) + } + } +} diff --git a/gradle.properties b/gradle.properties index a5932b3a..dfa1a264 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,2 @@ springBootVersion=3.3.0-RC1 springDataBomVersion=2024.0.0-RC1 -kotlinVersion=1.9.20 diff --git a/guide-projects/plus-repository-guide/build.gradle b/guide-projects/plus-repository-guide/build.gradle index 00988e09..964af24a 100644 --- a/guide-projects/plus-repository-guide/build.gradle +++ b/guide-projects/plus-repository-guide/build.gradle @@ -1,3 +1,8 @@ +plugins { + id "spring.jdbc.plus.java-conventions" + id "spring.jdbc.plus.spring-bom-conventions" +} + dependencies { implementation project(':spring-boot-starter-data-jdbc-plus-repository') diff --git a/guide-projects/plus-sql-java-groovy-guide/build.gradle b/guide-projects/plus-sql-java-groovy-guide/build.gradle index 3b599fc0..27c5b678 100644 --- a/guide-projects/plus-sql-java-groovy-guide/build.gradle +++ b/guide-projects/plus-sql-java-groovy-guide/build.gradle @@ -1,12 +1,9 @@ plugins { - id "java" + id "spring.jdbc.plus.java-conventions" + id "spring.jdbc.plus.spring-bom-conventions" id "groovy" } -repositories { - mavenCentral() -} - compileGroovy { options.encoding = "UTF-8" groovyOptions.encoding = "UTF-8" diff --git a/guide-projects/plus-sql-java-kotlin-guide/build.gradle b/guide-projects/plus-sql-java-kotlin-guide/build.gradle index cfcd22cb..e1fe3d8b 100644 --- a/guide-projects/plus-sql-java-kotlin-guide/build.gradle +++ b/guide-projects/plus-sql-java-kotlin-guide/build.gradle @@ -1,17 +1,7 @@ -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") - } -} - -apply plugin: "java" -apply plugin: "kotlin" - -repositories { - mavenCentral() +plugins { + id "spring.jdbc.plus.java-conventions" + id "spring.jdbc.plus.spring-bom-conventions" + id "org.jetbrains.kotlin.jvm" version "1.9.20" } compileKotlin { @@ -21,6 +11,7 @@ compileKotlin { jvmTarget = "17" } } + compileTestKotlin { kotlinOptions { javaParameters = true diff --git a/guide-projects/plus-sql-kotlin-guide/build.gradle.kts b/guide-projects/plus-sql-kotlin-guide/build.gradle.kts index cfb773e7..c3ec6452 100644 --- a/guide-projects/plus-sql-kotlin-guide/build.gradle.kts +++ b/guide-projects/plus-sql-kotlin-guide/build.gradle.kts @@ -1,28 +1,18 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -buildscript { - repositories { - maven(url = "https://plugins.gradle.org/m2/") - } - dependencies { - classpath("org.jlleitschuh.gradle:ktlint-gradle:10.2.0") - } -} - plugins { - val kotlinVersion = "1.9.20" - + id("spring.jdbc.plus.spring-bom-conventions") id("org.jlleitschuh.gradle.ktlint") version "10.2.0" - kotlin("jvm") version kotlinVersion - kotlin("plugin.spring") version kotlinVersion + kotlin("jvm") version "1.9.20" + kotlin("plugin.spring") version "1.9.20" } -repositories { - mavenCentral() +tasks.withType { + kotlinOptions.jvmTarget = "17" + kotlinOptions.javaParameters = true } dependencies { - implementation("org.springframework.boot:spring-boot-starter-web") implementation(project(":spring-boot-starter-data-jdbc-plus-sql")) implementation("org.springframework.boot:spring-boot-starter-actuator") @@ -36,8 +26,3 @@ dependencies { testImplementation("org.springframework.boot:spring-boot-starter-test") } - -tasks.withType { - kotlinOptions.jvmTarget = "17" - kotlinOptions.javaParameters = true -} diff --git a/settings.gradle b/settings.gradle index fe663b3b..2e79688b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,12 @@ +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { + url "https://repo.spring.io/milestone/" + } + } +} + rootProject.name = "spring-jdbc-plus" include "spring-jdbc-plus-commons" diff --git a/spring-boot-autoconfigure-data-jdbc-plus/build.gradle b/spring-boot-autoconfigure-data-jdbc-plus/build.gradle index 773f36e9..aa1db4b0 100644 --- a/spring-boot-autoconfigure-data-jdbc-plus/build.gradle +++ b/spring-boot-autoconfigure-data-jdbc-plus/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "spring.jdbc.plus.java-conventions" + id "spring.jdbc.plus.spring-bom-conventions" + id "spring.jdbc.plus.maven-publish-conventions" +} + compileJava.dependsOn(processResources) dependencies { diff --git a/spring-boot-starter-data-jdbc-plus-repository/build.gradle b/spring-boot-starter-data-jdbc-plus-repository/build.gradle index 0830163d..08a0e416 100644 --- a/spring-boot-starter-data-jdbc-plus-repository/build.gradle +++ b/spring-boot-starter-data-jdbc-plus-repository/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "spring.jdbc.plus.java-conventions" + id "spring.jdbc.plus.spring-bom-conventions" + id "spring.jdbc.plus.maven-publish-conventions" +} + dependencies { api(project(":spring-data-jdbc-plus-repository")) api(project(":spring-boot-autoconfigure-data-jdbc-plus")) diff --git a/spring-boot-starter-data-jdbc-plus-sql/build.gradle b/spring-boot-starter-data-jdbc-plus-sql/build.gradle index 0b6a5f27..45b31ba2 100644 --- a/spring-boot-starter-data-jdbc-plus-sql/build.gradle +++ b/spring-boot-starter-data-jdbc-plus-sql/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "spring.jdbc.plus.java-conventions" + id "spring.jdbc.plus.spring-bom-conventions" + id "spring.jdbc.plus.maven-publish-conventions" +} + dependencies { api(project(":spring-boot-autoconfigure-data-jdbc-plus")) api(project(":spring-data-jdbc-plus-sql")) diff --git a/spring-data-jdbc-plus-repository/build.gradle b/spring-data-jdbc-plus-repository/build.gradle index 814a29a6..68f85913 100644 --- a/spring-data-jdbc-plus-repository/build.gradle +++ b/spring-data-jdbc-plus-repository/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "spring.jdbc.plus.java-conventions" + id "spring.jdbc.plus.spring-bom-conventions" + id "spring.jdbc.plus.maven-publish-conventions" +} + compileJava.dependsOn(processResources) dependencies { diff --git a/spring-data-jdbc-plus-sql/build.gradle b/spring-data-jdbc-plus-sql/build.gradle index 21b7d5d1..7ea4485d 100644 --- a/spring-data-jdbc-plus-sql/build.gradle +++ b/spring-data-jdbc-plus-sql/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "spring.jdbc.plus.java-conventions" + id "spring.jdbc.plus.spring-bom-conventions" + id "spring.jdbc.plus.maven-publish-conventions" +} + compileJava.dependsOn(processResources) dependencies { diff --git a/spring-data-jdbc-plus-support/build.gradle b/spring-data-jdbc-plus-support/build.gradle index 2b14b143..f582f61e 100644 --- a/spring-data-jdbc-plus-support/build.gradle +++ b/spring-data-jdbc-plus-support/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "spring.jdbc.plus.java-conventions" + id "spring.jdbc.plus.spring-bom-conventions" + id "spring.jdbc.plus.maven-publish-conventions" +} + compileJava.dependsOn(processResources) dependencies { diff --git a/spring-data-plus-sql-gen/build.gradle b/spring-data-plus-sql-gen/build.gradle index e6c878fc..ae334bb9 100644 --- a/spring-data-plus-sql-gen/build.gradle +++ b/spring-data-plus-sql-gen/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "spring.jdbc.plus.java-conventions" + id "spring.jdbc.plus.spring-bom-conventions" + id "spring.jdbc.plus.maven-publish-conventions" +} + dependencies { api(project(":spring-data-jdbc-plus-sql")) diff --git a/spring-jdbc-plus-commons/build.gradle b/spring-jdbc-plus-commons/build.gradle index 9e2969af..5980f60e 100644 --- a/spring-jdbc-plus-commons/build.gradle +++ b/spring-jdbc-plus-commons/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "spring.jdbc.plus.java-conventions" + id "spring.jdbc.plus.spring-bom-conventions" + id "spring.jdbc.plus.maven-publish-conventions" +} + compileJava.dependsOn(processResources) dependencies { diff --git a/spring-jdbc-plus-support/build.gradle b/spring-jdbc-plus-support/build.gradle index f3a3ffd8..71ca3fa4 100644 --- a/spring-jdbc-plus-support/build.gradle +++ b/spring-jdbc-plus-support/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "spring.jdbc.plus.java-conventions" + id "spring.jdbc.plus.spring-bom-conventions" + id "spring.jdbc.plus.maven-publish-conventions" +} + dependencies { api("org.springframework:spring-jdbc")