Fix DependencyResolutionContext for multiple boms
The problem was that it was not accumulating DependencyManagement instances. It was throwing away the old ones and replacing with only the latest.
This commit is contained in:
@@ -44,18 +44,17 @@ public class DependencyResolutionContext {
|
||||
|
||||
private final List<Dependency> managedDependencies = new ArrayList<Dependency>();
|
||||
|
||||
private DependencyManagement dependencyManagement = new SpringBootDependenciesDependencyManagement();
|
||||
private DependencyManagement dependencyManagement = null;
|
||||
|
||||
private ArtifactCoordinatesResolver artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver(
|
||||
this.dependencyManagement);
|
||||
private ArtifactCoordinatesResolver artifactCoordinatesResolver;
|
||||
|
||||
public DependencyResolutionContext() {
|
||||
addDependencyManagement(this.dependencyManagement);
|
||||
addDependencyManagement(new SpringBootDependenciesDependencyManagement());
|
||||
}
|
||||
|
||||
private String getIdentifier(Dependency dependency) {
|
||||
return getIdentifier(dependency.getArtifact().getGroupId(), dependency
|
||||
.getArtifact().getArtifactId());
|
||||
return getIdentifier(dependency.getArtifact().getGroupId(),
|
||||
dependency.getArtifact().getArtifactId());
|
||||
}
|
||||
|
||||
private String getIdentifier(String groupId, String artifactId) {
|
||||
@@ -69,8 +68,8 @@ public class DependencyResolutionContext {
|
||||
public String getManagedVersion(String groupId, String artifactId) {
|
||||
Dependency dependency = getManagedDependency(groupId, artifactId);
|
||||
if (dependency == null) {
|
||||
dependency = this.managedDependencyByGroupAndArtifact.get(getIdentifier(
|
||||
groupId, artifactId));
|
||||
dependency = this.managedDependencyByGroupAndArtifact
|
||||
.get(getIdentifier(groupId, artifactId));
|
||||
}
|
||||
return dependency != null ? dependency.getArtifact().getVersion() : null;
|
||||
}
|
||||
@@ -98,19 +97,23 @@ public class DependencyResolutionContext {
|
||||
List<Exclusion> aetherExclusions = new ArrayList<Exclusion>();
|
||||
for (org.springframework.boot.cli.compiler.dependencies.Dependency.Exclusion exclusion : dependency
|
||||
.getExclusions()) {
|
||||
aetherExclusions.add(new Exclusion(exclusion.getGroupId(), exclusion
|
||||
.getArtifactId(), "*", "*"));
|
||||
aetherExclusions.add(new Exclusion(exclusion.getGroupId(),
|
||||
exclusion.getArtifactId(), "*", "*"));
|
||||
}
|
||||
Dependency aetherDependency = new Dependency(new DefaultArtifact(
|
||||
dependency.getGroupId(), dependency.getArtifactId(), "jar",
|
||||
dependency.getVersion()), JavaScopes.COMPILE, false, aetherExclusions);
|
||||
Dependency aetherDependency = new Dependency(
|
||||
new DefaultArtifact(dependency.getGroupId(),
|
||||
dependency.getArtifactId(), "jar", dependency.getVersion()),
|
||||
JavaScopes.COMPILE, false, aetherExclusions);
|
||||
this.managedDependencies.add(0, aetherDependency);
|
||||
this.managedDependencyByGroupAndArtifact.put(getIdentifier(aetherDependency),
|
||||
aetherDependency);
|
||||
}
|
||||
this.dependencyManagement = this.dependencyManagement == null
|
||||
? dependencyManagement
|
||||
: new CompositeDependencyManagement(dependencyManagement,
|
||||
this.dependencyManagement);
|
||||
this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver(
|
||||
new CompositeDependencyManagement(dependencyManagement,
|
||||
this.dependencyManagement));
|
||||
this.dependencyManagement);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user