From ddf313d0354a0dd879dec56deb9df760de67e0a6 Mon Sep 17 00:00:00 2001 From: Luo Date: Sun, 1 Sep 2024 18:57:44 +0800 Subject: [PATCH] replace lib-versions.properties with gradle default libs.versions.toml (#101) --- buildSrc/build.gradle | 2 +- .../groovy/local-s3.java-conventions.gradle | 26 ++++------- .../src/main/groovy/local-s3.publish.gradle | 4 +- .../src/main/resources/version.properties | 22 --------- gradle/libs.versions.toml | 45 +++++++++++++++++++ local-s3-core/build.gradle | 12 ++--- local-s3-datatypes/build.gradle | 16 +++---- local-s3-docker/build.gradle | 28 ++++++------ .../docker/ReachabilityMetadataGenerator.java | 4 +- local-s3-interationtest/build.gradle | 11 ++--- local-s3-jupiter/build.gradle | 18 ++++---- local-s3-rest/build.gradle | 23 +++++----- local-s3-testcontainers/build.gradle | 6 +-- 13 files changed, 113 insertions(+), 104 deletions(-) delete mode 100644 buildSrc/src/main/resources/version.properties create mode 100644 gradle/libs.versions.toml diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 185b064..9b38c21 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -11,4 +11,4 @@ dependencies { implementation 'com.robothy:cn-repo:1.8' implementation 'io.franzbecker:gradle-lombok:5.0.0' //testImplementation 'org.spockframework:spock-core:1.3-groovy-2.5' -} \ No newline at end of file +} diff --git a/buildSrc/src/main/groovy/local-s3.java-conventions.gradle b/buildSrc/src/main/groovy/local-s3.java-conventions.gradle index 943e74c..5608cbf 100644 --- a/buildSrc/src/main/groovy/local-s3.java-conventions.gradle +++ b/buildSrc/src/main/groovy/local-s3.java-conventions.gradle @@ -7,7 +7,6 @@ plugins { repositories { mavenLocal() mavenCentral() - jcenter() // maven { url 'https://maven.aliyun.com/repository/google/' } @@ -20,22 +19,15 @@ repositories { project.group = 'io.github.robothy' -// Load version -ext { - libVersion = new Properties() - def versionFile = new File("${project.rootProject.rootDir}/buildSrc/src/main/resources/version.properties") - ext.libVersion.load(versionFile.newInputStream()) -} - dependencies { - implementation "org.slf4j:slf4j-api:${libVersion['org.slf4j.slf4j-api']}" - compileOnly "org.projectlombok:lombok:${libVersion['org.projectlombok.lombok']}" - annotationProcessor "org.projectlombok:lombok:${libVersion['org.projectlombok.lombok']}" - testCompileOnly "org.projectlombok:lombok:${libVersion['org.projectlombok.lombok']}" - testAnnotationProcessor "org.projectlombok:lombok:${libVersion['org.projectlombok.lombok']}" - testImplementation "org.mockito:mockito-inline:${libVersion['org.mockito.mockito-inline']}" - testImplementation "org.junit.jupiter:junit-jupiter:${libVersion['org.junit.jupiter.junit-jupiter']}" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${libVersion['org.junit.jupiter.junit-jupiter-engine']}" + implementation(libs.slf4jApi) + compileOnly(libs.lombok) + annotationProcessor(libs.lombok) + testCompileOnly(libs.lombok) + testAnnotationProcessor(libs.lombok) + testImplementation(libs.mockitoInline) + testImplementation(libs.junit5JupiterEngine) + testImplementation(libs.junit5) } test { @@ -67,4 +59,4 @@ java { // } sourceCompatibility(8) targetCompatibility(8) -} \ No newline at end of file +} diff --git a/buildSrc/src/main/groovy/local-s3.publish.gradle b/buildSrc/src/main/groovy/local-s3.publish.gradle index 1aa5538..9bc58b2 100644 --- a/buildSrc/src/main/groovy/local-s3.publish.gradle +++ b/buildSrc/src/main/groovy/local-s3.publish.gradle @@ -79,7 +79,7 @@ publishing { task delombok(type: DelombokTask, dependsOn: compileJava) { - ext.outputDir = file("$buildDir/delombok") + ext.outputDir = project.layout.buildDirectory.dir("delombok").get() outputs.dir(outputDir) sourceSets.main.java.srcDirs.each { inputs.dir(it) @@ -103,4 +103,4 @@ signing { def signingPassword = findProperty("signing.password") useInMemoryPgpKeys(signingKey, signingPassword) sign publishing.publications.maven -} \ No newline at end of file +} diff --git a/buildSrc/src/main/resources/version.properties b/buildSrc/src/main/resources/version.properties deleted file mode 100644 index 1304974..0000000 --- a/buildSrc/src/main/resources/version.properties +++ /dev/null @@ -1,22 +0,0 @@ -ch.qos.logback.logback-classic=1.4.12 -ch.qos.logback.logback-core=1.4.12 -com.amazonaws.aws-java-sdk=1.12.757 -software.amazon.awssdk.s3=2.26.16 -com.fasterxml.jackson.core.jackson-databind=2.15.2 -com.fasterxml.jackson.dataformat.jackson-dataformat-xml=2.15.2 -com.fasterxml.jackson.datatype.jackson-datatype-jdk8=2.15.2 -com.fasterxml.jackson.datatype.jackson-datatype-jsr310=2.15.2 -com.robothy.netty-http-router=1.15 -commons-codec.commons-codec=1.15 -io.netty.netty-all=4.1.108.Final -org.apache.commons.commons-collections4=4.4 -commons-io.commons-io=2.13.0 -org.apache.commons.commons-lang3=3.12.0 -org.junit.jupiter.junit-jupiter-engine=5.8.1 -org.junit.jupiter.junit-jupiter=5.8.1 -org.mockito.mockito-inline=4.2.0 -org.projectlombok.lombok=1.18.30 -org.slf4j.slf4j-api=1.7.36 -org.testcontainers.testcontainers=1.17.5 -org.apache.commons.commons-compress=1.26.2 -org.testcontainers.junit-jupiter=1.17.5 \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..1228cda --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,45 @@ +[versions] +logback = "1.4.12" +awsJavaSdk = "1.12.757" +awssdkS3 = "2.26.16" +jackson = "2.15.2" +nettyHttpRouter = "1.15" +apacheCommonsCodec = "1.15" +netty = "4.1.108.Final" +apacheCommonsCollections4 = "4.4" +commonsIo = "2.13.0" +apacheCommonsLang3 = "3.12.0" +junit5 = "5.8.1" +mockito = "4.2.0" +lombok = "1.18.30" +slf4j = "1.7.36" +testContainers = "1.17.5" +apacheCommonsCompress = "1.26.2" + +robothyCnRepo = "1.18" +gradleLombok = "5.0.0" + +[libraries] +logbackClassic = { group = "ch.qos.logback", name = "logback-classic", version.ref = "logback" } +awsJavaSdk = { group = "com.amazonaws", name = "aws-java-sdk", version.ref = "awsJavaSdk" } +awssdkS3 = { group = "software.amazon.awssdk", name = "s3", version.ref = "awssdkS3" } +jacksonDatabind = { group = "com.fasterxml.jackson.core", name = "jackson-databind", version.ref = "jackson" } +jacksonDataformatXml = { group = "com.fasterxml.jackson.dataformat", name = "jackson-dataformat-xml", version.ref = "jackson" } +jacksonDatatypeJdk8 = { group = "com.fasterxml.jackson.datatype", name = "jackson-datatype-jdk8", version.ref = "jackson" } +jacksonDatatypeJsr310 = { group = "com.fasterxml.jackson.datatype", name = "jackson-datatype-jsr310", version.ref = "jackson" } +nettyHttpRouter = { group = "io.github.robothy", name = "netty-http-router", version.ref = "nettyHttpRouter" } +apacheCommonsCodec = { group = "commons-codec", name = "commons-codec", version.ref = "apacheCommonsCodec" } +nettyAll = { group = "io.netty", name = "netty-all", version.ref = "netty" } +apacheCommonsCollections4 = { group = "org.apache.commons", name = "commons-collections4", version.ref = "apacheCommonsCollections4" } +commonsIo = { group = "commons-io", name = "commons-io", version.ref = "commonsIo" } +apacheCommonsLang3 = { group = "org.apache.commons", name = "commons-lang3", version.ref = "apacheCommonsLang3" } +junit5 = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit5" } +junit5JupiterEngine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit5" } +mockitoInline = { group = "org.mockito", name = "mockito-inline", version.ref = "mockito" } +lombok = { group = "org.projectlombok", name = "lombok", version.ref = "lombok" } +slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" } +testContainers = { group = "org.testcontainers", name = "testcontainers", version.ref = "testContainers" } +testContainersJunit = { group = "org.testcontainers", name = "junit-jupiter", version.ref = "testContainers" } +apacheCommonsCompress = { group = "org.apache.commons", name = "commons-compress", version.ref = "apacheCommonsCompress" } +robothyCnRepo = { group = "com.robothy", name = "cn-repo", version.ref = "robothyCnRepo" } +gradleLombok = { group = "io.franzbecker", name = "gradle-lombok", version.ref = "gradleLombok" } diff --git a/local-s3-core/build.gradle b/local-s3-core/build.gradle index 92a85fa..7f29290 100644 --- a/local-s3-core/build.gradle +++ b/local-s3-core/build.gradle @@ -5,9 +5,9 @@ plugins { dependencies { implementation project(":local-s3-datatypes") - implementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${libVersion['com.fasterxml.jackson.datatype.jackson-datatype-jdk8']}" - implementation "com.fasterxml.jackson.core:jackson-databind:${libVersion['com.fasterxml.jackson.core.jackson-databind']}" - implementation "commons-io:commons-io:${libVersion['commons-io.commons-io']}" - implementation "org.apache.commons:commons-lang3:${libVersion['org.apache.commons.commons-lang3']}" - implementation "commons-codec:commons-codec:${libVersion['commons-codec.commons-codec']}" -} \ No newline at end of file + implementation(libs.jacksonDatatypeJdk8) + implementation(libs.jacksonDatabind) + implementation(libs.commonsIo) + implementation(libs.apacheCommonsLang3) + implementation(libs.apacheCommonsCodec) +} diff --git a/local-s3-datatypes/build.gradle b/local-s3-datatypes/build.gradle index 907a5b5..aa5711d 100644 --- a/local-s3-datatypes/build.gradle +++ b/local-s3-datatypes/build.gradle @@ -4,11 +4,11 @@ plugins { } dependencies { - implementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${libVersion['com.fasterxml.jackson.datatype.jackson-datatype-jdk8']}" - implementation "com.fasterxml.jackson.core:jackson-databind:${libVersion['com.fasterxml.jackson.core.jackson-databind']}" - implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${libVersion['com.fasterxml.jackson.dataformat.jackson-dataformat-xml']}" - implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${libVersion['com.fasterxml.jackson.datatype.jackson-datatype-jsr310']}" - implementation "commons-io:commons-io:${libVersion['commons-io.commons-io']}" - implementation "org.apache.commons:commons-lang3:${libVersion['org.apache.commons.commons-lang3']}" - implementation "org.apache.commons:commons-collections4:${libVersion['org.apache.commons.commons-collections4']}" -} \ No newline at end of file + implementation(libs.jacksonDatatypeJdk8) + implementation(libs.jacksonDatabind) + implementation(libs.jacksonDataformatXml) + implementation(libs.jacksonDatatypeJsr310) + implementation(libs.commonsIo) + implementation(libs.apacheCommonsLang3) + implementation(libs.apacheCommonsCollections4) +} diff --git a/local-s3-docker/build.gradle b/local-s3-docker/build.gradle index 7d7cb4d..be5d6fe 100644 --- a/local-s3-docker/build.gradle +++ b/local-s3-docker/build.gradle @@ -7,12 +7,12 @@ plugins { dependencies { implementation(project(":local-s3-rest")) - runtimeOnly "ch.qos.logback:logback-classic:${libVersion['ch.qos.logback.logback-classic']}" testImplementation(project(":local-s3-testcontainers")) - testImplementation("org.testcontainers:testcontainers:${libVersion['org.testcontainers.testcontainers']}") - testImplementation "org.testcontainers:junit-jupiter:${libVersion['org.testcontainers.junit-jupiter']}" - testImplementation "software.amazon.awssdk:s3:${libVersion['software.amazon.awssdk.s3']}" - testImplementation "com.amazonaws:aws-java-sdk:${libVersion['com.amazonaws.aws-java-sdk']}" + runtimeOnly(libs.logbackClassic) + testImplementation(libs.testContainers) + testImplementation(libs.testContainersJunit) + testImplementation(libs.awssdkS3) + testImplementation(libs.awsJavaSdk) } jar { @@ -32,11 +32,11 @@ tasks.register('collectReachabilityMetadata', JavaExec) { outputs.cacheIf { true } - inputs.file("${buildDir}/libs/s3.jar") + inputs.file(project.layout.buildDirectory.file("libs/s3.jar")) .withPropertyName("jar") .withPathSensitivity(PathSensitivity.RELATIVE) - outputs.dir(file("${buildDir}/reachability-metadata")) + outputs.dir(project.layout.buildDirectory.file("reachability-metadata")) .withPropertyName("reachability-metadata") mainClass.set('com.robothy.s3.docker.ReachabilityMetadataGenerator') @@ -48,21 +48,21 @@ tasks.register('buildGraalVMNativeImage', Exec) { dependsOn('collectReachabilityMetadata') outputs.cacheIf { true } - inputs.dir(file("${buildDir}/reachability-metadata")) + inputs.dir(project.layout.buildDirectory.dir("reachability-metadata")) .withPropertyName("reachability-metadata") .withPathSensitivity(PathSensitivity.RELATIVE) - inputs.file("${buildDir}/libs/s3.jar") + inputs.file(project.layout.buildDirectory.file("libs/s3.jar")) .withPropertyName("jar") .withPathSensitivity(PathSensitivity.RELATIVE) - outputs.file("${buildDir}/bin/s3") + outputs.file(project.layout.buildDirectory.file("bin/s3")) .withPropertyName("s3-native-image") doFirst { var cmd = new ArrayList(executor) var buildCmd = """docker run --rm \ -v ${project.projectDir}:/project \ --v ${project.buildDir}/bin:/app \ -ghcr.io/graalvm/native-image:ol9-java17-22.3.0 \ +-v ${project.layout.buildDirectory.get().asFile}/bin:/app \ +ghcr.io/graalvm/native-image:ol9-java17-22.3.3 \ -jar /project/build/libs/s3.jar \ --initialize-at-build-time=ch.qos.logback,org.slf4j \ --install-exit-handlers \ @@ -79,7 +79,7 @@ tasks.register('buildGraalVMNativeBasedDockerImage', Exec) { outputs.cacheIf { true } - inputs.file("${buildDir}/bin/s3") + inputs.file(project.layout.buildDirectory.file("bin/s3")) .withPropertyName("s3-native-image") .withPathSensitivity(PathSensitivity.RELATIVE) @@ -141,4 +141,4 @@ tasks.register('pushLatestImage', Exec) { } -rootProject.tasks.release.dependsOn(pushLatestImage, pushJava17BasedDockerImage, pushGraalVMNativeBasedDockerImage) \ No newline at end of file +rootProject.tasks.release.dependsOn(pushLatestImage, pushJava17BasedDockerImage, pushGraalVMNativeBasedDockerImage) diff --git a/local-s3-docker/src/test/java/com/robothy/s3/docker/ReachabilityMetadataGenerator.java b/local-s3-docker/src/test/java/com/robothy/s3/docker/ReachabilityMetadataGenerator.java index db1cec0..e362ba9 100644 --- a/local-s3-docker/src/test/java/com/robothy/s3/docker/ReachabilityMetadataGenerator.java +++ b/local-s3-docker/src/test/java/com/robothy/s3/docker/ReachabilityMetadataGenerator.java @@ -56,7 +56,7 @@ public static void main(String[] args) throws IOException { File dataPath = Files.createTempDirectory("local-s3-data").toFile(); dataPath.deleteOnExit(); - try (CollectReachabilityMetadataContainer container = new CollectReachabilityMetadataContainer("ol9-java17-22.3.0")) { + try (CollectReachabilityMetadataContainer container = new CollectReachabilityMetadataContainer("ol9-java17-22.3.3")) { @@ -87,7 +87,7 @@ public static void main(String[] args) throws IOException { } /*======== Load data from data path. ========*/ - try (CollectReachabilityMetadataContainer container = new CollectReachabilityMetadataContainer("ol9-java17-22.3.0")) { + try (CollectReachabilityMetadataContainer container = new CollectReachabilityMetadataContainer("ol9-java17-22.3.3")) { container.port(port) .withFileSystemBind("build/reachability-metadata/META-INF/native-image", "/metadata", BindMode.READ_WRITE) .withFileSystemBind("build/libs", "/app", BindMode.READ_WRITE) diff --git a/local-s3-interationtest/build.gradle b/local-s3-interationtest/build.gradle index 6bf39f3..31e9133 100644 --- a/local-s3-interationtest/build.gradle +++ b/local-s3-interationtest/build.gradle @@ -4,17 +4,12 @@ plugins { dependencies { - testImplementation("software.amazon.awssdk:s3:${libVersion['software.amazon.awssdk.s3']}") - - testImplementation("com.amazonaws:aws-java-sdk:${libVersion['com.amazonaws.aws-java-sdk']}") - testImplementation(project(":local-s3-jupiter")) - testImplementation (project(":local-s3-datatypes")) - testImplementation(project(":local-s3-core")) testImplementation(project(":local-s3-rest")) - //testRuntimeOnly "ch.qos.logback:logback-core:${libVersion['ch.qos.logback.logback-core']}" - testRuntimeOnly "ch.qos.logback:logback-classic:${libVersion['ch.qos.logback.logback-classic']}" + testImplementation(libs.awssdkS3) + testImplementation(libs.awsJavaSdk) + testRuntimeOnly(libs.logbackClassic) } diff --git a/local-s3-jupiter/build.gradle b/local-s3-jupiter/build.gradle index cd5ff57..bf8f073 100644 --- a/local-s3-jupiter/build.gradle +++ b/local-s3-jupiter/build.gradle @@ -5,14 +5,14 @@ plugins { dependencies { implementation project(":local-s3-rest") - compileOnly "software.amazon.awssdk:s3:${libVersion['software.amazon.awssdk.s3']}" - compileOnly "com.amazonaws:aws-java-sdk:${libVersion['com.amazonaws.aws-java-sdk']}" - implementation "commons-io:commons-io:${libVersion['commons-io.commons-io']}" - implementation "org.apache.commons:commons-lang3:${libVersion['org.apache.commons.commons-lang3']}" - implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${libVersion['com.fasterxml.jackson.dataformat.jackson-dataformat-xml']}" - implementation "org.junit.jupiter:junit-jupiter:${libVersion['org.junit.jupiter.junit-jupiter']}" - testRuntimeOnly "ch.qos.logback:logback-classic:${libVersion['ch.qos.logback.logback-classic']}" - testImplementation "software.amazon.awssdk:s3:${libVersion['software.amazon.awssdk.s3']}" - testImplementation "com.amazonaws:aws-java-sdk:${libVersion['com.amazonaws.aws-java-sdk']}" + compileOnly(libs.awssdkS3) + compileOnly(libs.awsJavaSdk) + implementation(libs.commonsIo) + implementation(libs.apacheCommonsLang3) + implementation(libs.jacksonDataformatXml) + implementation(libs.junit5JupiterEngine) + implementation(libs.logbackClassic) + implementation(libs.awssdkS3) + implementation(libs.awsJavaSdk) } diff --git a/local-s3-rest/build.gradle b/local-s3-rest/build.gradle index 860255b..d135d82 100644 --- a/local-s3-rest/build.gradle +++ b/local-s3-rest/build.gradle @@ -6,17 +6,16 @@ plugins { dependencies { implementation project(":local-s3-core") implementation project(":local-s3-datatypes") - implementation "io.netty:netty-all:${libVersion['io.netty.netty-all']}" - implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${libVersion['com.fasterxml.jackson.dataformat.jackson-dataformat-xml']}" - implementation "com.fasterxml.jackson.core:jackson-databind:${libVersion['com.fasterxml.jackson.core.jackson-databind']}" - implementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${libVersion['com.fasterxml.jackson.datatype.jackson-datatype-jdk8']}" - implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${libVersion['com.fasterxml.jackson.datatype.jackson-datatype-jsr310']}" - implementation "commons-io:commons-io:${libVersion['commons-io.commons-io']}" - implementation "org.apache.commons:commons-lang3:${libVersion['org.apache.commons.commons-lang3']}" - implementation "org.apache.commons:commons-collections4:${libVersion['org.apache.commons.commons-collections4']}" - implementation ("io.github.robothy:netty-http-router:${libVersion['com.robothy.netty-http-router']}") { + implementation(libs.nettyAll) + implementation(libs.jacksonDataformatXml) + implementation(libs.jacksonDatabind) + implementation(libs.jacksonDatatypeJdk8) + implementation(libs.jacksonDatatypeJsr310) + implementation(libs.commonsIo) + implementation(libs.apacheCommonsLang3) + implementation(libs.apacheCommonsCollections4) + implementation(libs.nettyHttpRouter) { exclude(group: "org.springframework", module: "spring-web") } - - testImplementation "org.mockito:mockito-inline:${libVersion['org.mockito.mockito-inline']}" -} \ No newline at end of file + implementation(libs.mockitoInline) +} diff --git a/local-s3-testcontainers/build.gradle b/local-s3-testcontainers/build.gradle index cac8a0a..2239399 100644 --- a/local-s3-testcontainers/build.gradle +++ b/local-s3-testcontainers/build.gradle @@ -5,10 +5,10 @@ plugins { dependencies { - implementation "org.testcontainers:testcontainers:${libVersion['org.testcontainers.testcontainers']}" - implementation("org.apache.commons:commons-compress:${libVersion['org.apache.commons.commons-compress']}") + implementation(libs.testContainers) + implementation(libs.apacheCommonsCompress) } test { useJUnitPlatform() -} \ No newline at end of file +}