@@ -99,6 +99,7 @@ public ProjectDependencyAnalysis analyze(MavenProject project, Collection<String
99
99
Map <Artifact , Set <DependencyUsage >> usedUndeclaredArtifactsWithClasses = new LinkedHashMap <>(usedArtifacts );
100
100
Set <Artifact > usedUndeclaredArtifacts =
101
101
removeAll (usedUndeclaredArtifactsWithClasses .keySet (), declaredArtifacts );
102
+
102
103
usedUndeclaredArtifactsWithClasses .keySet ().retainAll (usedUndeclaredArtifacts );
103
104
104
105
Set <Artifact > unusedDeclaredArtifacts = new LinkedHashSet <>(declaredArtifacts );
@@ -242,7 +243,7 @@ private static Map<Artifact, Set<DependencyUsage>> buildUsedArtifacts(
242
243
for (DependencyUsage classUsage : dependencyClasses ) {
243
244
Artifact artifact = findArtifactForClassName (artifactClassMap , classUsage .getDependencyClass ());
244
245
245
- if (artifact != null ) {
246
+ if (artifact != null && ! includedInJDK ( artifact ) ) {
246
247
Set <DependencyUsage > classesFromArtifact = usedArtifacts .get (artifact );
247
248
if (classesFromArtifact == null ) {
248
249
classesFromArtifact = new HashSet <>();
@@ -255,6 +256,21 @@ private static Map<Artifact, Set<DependencyUsage>> buildUsedArtifacts(
255
256
return usedArtifacts ;
256
257
}
257
258
259
+ // MSHARED-47 an uncommon case where a commonly used
260
+ // third party dependency was added to the JDK
261
+ private static boolean includedInJDK (Artifact artifact ) {
262
+ if ("xml-apis" .equals (artifact .getGroupId ())) {
263
+ if ("xml-apis" .equals (artifact .getArtifactId ())) {
264
+ return true ;
265
+ }
266
+ } else if ("xerces" .equals (artifact .getGroupId ())) {
267
+ if ("xmlParserAPIs" .equals (artifact .getArtifactId ())) {
268
+ return true ;
269
+ }
270
+ }
271
+ return false ;
272
+ }
273
+
258
274
private static Artifact findArtifactForClassName (Map <Artifact , Set <String >> artifactClassMap , String className ) {
259
275
for (Map .Entry <Artifact , Set <String >> entry : artifactClassMap .entrySet ()) {
260
276
if (entry .getValue ().contains (className )) {
0 commit comments