Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Gradle 7 #4171

Merged
merged 9 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
}
}
86 changes: 50 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,55 @@ 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(
// The task is a bit more generic that it needs to be, but we may consider applying it to other modules too
tasks.register('checkPOMdependencies') {
doLast {
def rootNode = new XmlSlurper().parse(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() }

Set<String> whitelist = [
]

for (dependency in rootNode.dependencies.children()) {
def coordinates = "${dependency.groupId.text()}:${dependency.artifactId.text()}".toString()
if (!dependencies.contains(coordinates) && !whitelist.contains(coordinates)) {
throw new IllegalStateException("New dependency! ${coordinates}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this exception message more helpful for contributors?

e.g.

Suggested change
throw new IllegalStateException("New dependency! ${coordinates}")
throw new IllegalStateException("A new dependency has been added ${coordinates} - if this was intentional please add it to the whitelist in PATH_TO_GRADLE_FILE")

What do we expect the process to be - do we need to be approving new dependencies somehow?

BTW I think it would be good to move this to a separate .gradle file, so that areas of major scripting are encapsulated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! We could, yes 👍
FYI this message is mostly for us, maintainers, as the chance of an external dependency added by external contributors is super low

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted and made the message more user friendly 👍

}
}
}
}
)
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.18.1'
testImplementation 'org.assertj:assertj-core:3.18.1'
}
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.1018'
testCompile 'com.amazonaws:aws-java-sdk-dynamodb:1.11.929'
testImplementation 'com.amazonaws:aws-java-sdk-dynamodb:1.11.929'

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.12.1"
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.12.1"
testImplementation "org.elasticsearch.client:transport:7.12.1"
testImplementation 'org.rnorth.visible-assertions:visible-assertions:2.1.2'
}
14 changes: 7 additions & 7 deletions modules/gcloud/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
description = "Testcontainers :: GCloud"

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

testCompile 'com.google.cloud:google-cloud-datastore:1.102.4'
testCompile 'com.google.cloud:google-cloud-firestore:1.33.0'
testCompile 'com.google.cloud:google-cloud-pubsub:1.105.0'
testCompile 'com.google.cloud:google-cloud-spanner:1.50.0'
testCompile 'com.google.cloud:google-cloud-bigtable:1.17.3'
testCompile 'org.assertj:assertj-core:3.15.0'
testImplementation 'com.google.cloud:google-cloud-datastore:1.102.4'
testImplementation 'com.google.cloud:google-cloud-firestore:1.33.0'
testImplementation 'com.google.cloud:google-cloud-pubsub:1.105.0'
testImplementation 'com.google.cloud:google-cloud-spanner:1.50.0'
testImplementation 'com.google.cloud:google-cloud-bigtable:1.17.3'
testImplementation 'org.assertj:assertj-core:3.15.0'
}
4 changes: 2 additions & 2 deletions modules/influxdb/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
description = "Testcontainers :: InfluxDB"

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

compileOnly 'org.influxdb:influxdb-java:2.21'
testCompile 'org.influxdb:influxdb-java:2.21'
testImplementation 'org.influxdb:influxdb-java:2.21'
}
Loading