Skip to content

Commit f56ac14

Browse files
committed
remove redundant build config and tighten test task setup
1 parent 1c57199 commit f56ac14

4 files changed

Lines changed: 58 additions & 45 deletions

File tree

build.gradle

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,16 @@ subprojects {
2323
}
2424

2525
dependencies {
26-
implementation platform(libs.spring.boot.bom)
27-
testImplementation platform(libs.spring.boot.bom)
28-
annotationProcessor platform(libs.spring.boot.bom)
26+
if (project.name != 'jsonrpc-core') {
27+
implementation platform(libs.spring.boot.bom)
28+
testImplementation platform(libs.spring.boot.bom)
29+
annotationProcessor platform(libs.spring.boot.bom)
30+
}
2931
testImplementation libs.junit.jupiter
3032
testRuntimeOnly libs.junit.platform.launcher
3133
compileOnly libs.jspecify
3234
}
3335

34-
def integrationTestSourceSet = sourceSets.create('integrationTest') {
35-
java.srcDir file('src/integrationTest/java')
36-
resources.srcDir file('src/integrationTest/resources')
37-
compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath
38-
runtimeClasspath += output + compileClasspath
39-
}
40-
def e2eTestSourceSet = sourceSets.create('e2eTest') {
41-
java.srcDir file('src/e2eTest/java')
42-
resources.srcDir file('src/e2eTest/resources')
43-
compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath
44-
runtimeClasspath += output + compileClasspath
45-
}
46-
47-
configurations {
48-
integrationTestImplementation.extendsFrom(testImplementation)
49-
integrationTestRuntimeOnly.extendsFrom(testRuntimeOnly)
50-
e2eTestImplementation.extendsFrom(testImplementation)
51-
e2eTestRuntimeOnly.extendsFrom(testRuntimeOnly)
52-
}
53-
5436
tasks.withType(JavaCompile).configureEach {
5537
options.encoding = 'UTF-8'
5638
options.compilerArgs += ['-parameters']
@@ -60,25 +42,56 @@ subprojects {
6042
useJUnitPlatform()
6143
}
6244

63-
tasks.register('integrationTest', Test) {
64-
description = 'Runs integration tests.'
65-
group = 'verification'
66-
testClassesDirs = integrationTestSourceSet.output.classesDirs
67-
classpath = integrationTestSourceSet.runtimeClasspath
68-
shouldRunAfter(tasks.named('test'))
69-
}
70-
71-
tasks.register('e2eTest', Test) {
72-
description = 'Runs end-to-end tests.'
73-
group = 'verification'
74-
testClassesDirs = e2eTestSourceSet.output.classesDirs
75-
classpath = e2eTestSourceSet.runtimeClasspath
76-
shouldRunAfter(tasks.named('integrationTest'))
45+
def hasIntegrationTestSources = file('src/integrationTest/java').exists() || file('src/integrationTest/resources').exists()
46+
if (hasIntegrationTestSources) {
47+
def integrationTestSourceSet = sourceSets.create('integrationTest') {
48+
java.srcDir file('src/integrationTest/java')
49+
resources.srcDir file('src/integrationTest/resources')
50+
compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath
51+
runtimeClasspath += output + compileClasspath
52+
}
53+
configurations {
54+
integrationTestImplementation.extendsFrom(testImplementation)
55+
integrationTestRuntimeOnly.extendsFrom(testRuntimeOnly)
56+
}
57+
tasks.register('integrationTest', Test) {
58+
description = 'Runs integration tests.'
59+
group = 'verification'
60+
testClassesDirs = integrationTestSourceSet.output.classesDirs
61+
classpath = integrationTestSourceSet.runtimeClasspath
62+
shouldRunAfter(tasks.named('test'))
63+
}
64+
tasks.named('check') {
65+
dependsOn(tasks.named('integrationTest'))
66+
}
7767
}
7868

79-
tasks.named('check') {
80-
dependsOn(tasks.named('integrationTest'))
81-
dependsOn(tasks.named('e2eTest'))
69+
def hasE2eTestSources = file('src/e2eTest/java').exists() || file('src/e2eTest/resources').exists()
70+
if (hasE2eTestSources) {
71+
def e2eTestSourceSet = sourceSets.create('e2eTest') {
72+
java.srcDir file('src/e2eTest/java')
73+
resources.srcDir file('src/e2eTest/resources')
74+
compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath
75+
runtimeClasspath += output + compileClasspath
76+
}
77+
configurations {
78+
e2eTestImplementation.extendsFrom(testImplementation)
79+
e2eTestRuntimeOnly.extendsFrom(testRuntimeOnly)
80+
}
81+
tasks.register('e2eTest', Test) {
82+
description = 'Runs end-to-end tests.'
83+
group = 'verification'
84+
testClassesDirs = e2eTestSourceSet.output.classesDirs
85+
classpath = e2eTestSourceSet.runtimeClasspath
86+
if (hasIntegrationTestSources) {
87+
shouldRunAfter(tasks.named('integrationTest'))
88+
} else {
89+
shouldRunAfter(tasks.named('test'))
90+
}
91+
}
92+
tasks.named('check') {
93+
dependsOn(tasks.named('e2eTest'))
94+
}
8295
}
8396

8497
publishing {

gradle/libs.versions.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
[versions]
22
spring-boot = "4.0.2"
33
jspecify = "1.0.0"
4+
jackson = "3.0.4"
5+
junit = "6.0.2"
46

57
[libraries]
68
spring-boot-bom = { module = "org.springframework.boot:spring-boot-dependencies", version.ref = "spring-boot" }
7-
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" }
8-
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" }
9-
jackson-databind = { module = "tools.jackson.core:jackson-databind" }
9+
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
10+
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit" }
11+
jackson-databind = { module = "tools.jackson.core:jackson-databind", version.ref = "jackson" }
1012
spring-web = { module = "org.springframework:spring-web" }
1113
spring-test = { module = "org.springframework:spring-test" }
1214
spring-webmvc = { module = "org.springframework:spring-webmvc" }

jsonrpc-spring-boot-autoconfigure/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ dependencies {
99

1010
testImplementation libs.spring.boot.starter.test
1111
testImplementation libs.spring.boot.starter.web
12-
testImplementation libs.micrometer.core
1312
}

samples/spring-boot-demo/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ repositories {
1919

2020
dependencies {
2121
implementation 'org.springframework.boot:spring-boot-starter-web'
22-
implementation 'org.springframework.boot:spring-boot-starter-jackson'
2322
implementation 'io.github.limehee:jsonrpc-spring-boot-starter:0.1.0-SNAPSHOT'
2423
testImplementation 'org.springframework.boot:spring-boot-starter-test'
2524
}

0 commit comments

Comments
 (0)