Skip to content

Commit cf066b6

Browse files
committed
chore: update build.gradle - someone with more experience in testing should look over it .... @tidycode 👉👈
1 parent abb092d commit cf066b6

File tree

1 file changed

+36
-63
lines changed

1 file changed

+36
-63
lines changed

build.gradle

Lines changed: 36 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,28 @@ plugins {
2727
id 'jacoco'
2828
}
2929

30-
repositories {
31-
mavenCentral()
30+
group = 'com.interguess'
31+
version = 'unknown'
32+
33+
java {
34+
toolchain {
35+
languageVersion = JavaLanguageVersion.of(21)
36+
}
3237
}
3338

3439
jacoco {
3540
toolVersion = '0.8.12'
3641
}
3742

38-
group 'com.interguess'
39-
version 'unknown'
43+
repositories {
44+
mavenCentral()
45+
}
46+
47+
def junitPlatformVersion = '1.13.3'
48+
def junitJupiterVersion = '5.13.3'
49+
def opentest4jVersion = '1.3.0'
50+
def lombokVersion = '1.18.38'
51+
def mockitoVersion = '5.18.0'
4052

4153
subprojects {
4254
apply plugin: 'java'
@@ -47,56 +59,34 @@ subprojects {
4759
}
4860

4961
dependencies {
50-
testImplementation platform('org.junit:junit-bom:5.13.3')
51-
testImplementation 'org.junit.jupiter:junit-jupiter'
52-
53-
// Plattform-Module explizit hinzufügen
54-
testImplementation 'org.junit.platform:junit-platform-engine:1.13.3'
55-
testImplementation 'org.junit.platform:junit-platform-launcher:1.13.3'
56-
testImplementation 'org.junit.platform:junit-platform-commons:1.13.3'
57-
58-
testAnnotationProcessor 'org.projectlombok:lombok:1.18.38'
59-
60-
testImplementation 'org.mockito:mockito-core:5.18.0'
61-
testImplementation 'org.mockito:mockito-junit-jupiter:5.18.0'
62-
63-
testImplementation('com.google.testing.compile:compile-testing:0.21.0') {
64-
exclude group: 'junit', module: 'junit'
62+
testImplementation platform("org.junit:junit-bom:$junitJupiterVersion")
63+
testImplementation "org.junit.jupiter:junit-jupiter"
64+
testImplementation "org.junit.platform:junit-platform-engine:$junitPlatformVersion"
65+
testImplementation "org.junit.platform:junit-platform-launcher:$junitPlatformVersion"
66+
testImplementation "org.junit.platform:junit-platform-commons:$junitPlatformVersion"
67+
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
68+
testImplementation "org.mockito:mockito-core:$mockitoVersion"
69+
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion"
70+
testImplementation('com.google.testing.compile:compile-testing:0.21.0') {
71+
exclude group: 'junit', module: 'junit'
72+
}
6573
}
66-
}
67-
6874

69-
// Erzwinge gleiche Versionen für JUnit-Komponenten
7075
configurations.all {
7176
resolutionStrategy.eachDependency { details ->
7277
if (details.requested.group == 'org.junit.platform') {
73-
details.useVersion '1.13.3'
74-
details.because 'Align all JUnit Platform modules to same version to avoid discovery errors'
78+
details.useVersion junitPlatformVersion
7579
}
7680
if (details.requested.group == 'org.junit.jupiter') {
77-
details.useVersion '5.13.3'
78-
details.because 'Align all JUnit Jupiter modules to same version'
81+
details.useVersion junitJupiterVersion
7982
}
8083
if (details.requested.group == 'org.opentest4j') {
81-
details.useVersion '1.3.0'
82-
details.because 'Compatible version for JUnit 5.13.3'
84+
details.useVersion opentest4jVersion
8385
}
8486
}
85-
86-
// JUnit Vintage Engine ausschließen
8787
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
8888
}
8989

90-
jacoco {
91-
toolVersion = '0.8.12'
92-
}
93-
94-
java {
95-
toolchain {
96-
languageVersion = JavaLanguageVersion.of(21)
97-
}
98-
}
99-
10090
test {
10191
useJUnitPlatform()
10292
finalizedBy jacocoTestReport
@@ -115,40 +105,23 @@ subprojects {
115105
}
116106
}
117107

118-
java {
119-
toolchain {
120-
languageVersion = JavaLanguageVersion.of(21)
121-
}
122-
}
123-
124108
tasks.named('test') {
125109
useJUnitPlatform()
110+
126111
javaLauncher.set(javaToolchains.launcherFor {
127112
languageVersion = JavaLanguageVersion.of(21)
128113
})
129114
}
130115

131-
task jacocoRootReport(type: JacocoReport) {
116+
tasks.register('jacocoRootReport', JacocoReport) {
132117
dependsOn subprojects.jacocoTestReport
133118

134-
def coverageSourceDirs = files()
135-
def classDirs = files()
136-
def execFiles = files()
137-
138-
subprojects.each { subproject ->
139-
coverageSourceDirs += subproject.sourceSets.main.allSource.srcDirs
140-
classDirs += subproject.sourceSets.main.output
141-
execFiles += fileTree(dir: subproject.buildDir, includes: [
142-
'jacoco/test.exec'
143-
])
144-
}
145-
146-
sourceDirectories.setFrom coverageSourceDirs
147-
classDirectories.setFrom classDirs
148-
executionData.setFrom execFiles
119+
sourceDirectories.setFrom files(subprojects.collect { it.sourceSets.main.allSource.srcDirs }.flatten())
120+
classDirectories.setFrom files(subprojects.collect { it.sourceSets.main.output }.flatten())
121+
executionData.setFrom files(subprojects.collect { fileTree(dir: it.buildDir, includes: ['jacoco/test.exec']) })
149122

150123
reports {
151124
html.required = true
152125
xml.required = true
153126
}
154-
}
127+
}

0 commit comments

Comments
 (0)