From 7b3d69b9d3469e1906b40c313157f2fc59fdc2a7 Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Mon, 16 Oct 2023 21:35:37 +0200 Subject: [PATCH] Support both Groovy 3.x and Groovy 4.x We still have to support Gradle < 9.x, which requires Groovy 3.x See https://github.com/gesellix/docker-client/issues/578 --- .github/dependabot.yml | 1 + build.gradle.kts | 1 + client-groovy4/build.gradle.kts | 246 ++++++++++++++++++++++++++++++ client/build.gradle.kts | 34 ++--- explore/build.gradle.kts | 16 +- integration-test/build.gradle.kts | 6 +- settings.gradle.kts | 6 +- 7 files changed, 289 insertions(+), 21 deletions(-) create mode 100644 client-groovy4/build.gradle.kts diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 70296970..c3f86a49 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -19,4 +19,5 @@ updates: # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#groups groovy: patterns: + - "org.codehaus.groovy:*" - "org.apache.groovy:*" diff --git a/build.gradle.kts b/build.gradle.kts index 5ee2e621..a39673a1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,6 +11,7 @@ val dependencyVersions = listOf( "net.bytebuddy:byte-buddy:1.14.9", "net.bytebuddy:byte-buddy-agent:1.14.9", "org.apache.commons:commons-compress:1.24.0", + "org.codehaus.groovy:groovy:3.0.19", "org.apache.groovy:groovy:4.0.15", "org.jetbrains:annotations:24.0.1", "org.junit:junit-bom:5.10.0", diff --git a/client-groovy4/build.gradle.kts b/client-groovy4/build.gradle.kts new file mode 100644 index 00000000..b83946c0 --- /dev/null +++ b/client-groovy4/build.gradle.kts @@ -0,0 +1,246 @@ +import java.text.SimpleDateFormat +import java.util.* + +plugins { + id("groovy") + id("java-library") + id("maven-publish") + id("signing") + id("com.github.ben-manes.versions") + id("net.ossindex.audit") + id("io.freefair.maven-central.validate-poms") +} + +dependencies { + constraints { + implementation("de.gesellix:docker-engine") { + version { + strictly("[2023-10-01T01-01-01,)") + } + } + implementation("de.gesellix:docker-filesocket") { + version { + strictly("[2023-09-01T01-01-01,)") + } + } + implementation("de.gesellix:docker-remote-api-model-1-41") { + version { + strictly("[2023-10-01T01-01-01,)") + } + } + implementation("org.slf4j:slf4j-api") { + version { + strictly("[1.7,3)") + prefer("2.0.9") + } + } + implementation("com.squareup.okhttp3:mockwebserver") { + version { + strictly("[4,5)") + prefer("4.11.0") + } + } + api("com.squareup.okhttp3:okhttp") { + version { + strictly("[4,5)") + prefer("4.11.0") + } + } + listOf( + "com.squareup.okio:okio", + "com.squareup.okio:okio-jvm" + ).onEach { + implementation(it) { + version { + strictly("[3,4)") + prefer("3.6.0") + } + } + } + listOf( + "org.jetbrains.kotlin:kotlin-reflect", + "org.jetbrains.kotlin:kotlin-stdlib", + "org.jetbrains.kotlin:kotlin-stdlib-jdk7", + "org.jetbrains.kotlin:kotlin-stdlib-jdk8", + "org.jetbrains.kotlin:kotlin-stdlib-common", + "org.jetbrains.kotlin:kotlin-test" + ).onEach { + implementation(it) { + version { + strictly("[1.6,1.10)") + prefer("1.9.10") + } + } + } + listOf( + "org.apache.groovy:groovy", + "org.apache.groovy:groovy-json" + ).onEach { + implementation(it) { + version { + strictly("[4,)") + prefer("4.0.15") + } + } + } + listOf( + "com.squareup.moshi:moshi", + "com.squareup.moshi:moshi-kotlin" + ).onEach { + implementation(it) { + version { + strictly("[1.12.0,)") + prefer("1.15.0") + } + } + } + } + + // TODO consider changing this from api to implementation. + // The change would require to move api.core client classes like `ClientException` to another module. + api("de.gesellix:docker-remote-api-client:2023-10-12T22-20-00") + api("de.gesellix:docker-remote-api-model-1-41:2023-10-12T20-45-00") + api("de.gesellix:docker-engine:2023-10-03T21-35-00") + api("de.gesellix:docker-compose:2023-09-23T20-42-00") + + implementation("org.apache.groovy:groovy:4.0.15") + implementation("org.apache.groovy:groovy-json:4.0.15") + + api("com.squareup.moshi:moshi:1.15.0") + implementation("com.google.re2j:re2j:1.7") + + implementation("org.slf4j:slf4j-api:2.0.9") + testImplementation("ch.qos.logback:logback-classic:[1.2,2)!!1.3.11") + + implementation("com.squareup.okio:okio:3.6.0") + api("com.squareup.okhttp3:okhttp:4.11.0") + testImplementation("com.squareup.okhttp3:mockwebserver:[4,5)") + + implementation("org.apache.commons:commons-compress:1.24.0") + +// implementation("org.bouncycastle:bcpkix-jdk18on:1.76") + + testImplementation("de.gesellix:testutil:[2023-09-01T01-01-01,)") + + testImplementation("org.junit.platform:junit-platform-launcher:1.10.0") + testImplementation("org.spockframework:spock-core:2.3-groovy-4.0") + testRuntimeOnly("net.bytebuddy:byte-buddy:1.14.9") + testRuntimeOnly("org.objenesis:objenesis:3.3") + testImplementation("io.github.joke:spock-mockable:2.3.0") + + testImplementation("org.apache.commons:commons-lang3:3.13.0") +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(8)) + } +} + +java { + sourceSets { + main { + groovy { + srcDirs(project(":client").sourceSets["main"].allJava) + } + resources { + srcDirs(project(":client").sourceSets["main"].resources) + } + } + test { + groovy { + srcDirs(project(":client").sourceSets["test"].allJava) + } + resources { + srcDirs(project(":client").sourceSets["test"].resources) + } + } + } +} + +tasks { + withType { + options.encoding = "UTF-8" + } + + withType { + useJUnitPlatform() + + // minimal way of providing a special environment variable for the EnvFileParserTest + environment("A_KNOWN_VARIABLE", "my value") + } +} + +val javadocJar by tasks.registering(Jar::class) { + dependsOn("classes") + archiveClassifier.set("javadoc") + from(tasks.javadoc) +} + +val sourcesJar by tasks.registering(Jar::class) { + dependsOn("classes") + archiveClassifier.set("sources") + from(sourceSets.main.get().allSource) +} + +artifacts { + add("archives", sourcesJar.get()) + add("archives", javadocJar.get()) +} + +fun findProperty(s: String) = project.findProperty(s) as String? + +val isSnapshot = project.version == "unspecified" +val artifactVersion = if (!isSnapshot) project.version as String else SimpleDateFormat("yyyy-MM-dd\'T\'HH-mm-ss").format(Date())!! +val publicationName = "dockerClient" +publishing { + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/${property("github.package-registry.owner")}/${property("github.package-registry.repository")}") + credentials { + username = System.getenv("GITHUB_ACTOR") ?: findProperty("github.package-registry.username") + password = System.getenv("GITHUB_TOKEN") ?: findProperty("github.package-registry.password") + } + } + } + publications { + register(publicationName, MavenPublication::class) { + pom { + name.set("docker-client") + description.set("A Docker client for the JVM written in Groovy") + url.set("https://github.com/gesellix/docker-client") + licenses { + license { + name.set("MIT") + url.set("https://opensource.org/licenses/MIT") + } + } + developers { + developer { + id.set("gesellix") + name.set("Tobias Gesellchen") + email.set("tobias@gesellix.de") + } + } + scm { + connection.set("scm:git:github.com/gesellix/docker-client.git") + developerConnection.set("scm:git:ssh://github.com/gesellix/docker-client.git") + url.set("https://github.com/gesellix/docker-client") + } + } + artifactId = "docker-client" + version = "${artifactVersion}-groovy-4" + from(components["java"]) + artifact(sourcesJar.get()) + artifact(javadocJar.get()) + } + } +} + +signing { + val signingKey: String? by project + val signingPassword: String? by project + useInMemoryPgpKeys(signingKey, signingPassword) + sign(publishing.publications[publicationName]) +} diff --git a/client/build.gradle.kts b/client/build.gradle.kts index 74f874e6..9e4e5046 100644 --- a/client/build.gradle.kts +++ b/client/build.gradle.kts @@ -47,8 +47,8 @@ dependencies { } } listOf( - "com.squareup.okio:okio", - "com.squareup.okio:okio-jvm" + "com.squareup.okio:okio", + "com.squareup.okio:okio-jvm" ).onEach { implementation(it) { version { @@ -58,12 +58,12 @@ dependencies { } } listOf( - "org.jetbrains.kotlin:kotlin-reflect", - "org.jetbrains.kotlin:kotlin-stdlib", - "org.jetbrains.kotlin:kotlin-stdlib-jdk7", - "org.jetbrains.kotlin:kotlin-stdlib-jdk8", - "org.jetbrains.kotlin:kotlin-stdlib-common", - "org.jetbrains.kotlin:kotlin-test" + "org.jetbrains.kotlin:kotlin-reflect", + "org.jetbrains.kotlin:kotlin-stdlib", + "org.jetbrains.kotlin:kotlin-stdlib-jdk7", + "org.jetbrains.kotlin:kotlin-stdlib-jdk8", + "org.jetbrains.kotlin:kotlin-stdlib-common", + "org.jetbrains.kotlin:kotlin-test" ).onEach { implementation(it) { version { @@ -73,19 +73,19 @@ dependencies { } } listOf( - "org.apache.groovy:groovy", - "org.apache.groovy:groovy-json" + "org.codehaus.groovy:groovy", + "org.codehaus.groovy:groovy-json" ).onEach { implementation(it) { version { - strictly("[4,)") - prefer("4.0.15") + strictly("[3,4)") + prefer("3.0.19") } } } listOf( - "com.squareup.moshi:moshi", - "com.squareup.moshi:moshi-kotlin" + "com.squareup.moshi:moshi", + "com.squareup.moshi:moshi-kotlin" ).onEach { implementation(it) { version { @@ -103,8 +103,8 @@ dependencies { api("de.gesellix:docker-engine:2023-10-03T21-35-00") api("de.gesellix:docker-compose:2023-09-23T20-42-00") - implementation("org.apache.groovy:groovy:4.0.15") - implementation("org.apache.groovy:groovy-json:4.0.15") + implementation("org.codehaus.groovy:groovy:3.0.19") + implementation("org.codehaus.groovy:groovy-json:3.0.19") api("com.squareup.moshi:moshi:1.15.0") implementation("com.google.re2j:re2j:1.7") @@ -123,7 +123,7 @@ dependencies { testImplementation("de.gesellix:testutil:[2023-09-01T01-01-01,)") testImplementation("org.junit.platform:junit-platform-launcher:1.10.0") - testImplementation("org.spockframework:spock-core:2.3-groovy-4.0") + testImplementation("org.spockframework:spock-core:2.3-groovy-3.0") testRuntimeOnly("net.bytebuddy:byte-buddy:1.14.9") testRuntimeOnly("org.objenesis:objenesis:3.3") testImplementation("io.github.joke:spock-mockable:2.3.0") diff --git a/explore/build.gradle.kts b/explore/build.gradle.kts index 8de12862..5be0cc5a 100644 --- a/explore/build.gradle.kts +++ b/explore/build.gradle.kts @@ -37,6 +37,17 @@ dependencies { } } } + listOf( + "org.codehaus.groovy:groovy", + "org.codehaus.groovy:groovy-json" + ).onEach { + implementation(it) { + version { + strictly("[3,4)") + prefer("3.0.19") + } + } + } listOf( "org.apache.groovy:groovy", "org.apache.groovy:groovy-json" @@ -49,13 +60,16 @@ dependencies { } } } - implementation(project(":client")) +// implementation(project(":client")) + implementation(project(":client-groovy4")) +// implementation("org.codehaus.groovy:groovy:[3,4)") implementation("org.apache.groovy:groovy:4.0.15") testImplementation("org.apache.commons:commons-compress:1.24.0") implementation("org.slf4j:slf4j-api:2.0.9") runtimeOnly("ch.qos.logback:logback-classic:[1.2,2)!!1.3.11") +// testImplementation("org.spockframework:spock-core:2.3-groovy-3.0") testImplementation("org.spockframework:spock-core:2.3-groovy-4.0") testRuntimeOnly("net.bytebuddy:byte-buddy:1.14.9") testRuntimeOnly("ch.qos.logback:logback-classic:[1.2,2)!!1.3.11") diff --git a/integration-test/build.gradle.kts b/integration-test/build.gradle.kts index cb1492f8..79c637c3 100644 --- a/integration-test/build.gradle.kts +++ b/integration-test/build.gradle.kts @@ -75,7 +75,8 @@ dependencies { } } implementation(project(":client")) - testImplementation("org.apache.groovy:groovy-json:[4,)") + testImplementation("org.codehaus.groovy:groovy-json:[3,4)") +// testImplementation("org.apache.groovy:groovy-json:[4,)") testImplementation("com.kohlschutter.junixsocket:junixsocket-core:[2.4,)") testImplementation("com.kohlschutter.junixsocket:junixsocket-common:[2.4,)") @@ -87,7 +88,8 @@ dependencies { testImplementation("de.gesellix:docker-registry:2023-10-03T20-58-00") testImplementation("de.gesellix:testutil:[2023-09-01T01-01-01,)") - testImplementation("org.spockframework:spock-core:2.3-groovy-4.0") + testImplementation("org.spockframework:spock-core:2.3-groovy-3.0") +// testImplementation("org.spockframework:spock-core:2.3-groovy-4.0") testRuntimeOnly("net.bytebuddy:byte-buddy:1.14.9") testImplementation("org.apache.commons:commons-lang3:3.13.0") testRuntimeOnly("ch.qos.logback:logback-classic:[1.2,2)!!1.3.8") diff --git a/settings.gradle.kts b/settings.gradle.kts index 5241807a..b0268748 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,9 @@ rootProject.name = "docker-client" -include("client", "integration-test", "explore") +include( + "client", + "client-groovy4", + "integration-test", + "explore") // https://docs.gradle.org/8.0.1/userguide/toolchains.html#sub:download_repositories plugins {