From 8e704aab48bc3d3f80cb366584c78409a0330bac Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 14 Oct 2021 17:38:05 -0700 Subject: [PATCH] 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 --- .../classpath/CheckClasspathForUnnecessaryExclusions.java | 7 +++++++ .../spring-boot-starter-test/build.gradle | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForUnnecessaryExclusions.java b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForUnnecessaryExclusions.java index c03f7fae9c..797f2df3fb 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForUnnecessaryExclusions.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForUnnecessaryExclusions.java @@ -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 exclusions) { + if ("org.xmlunit:xmlunit-core".equals(dependencyId)) { + exclusions.remove("javax.xml.bind:jaxb-api"); + } + } + private String getExceptionMessage(Map> unnecessaryExclusions) { StringBuilder message = new StringBuilder("Unnecessary exclusions detected:"); for (Entry> entry : unnecessaryExclusions.entrySet()) { diff --git a/spring-boot-project/spring-boot-starters/spring-boot-starter-test/build.gradle b/spring-boot-project/spring-boot-starters/spring-boot-starter-test/build.gradle index 12ba82f587..74ba78aab0 100644 --- a/spring-boot-project/spring-boot-starters/spring-boot-starter-test/build.gradle +++ b/spring-boot-project/spring-boot-starters/spring-boot-starter-test/build.gradle @@ -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" + } }