-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Runtime artifact's POM repos aren't propagated to resolve the deployment deps #3289
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,7 +221,11 @@ public DependencyResult resolveDependencies(Artifact artifact) throws AppModelRe | |
} | ||
|
||
public CollectResult collectDependencies(Artifact artifact, List<Dependency> deps) throws AppModelResolverException { | ||
final CollectRequest request = newCollectRequest(artifact); | ||
return collectDependencies(artifact, deps, Collections.emptyList()); | ||
} | ||
|
||
public CollectResult collectDependencies(Artifact artifact, List<Dependency> deps, List<RemoteRepository> mainRepos) throws AppModelResolverException { | ||
final CollectRequest request = newCollectRequest(artifact, mainRepos); | ||
request.setDependencies(deps); | ||
try { | ||
return repoSystem.collectDependencies(repoSession, request); | ||
|
@@ -231,7 +235,11 @@ public CollectResult collectDependencies(Artifact artifact, List<Dependency> dep | |
} | ||
|
||
public DependencyResult resolveDependencies(Artifact artifact, List<Dependency> deps) throws AppModelResolverException { | ||
final CollectRequest request = newCollectRequest(artifact); | ||
return resolveDependencies(artifact, deps, Collections.emptyList()); | ||
} | ||
|
||
public DependencyResult resolveDependencies(Artifact artifact, List<Dependency> deps, List<RemoteRepository> mainRepos) throws AppModelResolverException { | ||
final CollectRequest request = newCollectRequest(artifact, mainRepos); | ||
request.setDependencies(deps); | ||
try { | ||
return repoSystem.resolveDependencies(repoSession, | ||
|
@@ -254,7 +262,7 @@ public DependencyResult resolveDependencies(Artifact artifact, String... exclude | |
deps.add(dep); | ||
} | ||
} | ||
final List<RemoteRepository> requestRepos = remoteRepoManager.aggregateRepositories(repoSession, remoteRepos, descr.getRepositories(), true); | ||
final List<RemoteRepository> requestRepos = aggregateRepositories(remoteRepos, newResolutionRepositories(descr.getRepositories())); | ||
try { | ||
return repoSystem.resolveDependencies(repoSession, | ||
new DependencyRequest().setCollectRequest( | ||
|
@@ -269,24 +277,32 @@ public DependencyResult resolveDependencies(Artifact artifact, String... exclude | |
} | ||
|
||
public DependencyResult resolveManagedDependencies(Artifact artifact, List<Dependency> deps, List<Dependency> managedDeps, String... excludedScopes) throws AppModelResolverException { | ||
return resolveManagedDependencies(artifact, deps, managedDeps, Collections.emptyList(), excludedScopes); | ||
} | ||
|
||
public DependencyResult resolveManagedDependencies(Artifact artifact, List<Dependency> deps, List<Dependency> managedDeps, List<RemoteRepository> mainRepos, String... excludedScopes) throws AppModelResolverException { | ||
try { | ||
return repoSystem.resolveDependencies(repoSession, | ||
new DependencyRequest().setCollectRequest( | ||
newCollectManagedRequest(artifact, deps, managedDeps, excludedScopes))); | ||
newCollectManagedRequest(artifact, deps, managedDeps, mainRepos, excludedScopes))); | ||
} catch (DependencyResolutionException e) { | ||
throw new AppModelResolverException("Failed to resolve dependencies for " + artifact, e); | ||
} | ||
} | ||
|
||
public CollectResult collectManagedDependencies(Artifact artifact, List<Dependency> deps, List<Dependency> managedDeps, String... excludedScopes) throws AppModelResolverException { | ||
return collectManagedDependencies(artifact, deps, managedDeps, Collections.emptyList(), excludedScopes); | ||
} | ||
|
||
public CollectResult collectManagedDependencies(Artifact artifact, List<Dependency> deps, List<Dependency> managedDeps, List<RemoteRepository> mainRepos, String... excludedScopes) throws AppModelResolverException { | ||
try { | ||
return repoSystem.collectDependencies(repoSession, newCollectManagedRequest(artifact, deps, managedDeps, excludedScopes)); | ||
return repoSystem.collectDependencies(repoSession, newCollectManagedRequest(artifact, deps, managedDeps, mainRepos, excludedScopes)); | ||
} catch (DependencyCollectionException e) { | ||
throw new AppModelResolverException("Failed to collect dependencies for " + artifact, e); | ||
} | ||
} | ||
|
||
private CollectRequest newCollectManagedRequest(Artifact artifact, List<Dependency> deps, List<Dependency> managedDeps, String... excludedScopes) throws AppModelResolverException { | ||
private CollectRequest newCollectManagedRequest(Artifact artifact, List<Dependency> deps, List<Dependency> managedDeps, List<RemoteRepository> mainRepos, String... excludedScopes) throws AppModelResolverException { | ||
final ArtifactDescriptorResult descr = resolveDescriptor(artifact); | ||
Collection<String> excluded; | ||
if(excludedScopes.length == 0) { | ||
|
@@ -325,11 +341,20 @@ private CollectRequest newCollectManagedRequest(Artifact artifact, List<Dependen | |
} | ||
} | ||
|
||
final List<RemoteRepository> repos = aggregateRepositories(mainRepos, remoteRepos); | ||
return new CollectRequest() | ||
.setRootArtifact(artifact) | ||
.setDependencies(mergeDeps(deps, originalDeps, managedVersions)) | ||
.setManagedDependencies(mergedManagedDeps) | ||
.setRepositories(remoteRepoManager.aggregateRepositories(repoSession, remoteRepos, descr.getRepositories(), true)); | ||
.setRepositories(aggregateRepositories(repos, newResolutionRepositories(descr.getRepositories()))); | ||
} | ||
|
||
public List<RemoteRepository> newResolutionRepositories(List<RemoteRepository> repos) { | ||
return repos.isEmpty() ? Collections.emptyList() : repoSystem.newResolutionRepositories(repoSession, repos); | ||
} | ||
|
||
public List<RemoteRepository> aggregateRepositories(List<RemoteRepository> dominant, List<RemoteRepository> recessive) { | ||
return dominant.isEmpty() ? recessive : remoteRepoManager.aggregateRepositories(repoSession, dominant, recessive, false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In which case do we have dominant and recessive repositories? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That occurs naturally in any Maven project given that there is a hierarchy of POMs each of which may include repositories. Since during tests we, unfortunately, loose the Maven build context, we have to initialize repos the Maven way ourselves, taking the repos from the default settings and then merging them into the target project's repos. Repos from the project's POM will be dominating. |
||
} | ||
|
||
public void install(Artifact artifact) throws AppModelResolverException { | ||
|
@@ -340,10 +365,10 @@ public void install(Artifact artifact) throws AppModelResolverException { | |
} | ||
} | ||
|
||
private CollectRequest newCollectRequest(Artifact artifact) throws AppModelResolverException { | ||
private CollectRequest newCollectRequest(Artifact artifact, List<RemoteRepository> mainRepos) throws AppModelResolverException { | ||
return new CollectRequest() | ||
.setRoot(new Dependency(artifact, JavaScopes.RUNTIME)) | ||
.setRepositories(remoteRepos); | ||
.setRepositories(aggregateRepositories(mainRepos, remoteRepos)); | ||
} | ||
|
||
private List<Dependency> mergeDeps(List<Dependency> dominant, List<Dependency> recessive, Map<AppArtifactKey, String> managedVersions) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to bother you with my dumb questions but trying to understand what's going on to make a real review :).
Why exactly do we exclude the test scope when in dev mode and not in the other modes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an app is compiled, every scope except
test
is available, which maps to our dev mode and that's how it's reflected in our code.However, when the application is packaged
provided
andtest
scopes are filtered out by default. So, in that case, I am delegating to the default Maven resolver config that is taking care of that.