Skip to content

Commit 27a1369

Browse files
committed
build.gradle: use testing.suites{}, centralize test config
1 parent 43d1669 commit 27a1369

File tree

5 files changed

+30
-49
lines changed

5 files changed

+30
-49
lines changed

build.gradle

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,9 @@ allprojects {
4545
}
4646

4747
subprojects {
48-
// To support nativeTest, we are migrating away from all subprojects using Spock by default
49-
def spockLess = ["consensusj-jrpc", "consensusj-jrpc-echod"]
50-
boolean useSpock = !spockLess.contains(it.name)
5148

5249
dependencies {
5350
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
54-
55-
testImplementation platform("org.junit:junit-bom:${junitJupiterVersion}")
56-
57-
if (useSpock) {
58-
testImplementation "org.apache.groovy:groovy:${groovyVersion}"
59-
testImplementation("org.spockframework:spock-core:${spockVersion}") {
60-
exclude module: "groovy-all"
61-
}
62-
63-
testRuntimeOnly "org.junit.platform:junit-platform-launcher"
64-
testRuntimeOnly "net.bytebuddy:byte-buddy:1.17.7"
65-
// allows Spock to mock classes (in addition to interfaces)
66-
testRuntimeOnly "org.objenesis:objenesis:3.4"
67-
// Allow Spock to mock classes with constructor arguments
68-
testRuntimeOnly "org.slf4j:slf4j-jdk14:${slf4jVersion}" // Runtime implementation of slf4j
69-
}
7051
}
7152

7253
configurations.configureEach {
@@ -122,8 +103,36 @@ subprojects {
122103
options.noTimestamp = true
123104
}
124105

125-
tasks.withType(Test).configureEach {
126-
useJUnitPlatform() // We're using Spock 2 and JUnit 5
106+
// To support nativeTest, we are migrating away from having all subprojects use Spock by default
107+
def spockLess = ["consensusj-jrpc", "consensusj-jrpc-echod"]
108+
boolean useSpock = !spockLess.contains(it.name)
109+
110+
testing {
111+
suites {
112+
configureEach {
113+
useJUnitJupiter()
114+
dependencies {
115+
implementation platform("org.junit:junit-bom:${junitJupiterVersion}")
116+
117+
implementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}"
118+
runtimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}"
119+
120+
runtimeOnly "org.slf4j:slf4j-jdk14:${slf4jVersion}"
121+
122+
annotationProcessor "com.uber.nullaway:nullaway:${nullAwayVersion}"
123+
124+
if (useSpock) {
125+
implementation "org.apache.groovy:groovy:${groovyVersion}"
126+
implementation("org.spockframework:spock-core:${spockVersion}") {
127+
exclude module: "groovy-all"
128+
}
129+
130+
runtimeOnly "net.bytebuddy:byte-buddy:1.17.7" // Lets Spock mock classes (in addition to interfaces)
131+
runtimeOnly "org.objenesis:objenesis:3.4" // Lets Spock mock classes with constructor arguments
132+
}
133+
}
134+
}
135+
}
127136
}
128137
}
129138

cj-btc-cli/build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ dependencies {
2222

2323
// Add SLF4J runtime adapter for JDK logging for GraalVM native-image build of bitcoin CLI tool
2424
nativeToolImplementation "org.slf4j:slf4j-jdk14:${slf4jVersion}"
25-
26-
testImplementation "org.apache.groovy:groovy:${groovyVersion}"
27-
28-
testRuntimeOnly "org.slf4j:slf4j-jdk14:${slf4jVersion}"
2925
}
3026

3127
testing {

consensusj-jrpc/build.gradle

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,6 @@ tasks.withType(JavaCompile) {
4343

4444
testing {
4545
suites {
46-
configureEach {
47-
useJUnitJupiter()
48-
dependencies {
49-
implementation platform("org.junit:junit-bom:${junitJupiterVersion}")
50-
51-
implementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}"
52-
runtimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}"
53-
54-
runtimeOnly "org.slf4j:slf4j-jdk14:${slf4jVersion}"
55-
56-
annotationProcessor "com.uber.nullaway:nullaway:${nullAwayVersion}"
57-
}
58-
}
5946
integrationTest(JvmTestSuite) {
6047
dependencies {
6148
implementation project()

consensusj-jsonrpc-cli/build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ dependencies {
1414
api 'commons-cli:commons-cli:1.11.0'
1515

1616
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-toml:${jacksonVersion}"
17-
18-
testImplementation "org.apache.groovy:groovy:${groovyVersion}"
19-
testRuntimeOnly "org.slf4j:slf4j-jdk14:${slf4jVersion}"
2017
}
2118

2219
jar {

consensusj-jsonrpc/build.gradle

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@ dependencies {
1212

1313
testImplementation project(':cj-btc-jsonrpc')
1414

15-
testImplementation "org.apache.groovy:groovy:${groovyVersion}"
16-
testImplementation ("org.apache.groovy:groovy-json:${groovyVersion}") {
17-
transitive = false
18-
}
19-
20-
testRuntimeOnly "org.slf4j:slf4j-jdk14:${slf4jVersion}"
21-
2215
annotationProcessor "com.uber.nullaway:nullaway:${nullAwayVersion}"
23-
testAnnotationProcessor "com.uber.nullaway:nullaway:${nullAwayVersion}"
2416
errorprone "com.google.errorprone:error_prone_core:${errorProneVersion}"
2517
}
2618

0 commit comments

Comments
 (0)