After updating to Spring Boot 2.6.X (with Spring Cloud 2021.0.0) we are missing org.apiguardian:apiguardian-api which should be included in 5.8.1 (https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api/5.8.1) which results in a lot of warnings.
Reverting to Spring Boot 2.5.4 and Cloud 2020.0.4 fixes the issue.
+--- org.springframework.boot:spring-boot-starter-test -> 2.5.4
| +--- org.junit.jupiter:junit-jupiter:5.7.2
| | +--- org.junit:junit-bom:5.7.2
| | | +--- org.junit.jupiter:junit-jupiter:5.7.2 (c)
| | | +--- org.junit.jupiter:junit-jupiter-api:5.7.2 (c)
| | | +--- org.junit.jupiter:junit-jupiter-engine:5.7.2 (c)
| | | +--- org.junit.jupiter:junit-jupiter-params:5.7.2 (c)
| | | +--- org.junit.platform:junit-platform-commons:1.7.2 (c)
| | | \--- org.junit.platform:junit-platform-engine:1.7.2 (c)
| | +--- org.junit.jupiter:junit-jupiter-api:5.7.2
| | | +--- org.junit:junit-bom:5.7.2 (*)
| | | +--- org.apiguardian:apiguardian-api:1.1.0
| | | +--- org.opentest4j:opentest4j:1.2.0
| | | \--- org.junit.platform:junit-platform-commons:1.7.2
| | | +--- org.junit:junit-bom:5.7.2 (*)
+--- org.springframework.boot:spring-boot-starter-test -> 2.6.1
| +--- org.junit.jupiter:junit-jupiter:5.8.1
| | +--- org.junit:junit-bom:5.8.1
| | | +--- org.junit.jupiter:junit-jupiter:5.8.1 (c)
| | | +--- org.junit.jupiter:junit-jupiter-api:5.8.1 (c)
| | | +--- org.junit.jupiter:junit-jupiter-engine:5.8.1 (c)
| | | +--- org.junit.jupiter:junit-jupiter-params:5.8.1 (c)
| | | +--- org.junit.platform:junit-platform-commons:1.8.1 (c)
| | | \--- org.junit.platform:junit-platform-engine:1.8.1 (c)
| | +--- org.junit.jupiter:junit-jupiter-api:5.8.1
| | | +--- org.junit:junit-bom:5.8.1 (*)
| | | +--- org.opentest4j:opentest4j:1.2.0
| | | \--- org.junit.platform:junit-platform-commons:1.8.1
| | | \--- org.junit:junit-bom:5.8.1 (*)
Using Gradle 7
plugins {
id 'org.springframework.boot' version '2.6.0'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
apply from: 'componentTestPlugin.gradle'
apply from: 'captureTestdataPlugin.gradle'
sourceCompatibility = '17'
jar.enabled = false
bootRun {
jvmArgs(
[
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'--add-opens', 'java.base/java.net=ALL-UNNAMED',
'--add-opens', 'java.management/java.lang.management=ALL-UNNAMED',
])
}
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
repositories {
maven { url resolveRepoUrl }
}
dependencies {
implementation enforcedPlatform('org.springframework.cloud:spring-cloud-dependencies:2021.0.0')
// Spring boot dependenices
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
// Monitoring
implementation 'org.springframework.cloud:spring-cloud-sleuth-zipkin'
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'io.micrometer:micrometer-registry-influx'
//Custom dependencies
implementation 'org.springdoc:springdoc-openapi-ui:1.5.13'
//test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'com.h2database:h2:2.0.202'
}
test {
useJUnitPlatform()
}
}
Comment From: wilkinsona
The scope of the API guardian dependency was changed in JUnit 5.8. It will now only appear on the compile classpath. This was an intentional change as the dependency should not be needed at runtime.
The Gradle script that you have provided illustrates this behaviour. The dependency appears on the test compile classpath:
$ gradle dependencyInsight --configuration testCompileClasspath --dependency apiguardian
> Task :dependencyInsight
org.apiguardian:apiguardian-api:1.1.2
variant "apiElements" [
org.gradle.category = library
org.gradle.dependency.bundling = external
org.gradle.jvm.version = 6 (compatible with: 17)
org.gradle.libraryelements = jar (compatible with: classes)
org.gradle.usage = java-api
org.gradle.status = release (not requested)
Requested attributes not found in the selected variant:
org.gradle.jvm.environment = standard-jvm
]
org.apiguardian:apiguardian-api:1.1.2
+--- org.junit.jupiter:junit-jupiter-api:5.8.1
| +--- org.junit.jupiter:junit-jupiter-params:5.8.1
| | +--- org.junit:junit-bom:5.8.1
| | | +--- org.junit.jupiter:junit-jupiter-params:5.8.1 (*)
| | | +--- org.junit.jupiter:junit-jupiter-api:5.8.1 (*)
| | | +--- org.junit.platform:junit-platform-commons:1.8.1
| | | | +--- org.junit.jupiter:junit-jupiter-api:5.8.1 (*)
| | | | \--- org.junit:junit-bom:5.8.1 (*)
| | | \--- org.junit.jupiter:junit-jupiter:5.8.1
| | | +--- org.springframework.boot:spring-boot-starter-test:2.6.0
| | | | \--- testCompileClasspath (requested org.springframework.boot:spring-boot-starter-test)
| | | \--- org.junit:junit-bom:5.8.1 (*)
| | \--- org.junit.jupiter:junit-jupiter:5.8.1 (*)
| +--- org.junit:junit-bom:5.8.1 (*)
| \--- org.junit.jupiter:junit-jupiter:5.8.1 (*)
+--- org.junit.jupiter:junit-jupiter-params:5.8.1 (*)
\--- org.junit.platform:junit-platform-commons:1.8.1 (*)
(*) - dependencies omitted (listed previously)
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 881ms
1 actionable task: 1 executed
It does not, however, appear on the test runtime classpath:
$ gradle dependencyInsight --configuration testRuntimeClasspath --dependency apiguardian
> Task :dependencyInsight
No dependencies matching given input were found in configuration ':testRuntimeClasspath'
BUILD SUCCESSFUL in 864ms
1 actionable task: 1 executed
You'll see the same behaviour if you depend upon org.junit.jupiter:junit-jupiter:5.8.1
directly without using spring-boot-starter-test
. In other words, the problem that you have reported is out of Spring Boot's control. Also, the change in JUnit should not cause a problem for consumers as the API Guardian dependency should only be needed at compile time.
Comment From: Zanndorin
Apparently I only read the "short" changelog which didn't include the large "Breaking changes"
Thanks!