2020import io .quarkus .domino .scm .ScmRevisionResolver ;
2121import io .quarkus .maven .dependency .ArtifactCoords ;
2222import io .quarkus .maven .dependency .ArtifactKey ;
23+ import io .quarkus .maven .dependency .GACT ;
2324import java .io .IOException ;
2425import java .io .PrintStream ;
2526import java .nio .file .Files ;
@@ -286,6 +287,7 @@ public static Builder builder() {
286287
287288 private Function <ArtifactCoords , List <Dependency >> artifactConstraintsProvider ;
288289 private Set <ArtifactCoords > allConstraints ;
290+ private Map <GACT , ArtifactCoords > allConstraintsByGa ;
289291 private Set <ArtifactCoords > projectBomConstraints ;
290292 private final Map <ArtifactCoords , ResolvedDependency > allDepsToBuild = new HashMap <>();
291293 private final Set <ArtifactCoords > nonManagedVisited = new HashSet <>();
@@ -625,7 +627,7 @@ private static Set<ArtifactCoords> toArtifactCoords(Collection<Dependency> deps)
625627 for (var d : deps ) {
626628 result .add (toCoords (d .getArtifact ()));
627629 }
628- return result ;
630+ return Collections . unmodifiableSet ( result ) ;
629631 }
630632
631633 public void resolveDependencies () {
@@ -643,6 +645,17 @@ void resolveDependenciesInternal() {
643645 enforcedConstraints .addAll (getBomConstraints (bomCoords ));
644646 }
645647 allConstraints = toArtifactCoords (enforcedConstraints );
648+ allConstraintsByGa = Collections .unmodifiableMap (
649+ allConstraints .stream ()
650+ .collect (
651+ HashMap ::new ,
652+ (m , gav ) -> m .put (new GACT (
653+ gav .getGroupId (),
654+ gav .getArtifactId (),
655+ gav .getClassifier (),
656+ gav .getType ()),
657+ gav ),
658+ (m1 , m2 ) -> m1 .putAll (m2 )));
646659 if (artifactConstraintsProvider == null ) {
647660 artifactConstraintsProvider = t -> enforcedConstraints ;
648661 }
@@ -997,8 +1010,7 @@ private void configureReleaseRepoDeps() {
9971010 }
9981011 for (Dependency directDep : descriptor .getDependencies ()) {
9991012 final Artifact a = directDep .getArtifact ();
1000- final ArtifactDependency dirArt = artifactDeps .get (ArtifactCoords .of (a .getGroupId (), a .getArtifactId (),
1001- a .getClassifier (), a .getExtension (), a .getVersion ()));
1013+ final ArtifactDependency dirArt = artifactDeps .get (toManagedCoords (a ));
10021014 if (dirArt != null ) {
10031015 d .addDependency (dirArt );
10041016 }
@@ -1014,6 +1026,16 @@ private void configureReleaseRepoDeps() {
10141026 }
10151027 }
10161028
1029+ private ArtifactCoords toManagedCoords (Artifact a ) {
1030+ final ArtifactCoords managed = allConstraintsByGa .get (new GACT (a .getGroupId (), a .getArtifactId (),
1031+ a .getClassifier (), a .getExtension ()));
1032+ if (managed != null ) {
1033+ return managed ;
1034+ }
1035+ return ArtifactCoords .of (a .getGroupId (), a .getArtifactId (),
1036+ a .getClassifier (), a .getExtension (), a .getVersion ());
1037+ }
1038+
10171039 private ScmRevision getRevision (ArtifactCoords coords , List <RemoteRepository > repos ) {
10181040 final ScmRevision revision ;
10191041 if (this .preResolvedRootArtifacts .containsKey (coords )) {
@@ -1712,4 +1734,5 @@ private static GAV toGav(ArtifactCoords coords) {
17121734 private static ArtifactCoords toCoords (Artifact a ) {
17131735 return ArtifactCoords .of (a .getGroupId (), a .getArtifactId (), a .getClassifier (), a .getExtension (), a .getVersion ());
17141736 }
1737+
17151738}
0 commit comments