Restore 'javax.xml.bind:jaxb-api' exclusion

Restore the 'javax.xml.bind:jaxb-api' exclusion from `xmlunit-core`
which is actually required when using Maven on Java 9+.

The `CheckClasspathForUnnecessaryExclusions` cannot deal with profile
specific dependencies so an exception has been hard coded.

See gh-28332
This commit is contained in:
Phillip Webb 2021-10-14 17:38:05 -07:00
parent e95b0b5257
commit 8e704aab48
2 changed files with 10 additions and 1 deletions

View File

@ -109,6 +109,7 @@ public class CheckClasspathForUnnecessaryExclusions extends DefaultTask {
.getIncoming().getArtifacts().getArtifacts().stream().map(this::getId)
.collect(Collectors.toList());
exclusions.removeAll(dependencies);
removeProfileExclusions(dependencyId, exclusions);
if (!exclusions.isEmpty()) {
unnecessaryExclusions.put(dependencyId, exclusions);
}
@ -119,6 +120,12 @@ public class CheckClasspathForUnnecessaryExclusions extends DefaultTask {
}
}
private void removeProfileExclusions(String dependencyId, Set<String> exclusions) {
if ("org.xmlunit:xmlunit-core".equals(dependencyId)) {
exclusions.remove("javax.xml.bind:jaxb-api");
}
}
private String getExceptionMessage(Map<String, Set<String>> unnecessaryExclusions) {
StringBuilder message = new StringBuilder("Unnecessary exclusions detected:");
for (Entry<String, Set<String>> entry : unnecessaryExclusions.entrySet()) {

View File

@ -18,5 +18,7 @@ dependencies {
api("org.skyscreamer:jsonassert")
api("org.springframework:spring-core")
api("org.springframework:spring-test")
api("org.xmlunit:xmlunit-core")
api("org.xmlunit:xmlunit-core") {
exclude group: "javax.xml.bind", module: "jaxb-api"
}
}