Skip to content

Commit

Permalink
Update to Gradle 7 (#4171)
Browse files Browse the repository at this point in the history
* Update to Gradle 7

* Add `checkPOMdependencies` task to test that no new dependencies were added

* Update examples to Gradle 7

* Disable the filesystem watching

* Try Gradle 7.0.2

* fix `provided` configuration

* Extract `ComparePOMWithLatestReleasedTask`

* Add missing file
  • Loading branch information
bsideup authored Jun 9, 2021
1 parent d76445b commit 9a8df79
Show file tree
Hide file tree
Showing 48 changed files with 254 additions and 217 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ node_modules/

.gradle/
build/
!buildSrc/src/main/groovy/org/testcontainers/build
out/
*.class

Expand Down
19 changes: 11 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
plugins {
id 'io.franzbecker.gradle-lombok' version '3.1.0'
id 'nebula.provided-base' version '3.0.3'
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'io.franzbecker.gradle-lombok' version '4.0.0'
id 'com.github.johnrengelman.shadow' version '7.0.0'
id "com.jfrog.bintray" version "1.8.4" apply false
}

apply from: "$rootDir/gradle/ci-support.gradle"

subprojects {
apply plugin: 'nebula.provided-base'
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'idea'
apply plugin: 'io.franzbecker.gradle-lombok'
apply plugin: 'com.github.johnrengelman.shadow'
Expand All @@ -26,8 +24,13 @@ subprojects {
mavenCentral()
}

configurations {
provided
api.extendsFrom(provided)
}

lombok {
version = '1.18.12'
version = '1.18.20'
}

task delombok(type: io.franzbecker.gradle.lombok.task.DelombokTask) {
Expand Down Expand Up @@ -98,7 +101,7 @@ subprojects {

shadowJar {
configurations = []
classifier = null
archiveClassifier.set(null)

doFirst {
// See https://github.com/johnrengelman/shadow/blob/5.0.0/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ConfigureShadowRelocation.groovy
Expand Down Expand Up @@ -128,6 +131,6 @@ subprojects {
}

dependencies {
testCompile 'ch.qos.logback:logback-classic:1.2.3'
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
}
}
7 changes: 7 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
id 'java-gradle-plugin'
}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.testcontainers.build

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction

class ComparePOMWithLatestReleasedTask extends DefaultTask {

@Input
Set<String> ignore = []

@TaskAction
def doCompare() {
def rootNode = new XmlSlurper().parse(project.tasks.generatePomFileForMavenJavaPublication.destination)

def artifactId = rootNode.artifactId.text()

def latestRelease = new XmlSlurper()
.parse("https://repo1.maven.org/maven2/org/testcontainers/${artifactId}/maven-metadata.xml")
.versioning.release.text()

def releasedRootNode = new XmlSlurper()
.parse("https://repo1.maven.org/maven2/org/testcontainers/${artifactId}/${latestRelease}/${artifactId}-${latestRelease}.pom")

Set<String> dependencies = releasedRootNode.dependencies.children()
.collect { "${it.groupId.text()}:${it.artifactId.text()}".toString() }

for (dependency in rootNode.dependencies.children()) {
def coordinates = "${dependency.groupId.text()}:${dependency.artifactId.text()}".toString()
if (!dependencies.contains(coordinates) && !ignore.contains(coordinates)) {
throw new IllegalStateException("A new dependency '${coordinates}' has been added to 'org.testcontainers:${artifactId}' - if this was intentional please add it to the ignore list in ${project.buildFile}")
}
}
}
}
62 changes: 26 additions & 36 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,24 @@ idea.module.testSourceDirs += sourceSets.jarFileTest.allSource.srcDirs
configurations {
baseline
shaded
[runtime, compileOnly, testCompile]*.extendsFrom shaded
[api, compileOnly, testCompile]*.extendsFrom shaded
}

shadowJar {
configurations = [project.configurations.shaded]

mergeServiceFiles()

exclude 'org/newsclub/**'

[
'META-INF/NOTICE',
'META-INF/NOTICE.txt',
'META-INF/LICENSE',
'META-INF/LICENSE.txt',
'META-INF/DEPENDENCIES',
'META-INF/maven/',
'META-INF/proguard/',
'META-INF/versions/*/module-info.class',
'META-INF/services/README.md',
'META-INF/services/com.fasterxml.jackson.core.*',
'META-INF/services/com.github.dockerjava.api.command.*',
'META-INF/services/javax.ws.rs.ext.*',
'META-INF/services/java.security.Provider',
'mozilla/public-suffix-list.txt',
'module-info.class',
].each { exclude(it) }

project.afterEvaluate {
dependencies {
for (id in project.configurations.compile.resolvedConfiguration.resolvedArtifacts*.moduleVersion*.id) {
exclude(dependency("${id.group}:${id.name}"))
}
}
}
}

task jarFileTest(type: Test) {
Expand Down Expand Up @@ -169,16 +152,16 @@ dependencies {
exclude group: "*", module: "*"
}

compile 'junit:junit:4.12'
compile 'org.slf4j:slf4j-api:1.7.30'
api 'junit:junit:4.12'
api 'org.slf4j:slf4j-api:1.7.30'
compileOnly 'org.jetbrains:annotations:20.1.0'
testCompileClasspath 'org.jetbrains:annotations:20.0.0'
compile 'org.apache.commons:commons-compress:1.20'
compile ('org.rnorth.duct-tape:duct-tape:1.0.8') {
api 'org.apache.commons:commons-compress:1.20'
api ('org.rnorth.duct-tape:duct-tape:1.0.8') {
exclude(group: 'org.jetbrains', module: 'annotations')
}

compile "com.github.docker-java:docker-java-api:3.2.8"
api "com.github.docker-java:docker-java-api:3.2.8"

shaded ('com.github.docker-java:docker-java-core:3.2.8') {
exclude(group: 'com.github.docker-java', module: 'docker-java-api')
Expand All @@ -195,7 +178,7 @@ dependencies {
exclude(group: 'org.slf4j')
}

compile 'com.github.docker-java:docker-java-transport-zerodep:3.2.8'
api 'com.github.docker-java:docker-java-transport-zerodep:3.2.8'

shaded "org.yaml:snakeyaml:1.27"

Expand All @@ -205,24 +188,31 @@ dependencies {
exclude(group: 'org.slf4j')
}

testCompile 'org.apache.httpcomponents:httpclient:4.5.9'
testCompile 'redis.clients:jedis:3.6.0'
testCompile 'com.rabbitmq:amqp-client:5.9.0'
testCompile 'org.mongodb:mongo-java-driver:3.12.7'
testImplementation 'org.apache.httpcomponents:httpclient:4.5.9'
testImplementation 'redis.clients:jedis:3.6.0'
testImplementation 'com.rabbitmq:amqp-client:5.9.0'
testImplementation 'org.mongodb:mongo-java-driver:3.12.7'

testCompile ('org.mockito:mockito-core:3.10.0') {
testImplementation ('org.mockito:mockito-core:3.10.0') {
exclude(module: 'hamcrest-core')
}
// Synthetic JAR used for MountableFileTest and DirectoryTarResourceTest
testCompile files('testlib/repo/fakejar/fakejar/0/fakejar-0.jar')
testImplementation files('testlib/repo/fakejar/fakejar/0/fakejar-0.jar')

testCompile 'org.rnorth.visible-assertions:visible-assertions:2.1.2'
testCompile 'org.assertj:assertj-core:3.18.1'
testCompile project(':test-support')
testImplementation 'org.rnorth.visible-assertions:visible-assertions:2.1.2'
testImplementation 'org.assertj:assertj-core:3.18.1'
testImplementation project(':test-support')

jarFileTestCompileOnly "org.projectlombok:lombok:${lombok.version}"
jarFileTestAnnotationProcessor "org.projectlombok:lombok:${lombok.version}"
jarFileTestCompile 'junit:junit:4.12'
jarFileTestCompile 'org.assertj:assertj-core:3.18.1'
jarFileTestCompile 'org.ow2.asm:asm-debug-all:5.2'
jarFileTestImplementation 'junit:junit:4.12'
jarFileTestImplementation 'org.assertj:assertj-core:3.18.1'
jarFileTestImplementation 'org.ow2.asm:asm-debug-all:5.2'
}

tasks.generatePomFileForMavenJavaPublication.finalizedBy(
tasks.register('checkPOMdependencies', org.testcontainers.build.ComparePOMWithLatestReleasedTask) {
ignore = [
]
}
)
2 changes: 1 addition & 1 deletion docs/examples/junit4/redis/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
description = "Examples for docs"

dependencies {
compile "io.lettuce:lettuce-core:5.1.1.RELEASE"
api "io.lettuce:lettuce-core:5.1.1.RELEASE"

testImplementation "junit:junit:4.12"
testImplementation project(":testcontainers")
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/junit5/redis/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
description = "Examples for docs"

dependencies {
compile "io.lettuce:lettuce-core:5.1.1.RELEASE"
api "io.lettuce:lettuce-core:5.1.1.RELEASE"

testImplementation "org.junit.jupiter:junit-jupiter-api:5.4.2"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.4.2"
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/spock/redis/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

dependencies {
compile "io.lettuce:lettuce-core:5.2.0.RELEASE"
api "io.lettuce:lettuce-core:5.2.0.RELEASE"
testImplementation 'org.spockframework:spock-core:1.2-groovy-2.5'
testImplementation project(":spock")
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
Expand Down
2 changes: 1 addition & 1 deletion examples/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
10 changes: 5 additions & 5 deletions examples/kafka-cluster/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ repositories {
dependencies {
testCompileOnly "org.projectlombok:lombok:1.18.20"
testAnnotationProcessor "org.projectlombok:lombok:1.18.10"
testCompile 'org.testcontainers:kafka'
testCompile 'org.apache.kafka:kafka-clients:2.3.1'
testCompile 'org.assertj:assertj-core:3.14.0'
testCompile 'com.google.guava:guava:23.0'
testCompile 'org.slf4j:slf4j-simple:1.7.30'
testImplementation 'org.testcontainers:kafka'
testImplementation 'org.apache.kafka:kafka-clients:2.3.1'
testImplementation 'org.assertj:assertj-core:3.14.0'
testImplementation 'com.google.guava:guava:23.0'
testImplementation 'org.slf4j:slf4j-simple:1.7.30'
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
org.gradle.parallel=false
org.gradle.caching=true

2 changes: 1 addition & 1 deletion gradle/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ publishing {
}
}

project.configurations.compile.dependencies.each { addDependency(it, 'compile') }
project.configurations.api.dependencies.each { addDependency(it, 'compile') }
project.configurations.provided.dependencies.each { addDependency(it, 'provided') }
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Sun Apr 05 19:28:23 BST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
4 changes: 2 additions & 2 deletions modules/cassandra/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
description = "TestContainers :: Cassandra"

dependencies {
compile project(":database-commons")
compile "com.datastax.cassandra:cassandra-driver-core:3.7.1"
api project(":database-commons")
api "com.datastax.cassandra:cassandra-driver-core:3.7.1"
}
8 changes: 4 additions & 4 deletions modules/clickhouse/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
description = "Testcontainers :: JDBC :: ClickHouse"

dependencies {
compile project(':testcontainers')
compile project(':jdbc')
api project(':testcontainers')
api project(':jdbc')

testCompile project(':jdbc-test')
testCompile 'ru.yandex.clickhouse:clickhouse-jdbc:0.2.4'
testImplementation project(':jdbc-test')
testImplementation 'ru.yandex.clickhouse:clickhouse-jdbc:0.2.4'
}
6 changes: 3 additions & 3 deletions modules/cockroachdb/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
description = "Testcontainers :: JDBC :: CockroachDB"

dependencies {
compile project(':jdbc')
api project(':jdbc')

testCompile project(':jdbc-test')
testCompile 'org.postgresql:postgresql:42.2.12'
testImplementation project(':jdbc-test')
testImplementation 'org.postgresql:postgresql:42.2.12'
}
4 changes: 2 additions & 2 deletions modules/couchbase/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
description = "Testcontainers :: Couchbase"

dependencies {
compile project(':testcontainers')
api project(':testcontainers')

testCompile 'com.couchbase.client:java-client:2.7.15'
testImplementation 'com.couchbase.client:java-client:2.7.15'
}
4 changes: 2 additions & 2 deletions modules/database-commons/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
description = "Testcontainers :: Database-Commons"

dependencies {
compile project(':testcontainers')
api project(':testcontainers')

testCompile 'org.assertj:assertj-core:3.19.0'
testImplementation 'org.assertj:assertj-core:3.19.0'
}
6 changes: 3 additions & 3 deletions modules/db2/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
description = "Testcontainers :: JDBC :: DB2"

dependencies {
compile project(':jdbc')
api project(':jdbc')

testCompile project(':jdbc-test')
testCompile 'com.ibm.db2:jcc:11.5.0.0'
testImplementation project(':jdbc-test')
testImplementation 'com.ibm.db2:jcc:11.5.0.0'
}
6 changes: 3 additions & 3 deletions modules/dynalite/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
description = "Testcontainers :: Dynalite"

dependencies {
compile project(':testcontainers')
api project(':testcontainers')

compileOnly 'com.amazonaws:aws-java-sdk-dynamodb:1.11.1030'
testCompile 'com.amazonaws:aws-java-sdk-dynamodb:1.11.1030'
testImplementation 'com.amazonaws:aws-java-sdk-dynamodb:1.11.1030'

testCompile 'org.rnorth.visible-assertions:visible-assertions:2.1.2'
testImplementation 'org.rnorth.visible-assertions:visible-assertions:2.1.2'
}
8 changes: 4 additions & 4 deletions modules/elasticsearch/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
description = "TestContainers :: elasticsearch"

dependencies {
compile project(':testcontainers')
testCompile "org.elasticsearch.client:elasticsearch-rest-client:7.13.0"
testCompile "org.elasticsearch.client:transport:7.12.1"
testCompile 'org.rnorth.visible-assertions:visible-assertions:2.1.2'
api project(':testcontainers')
testImplementation "org.elasticsearch.client:elasticsearch-rest-client:7.13.0"
testImplementation "org.elasticsearch.client:transport:7.12.1"
testImplementation 'org.rnorth.visible-assertions:visible-assertions:2.1.2'
}
Loading

0 comments on commit 9a8df79

Please sign in to comment.