Skip to content

Commit

Permalink
Support both Groovy 3.x and Groovy 4.x
Browse files Browse the repository at this point in the history
We still have to support Gradle < 9.x, which requires Groovy 3.x

See #578
  • Loading branch information
gesellix committed Oct 16, 2023
1 parent 99e8db5 commit 7b3d69b
Show file tree
Hide file tree
Showing 7 changed files with 289 additions and 21 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:*"
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
246 changes: 246 additions & 0 deletions client-groovy4/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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<JavaCompile> {
options.encoding = "UTF-8"
}

withType<Test> {
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("[email protected]")
}
}
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])
}
34 changes: 17 additions & 17 deletions client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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")
Expand All @@ -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")
Expand Down
16 changes: 15 additions & 1 deletion explore/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions integration-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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,)")

Expand All @@ -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")
Expand Down
Loading

0 comments on commit 7b3d69b

Please sign in to comment.