Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experiment] Leave out dep from depMgmt #1613

Closed
wants to merge 1 commit into from
Closed
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
Experiment: leave out dep from depMgmt
As dep is "stronger" anyway, on conflict resolution will
win.
  • Loading branch information
cstamas committed Jul 11, 2024
commit 9db1bfb3b0af4c7d1796d05d0a337165af25e2b1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 21,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -60,14 61,18 @@ public void populateResult(InternalSession session, ArtifactDescriptorResult res
session.getService(RepositoryFactory.class).createRemote(r)));
}

HashSet<String> dependencyKeys = new HashSet<>(model.getDependencies().size());
for (org.apache.maven.api.model.Dependency dependency : model.getDependencies()) {
result.addDependency(convert(dependency, stereotypes));
dependencyKeys.add(dependency.getManagementKey());
}

DependencyManagement mgmt = model.getDependencyManagement();
if (mgmt != null) {
for (org.apache.maven.api.model.Dependency dependency : mgmt.getDependencies()) {
result.addManagedDependency(convert(dependency, stereotypes));
if (!dependencyKeys.contains(dependency.getManagementKey())) {
result.addManagedDependency(convert(dependency, stereotypes));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 21,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -58,14 59,18 @@ public void populateResult(RepositorySystemSession session, ArtifactDescriptorRe
result.addRepository(ArtifactDescriptorUtils.toRemoteRepository(r));
}

HashSet<String> dependencyKeys = new HashSet<>(model.getDependencies().size());
for (org.apache.maven.model.Dependency dependency : model.getDependencies()) {
result.addDependency(convert(dependency, stereotypes));
dependencyKeys.add(dependency.getManagementKey());
}

DependencyManagement mgmt = model.getDependencyManagement();
if (mgmt != null) {
for (org.apache.maven.model.Dependency dependency : mgmt.getDependencies()) {
result.addManagedDependency(convert(dependency, stereotypes));
if (!dependencyKeys.contains(dependency.getManagementKey())) {
result.addManagedDependency(convert(dependency, stereotypes));
}
}
}

Expand Down