Skip to content

Commit 37508f4

Browse files
committed
Prefer conflict-resolved maven dependencies
The AbstractResolveDependencies class, when building a list of Maven dependencies to check, will now use the "getRelatedArtifact" method if it is available. This will return the coalesced version of an artifact when there is a conflict between dependencies with the same groupId and artifactId, but different versions. This fixes the BanDuplicateClasses to no longer detect conflicts between multiple versions of the same GA combination.
1 parent 900c7eb commit 37508f4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/org/scijava/maven/plugin/enforcer/AbstractResolveDependencies.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ else if ( node.getChildren() != null )
119119
dependencies = new HashSet<Artifact>();
120120
for( DependencyNode depNode : node.getChildren() )
121121
{
122-
dependencies.add( depNode.getArtifact() );
122+
dependencies.add( getResolvedArtifact(depNode) );
123123
}
124124
}
125125
}
@@ -141,7 +141,7 @@ private Set<Artifact> getAllDescendants( DependencyNode node )
141141
{
142142
try
143143
{
144-
Artifact artifact = depNode.getArtifact();
144+
Artifact artifact = getResolvedArtifact(depNode);
145145

146146
resolver.resolve( artifact, remoteRepositories, localRepository );
147147

@@ -167,6 +167,12 @@ private Set<Artifact> getAllDescendants( DependencyNode node )
167167
return children;
168168
}
169169

170+
private Artifact getResolvedArtifact(DependencyNode depNode) {
171+
// Use the getRelatedArtifact if there was a resolved conflict.
172+
return depNode.getRelatedArtifact() == null ?
173+
depNode.getArtifact() : depNode.getRelatedArtifact();
174+
}
175+
170176
protected Log getLog()
171177
{
172178
return helper.getLog();

0 commit comments

Comments
 (0)