Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.quarkus.domino.scm.ScmRevisionResolver;
import io.quarkus.maven.dependency.ArtifactCoords;
import io.quarkus.maven.dependency.ArtifactKey;
import io.quarkus.maven.dependency.GACT;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;
Expand Down Expand Up @@ -286,6 +287,7 @@ public static Builder builder() {

private Function<ArtifactCoords, List<Dependency>> artifactConstraintsProvider;
private Set<ArtifactCoords> allConstraints;
private Map<GACT, ArtifactCoords> allConstraintsByGa;
private Set<ArtifactCoords> projectBomConstraints;
private final Map<ArtifactCoords, ResolvedDependency> allDepsToBuild = new HashMap<>();
private final Set<ArtifactCoords> nonManagedVisited = new HashSet<>();
Expand Down Expand Up @@ -382,15 +384,14 @@ public <T> T applyToSorted(Function<Collection<ReleaseRepo>, T> func) {

public void log() {
try {
resolveDependenciesInternal();
logInternal();
} finally {
close();
}
}

void logInternal() {

resolveDependenciesInternal();
int codeReposTotal = 0;
int reportedArtifactsTotal = 0;
if ((config.isLogArtifactsToBuild()
Expand Down Expand Up @@ -625,7 +626,7 @@ private static Set<ArtifactCoords> toArtifactCoords(Collection<Dependency> deps)
for (var d : deps) {
result.add(toCoords(d.getArtifact()));
}
return result;
return Collections.unmodifiableSet(result);
}

public void resolveDependencies() {
Expand All @@ -643,6 +644,17 @@ void resolveDependenciesInternal() {
enforcedConstraints.addAll(getBomConstraints(bomCoords));
}
allConstraints = toArtifactCoords(enforcedConstraints);
allConstraintsByGa = Collections.unmodifiableMap(
allConstraints.stream()
.collect(
HashMap::new,
(m, gav) -> m.put(new GACT(
gav.getGroupId(),
gav.getArtifactId(),
gav.getClassifier(),
gav.getType()),
gav),
(m1, m2) -> m1.putAll(m2)));
if (artifactConstraintsProvider == null) {
artifactConstraintsProvider = t -> enforcedConstraints;
}
Expand Down Expand Up @@ -997,8 +1009,7 @@ private void configureReleaseRepoDeps() {
}
for (Dependency directDep : descriptor.getDependencies()) {
final Artifact a = directDep.getArtifact();
final ArtifactDependency dirArt = artifactDeps.get(ArtifactCoords.of(a.getGroupId(), a.getArtifactId(),
a.getClassifier(), a.getExtension(), a.getVersion()));
final ArtifactDependency dirArt = artifactDeps.get(toManagedCoords(a));
if (dirArt != null) {
d.addDependency(dirArt);
}
Expand All @@ -1014,6 +1025,16 @@ private void configureReleaseRepoDeps() {
}
}

private ArtifactCoords toManagedCoords(Artifact a) {
final ArtifactCoords managed = allConstraintsByGa.get(new GACT(a.getGroupId(), a.getArtifactId(),
a.getClassifier(), a.getExtension()));
if (managed != null) {
return managed;
}
return ArtifactCoords.of(a.getGroupId(), a.getArtifactId(),
a.getClassifier(), a.getExtension(), a.getVersion());
}

private ScmRevision getRevision(ArtifactCoords coords, List<RemoteRepository> repos) {
final ScmRevision revision;
if (this.preResolvedRootArtifacts.containsKey(coords)) {
Expand Down Expand Up @@ -1712,4 +1733,5 @@ private static GAV toGav(ArtifactCoords coords) {
private static ArtifactCoords toCoords(Artifact a) {
return ArtifactCoords.of(a.getGroupId(), a.getArtifactId(), a.getClassifier(), a.getExtension(), a.getVersion());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void completeTree() {
assertThat(rc.getReleases()).hasSize(4);

var roots = toMap(rc.getRootReleaseRepos());
assertThat(roots).hasSize(2);
assertThat(roots).hasSize(1);

var release = roots.get(ReleaseIdFactory.forScmAndTag("https://acme.org/lib", "1.0"));
assertThat(release).isNotNull();
Expand All @@ -115,10 +115,9 @@ public void completeTree() {
assertThat(release.getArtifacts()).hasSize(2);
assertThat(release.getArtifacts()).containsKey(ArtifactCoords.pom("org.bar", "bar-parent", "1.0"));
assertThat(release.getArtifacts()).containsKey(ArtifactCoords.jar("org.bar", "bar-lib", "1.0"));
assertThat(release.getDependencies()).isEmpty();
assertThat(release.getDependencies()).hasSize(1);

release = roots.get(ReleaseIdFactory.forScmAndTag("https://foo.org/lib", "2.0"));
assertThat(release).isNotNull();
release = release.getDependencies().iterator().next();
assertThat(release.getArtifacts()).hasSize(1);
assertThat(release.getArtifacts()).containsKey(ArtifactCoords.jar("org.foo", "foo-lib", "2.0"));
assertThat(release.getDependencies()).hasSize(1);
Expand Down Expand Up @@ -147,7 +146,7 @@ public void onlyManaged() {
assertThat(rc.getReleases()).hasSize(3);

var roots = toMap(rc.getRootReleaseRepos());
assertThat(roots).hasSize(2);
assertThat(roots).hasSize(1);
var release = roots.get(ReleaseIdFactory.forScmAndTag("https://acme.org/lib", "1.0"));
assertThat(release).isNotNull();
assertThat(release.getArtifacts()).hasSize(4);
Expand All @@ -162,9 +161,9 @@ public void onlyManaged() {
assertThat(release.getArtifacts()).hasSize(2);
assertThat(release.getArtifacts()).containsKey(ArtifactCoords.pom("org.bar", "bar-parent", "1.0"));
assertThat(release.getArtifacts()).containsKey(ArtifactCoords.jar("org.bar", "bar-lib", "1.0"));
assertThat(release.getDependencies()).isEmpty();
assertThat(release.getDependencies()).hasSize(1);

release = roots.get(ReleaseIdFactory.forScmAndTag("https://foo.org/lib", "2.0"));
release = release.getDependencies().iterator().next();
assertThat(release).isNotNull();
assertThat(release.getArtifacts()).hasSize(1);
assertThat(release.getArtifacts()).containsKey(ArtifactCoords.jar("org.foo", "foo-lib", "2.0"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ static void prepareRepo() {
.setTag("1.0");
var byteUtilsLib = byteUtilsProject.createMainModule("byte-utils");

var commonsIoProject = TestProject.of("org.commons.io", "1.0")
var commonsIoProject10 = TestProject.of("org.commons.io", "1.0")
.setRepoUrl("https://commons.org/code/io")
.setTag("1.0");
var commonsIoLib = commonsIoProject.createMainModule("commons-io")
var commonsIoLib10 = commonsIoProject10.createMainModule("commons-io")
.addDependency(byteUtilsLib);

var commonsIoProject09 = TestProject.of("org.commons.io", "0.9")
.setRepoUrl("https://commons.org/code/io")
.setTag("0.9");
var commonsIoLib09 = commonsIoProject09.createMainModule("commons-io")
.addDependency(byteUtilsLib);

var quarkusProject = TestProject.of("io.quarkus", "1.0")
Expand All @@ -52,7 +58,7 @@ static void prepareRepo() {
var quarkusBuildParent = quarkusParent.addPomModule("quarkus-build-parent")
.importBom(quarkusBom);
var quarkusCore = quarkusBuildParent.addModule("quarkus-core")
.addDependency(commonsIoLib);
.addDependency(commonsIoLib09);

var filesLibProject = TestProject.of("org.files", "1.0")
.setRepoUrl("https://files.org/code")
Expand All @@ -73,7 +79,7 @@ static void prepareRepo() {
.addVersionConstraint("camel-core")
.addVersionConstraint("camel-xml-lib")
.addVersionConstraint(xmlLib)
.addVersionConstraint(commonsIoLib);
.addVersionConstraint(commonsIoLib10);
var camelBuildParent = camelParent.addPomModule("camel-build-parent")
.importBom(camelBom);
var camelCore = camelBuildParent.addModule("camel-core")
Expand All @@ -86,7 +92,8 @@ static void prepareRepo() {
.install(camelProject)
.install(filesLibProject)
.install(xmlLibProject)
.install(commonsIoProject)
.install(commonsIoProject10)
.install(commonsIoProject09)
.install(byteUtilsProject);

releaseAssertions = Map.<ScmRevision, Consumer<ReleaseRepo>> of(
Expand All @@ -101,6 +108,8 @@ static void prepareRepo() {
.containsKey(ArtifactCoords.pom("io.quarkus", "quarkus-build-parent", "1.0"));
assertThat(release.getArtifacts()).containsKey(ArtifactCoords.jar("io.quarkus", "quarkus-core", "1.0"));
assertThat(release.getDependencies()).hasSize(1);
assertThat(release.getDependencies().iterator().next().artifacts)
.containsKey(ArtifactCoords.jar("org.commons.io", "commons-io", "1.0"));
},
ReleaseIdFactory.forScmAndTag("https://camel.org/code", "1.0"),
release -> {
Expand Down
Loading