Skip to content

Commit 9a8df79

Browse files
authored
Update to Gradle 7 (#4171)
* 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
1 parent d76445b commit 9a8df79

File tree

48 files changed

+254
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+254
-217
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ node_modules/
4646

4747
.gradle/
4848
build/
49+
!buildSrc/src/main/groovy/org/testcontainers/build
4950
out/
5051
*.class
5152

build.gradle

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
plugins {
2-
id 'io.franzbecker.gradle-lombok' version '3.1.0'
3-
id 'nebula.provided-base' version '3.0.3'
4-
id 'com.github.johnrengelman.shadow' version '5.2.0'
2+
id 'io.franzbecker.gradle-lombok' version '4.0.0'
3+
id 'com.github.johnrengelman.shadow' version '7.0.0'
54
id "com.jfrog.bintray" version "1.8.4" apply false
65
}
76

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

109
subprojects {
11-
apply plugin: 'nebula.provided-base'
12-
apply plugin: 'java'
10+
apply plugin: 'java-library'
1311
apply plugin: 'idea'
1412
apply plugin: 'io.franzbecker.gradle-lombok'
1513
apply plugin: 'com.github.johnrengelman.shadow'
@@ -26,8 +24,13 @@ subprojects {
2624
mavenCentral()
2725
}
2826

27+
configurations {
28+
provided
29+
api.extendsFrom(provided)
30+
}
31+
2932
lombok {
30-
version = '1.18.12'
33+
version = '1.18.20'
3134
}
3235

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

99102
shadowJar {
100103
configurations = []
101-
classifier = null
104+
archiveClassifier.set(null)
102105

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

130133
dependencies {
131-
testCompile 'ch.qos.logback:logback-classic:1.2.3'
134+
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
132135
}
133136
}

buildSrc/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
id 'java-gradle-plugin'
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.testcontainers.build
2+
3+
import org.gradle.api.DefaultTask
4+
import org.gradle.api.tasks.Input
5+
import org.gradle.api.tasks.TaskAction
6+
7+
class ComparePOMWithLatestReleasedTask extends DefaultTask {
8+
9+
@Input
10+
Set<String> ignore = []
11+
12+
@TaskAction
13+
def doCompare() {
14+
def rootNode = new XmlSlurper().parse(project.tasks.generatePomFileForMavenJavaPublication.destination)
15+
16+
def artifactId = rootNode.artifactId.text()
17+
18+
def latestRelease = new XmlSlurper()
19+
.parse("https://repo1.maven.org/maven2/org/testcontainers/${artifactId}/maven-metadata.xml")
20+
.versioning.release.text()
21+
22+
def releasedRootNode = new XmlSlurper()
23+
.parse("https://repo1.maven.org/maven2/org/testcontainers/${artifactId}/${latestRelease}/${artifactId}-${latestRelease}.pom")
24+
25+
Set<String> dependencies = releasedRootNode.dependencies.children()
26+
.collect { "${it.groupId.text()}:${it.artifactId.text()}".toString() }
27+
28+
for (dependency in rootNode.dependencies.children()) {
29+
def coordinates = "${dependency.groupId.text()}:${dependency.artifactId.text()}".toString()
30+
if (!dependencies.contains(coordinates) && !ignore.contains(coordinates)) {
31+
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}")
32+
}
33+
}
34+
}
35+
}

core/build.gradle

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,24 @@ idea.module.testSourceDirs += sourceSets.jarFileTest.allSource.srcDirs
2626
configurations {
2727
baseline
2828
shaded
29-
[runtime, compileOnly, testCompile]*.extendsFrom shaded
29+
[api, compileOnly, testCompile]*.extendsFrom shaded
3030
}
3131

3232
shadowJar {
3333
configurations = [project.configurations.shaded]
3434

3535
mergeServiceFiles()
3636

37-
exclude 'org/newsclub/**'
38-
3937
[
4038
'META-INF/NOTICE',
4139
'META-INF/NOTICE.txt',
4240
'META-INF/LICENSE',
4341
'META-INF/LICENSE.txt',
44-
'META-INF/DEPENDENCIES',
4542
'META-INF/maven/',
4643
'META-INF/proguard/',
4744
'META-INF/versions/*/module-info.class',
48-
'META-INF/services/README.md',
49-
'META-INF/services/com.fasterxml.jackson.core.*',
50-
'META-INF/services/com.github.dockerjava.api.command.*',
51-
'META-INF/services/javax.ws.rs.ext.*',
5245
'META-INF/services/java.security.Provider',
53-
'mozilla/public-suffix-list.txt',
54-
'module-info.class',
5546
].each { exclude(it) }
56-
57-
project.afterEvaluate {
58-
dependencies {
59-
for (id in project.configurations.compile.resolvedConfiguration.resolvedArtifacts*.moduleVersion*.id) {
60-
exclude(dependency("${id.group}:${id.name}"))
61-
}
62-
}
63-
}
6447
}
6548

6649
task jarFileTest(type: Test) {
@@ -169,16 +152,16 @@ dependencies {
169152
exclude group: "*", module: "*"
170153
}
171154

172-
compile 'junit:junit:4.12'
173-
compile 'org.slf4j:slf4j-api:1.7.30'
155+
api 'junit:junit:4.12'
156+
api 'org.slf4j:slf4j-api:1.7.30'
174157
compileOnly 'org.jetbrains:annotations:20.1.0'
175158
testCompileClasspath 'org.jetbrains:annotations:20.0.0'
176-
compile 'org.apache.commons:commons-compress:1.20'
177-
compile ('org.rnorth.duct-tape:duct-tape:1.0.8') {
159+
api 'org.apache.commons:commons-compress:1.20'
160+
api ('org.rnorth.duct-tape:duct-tape:1.0.8') {
178161
exclude(group: 'org.jetbrains', module: 'annotations')
179162
}
180163

181-
compile "com.github.docker-java:docker-java-api:3.2.8"
164+
api "com.github.docker-java:docker-java-api:3.2.8"
182165

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

198-
compile 'com.github.docker-java:docker-java-transport-zerodep:3.2.8'
181+
api 'com.github.docker-java:docker-java-transport-zerodep:3.2.8'
199182

200183
shaded "org.yaml:snakeyaml:1.27"
201184

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

208-
testCompile 'org.apache.httpcomponents:httpclient:4.5.9'
209-
testCompile 'redis.clients:jedis:3.6.0'
210-
testCompile 'com.rabbitmq:amqp-client:5.9.0'
211-
testCompile 'org.mongodb:mongo-java-driver:3.12.7'
191+
testImplementation 'org.apache.httpcomponents:httpclient:4.5.9'
192+
testImplementation 'redis.clients:jedis:3.6.0'
193+
testImplementation 'com.rabbitmq:amqp-client:5.9.0'
194+
testImplementation 'org.mongodb:mongo-java-driver:3.12.7'
212195

213-
testCompile ('org.mockito:mockito-core:3.10.0') {
196+
testImplementation ('org.mockito:mockito-core:3.10.0') {
214197
exclude(module: 'hamcrest-core')
215198
}
216199
// Synthetic JAR used for MountableFileTest and DirectoryTarResourceTest
217-
testCompile files('testlib/repo/fakejar/fakejar/0/fakejar-0.jar')
200+
testImplementation files('testlib/repo/fakejar/fakejar/0/fakejar-0.jar')
218201

219-
testCompile 'org.rnorth.visible-assertions:visible-assertions:2.1.2'
220-
testCompile 'org.assertj:assertj-core:3.18.1'
221-
testCompile project(':test-support')
202+
testImplementation 'org.rnorth.visible-assertions:visible-assertions:2.1.2'
203+
testImplementation 'org.assertj:assertj-core:3.18.1'
204+
testImplementation project(':test-support')
222205

223206
jarFileTestCompileOnly "org.projectlombok:lombok:${lombok.version}"
224207
jarFileTestAnnotationProcessor "org.projectlombok:lombok:${lombok.version}"
225-
jarFileTestCompile 'junit:junit:4.12'
226-
jarFileTestCompile 'org.assertj:assertj-core:3.18.1'
227-
jarFileTestCompile 'org.ow2.asm:asm-debug-all:5.2'
208+
jarFileTestImplementation 'junit:junit:4.12'
209+
jarFileTestImplementation 'org.assertj:assertj-core:3.18.1'
210+
jarFileTestImplementation 'org.ow2.asm:asm-debug-all:5.2'
228211
}
212+
213+
tasks.generatePomFileForMavenJavaPublication.finalizedBy(
214+
tasks.register('checkPOMdependencies', org.testcontainers.build.ComparePOMWithLatestReleasedTask) {
215+
ignore = [
216+
]
217+
}
218+
)

docs/examples/junit4/redis/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
description = "Examples for docs"
22

33
dependencies {
4-
compile "io.lettuce:lettuce-core:5.1.1.RELEASE"
4+
api "io.lettuce:lettuce-core:5.1.1.RELEASE"
55

66
testImplementation "junit:junit:4.12"
77
testImplementation project(":testcontainers")

docs/examples/junit5/redis/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
description = "Examples for docs"
22

33
dependencies {
4-
compile "io.lettuce:lettuce-core:5.1.1.RELEASE"
4+
api "io.lettuce:lettuce-core:5.1.1.RELEASE"
55

66
testImplementation "org.junit.jupiter:junit-jupiter-api:5.4.2"
77
testImplementation "org.junit.jupiter:junit-jupiter-params:5.4.2"

docs/examples/spock/redis/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
dependencies {
7-
compile "io.lettuce:lettuce-core:5.2.0.RELEASE"
7+
api "io.lettuce:lettuce-core:5.2.0.RELEASE"
88
testImplementation 'org.spockframework:spock-core:1.2-groovy-2.5'
99
testImplementation project(":spock")
1010
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

examples/kafka-cluster/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ repositories {
99
dependencies {
1010
testCompileOnly "org.projectlombok:lombok:1.18.20"
1111
testAnnotationProcessor "org.projectlombok:lombok:1.18.10"
12-
testCompile 'org.testcontainers:kafka'
13-
testCompile 'org.apache.kafka:kafka-clients:2.3.1'
14-
testCompile 'org.assertj:assertj-core:3.14.0'
15-
testCompile 'com.google.guava:guava:23.0'
16-
testCompile 'org.slf4j:slf4j-simple:1.7.30'
12+
testImplementation 'org.testcontainers:kafka'
13+
testImplementation 'org.apache.kafka:kafka-clients:2.3.1'
14+
testImplementation 'org.assertj:assertj-core:3.14.0'
15+
testImplementation 'com.google.guava:guava:23.0'
16+
testImplementation 'org.slf4j:slf4j-simple:1.7.30'
1717
}

0 commit comments

Comments
 (0)