-
Notifications
You must be signed in to change notification settings - Fork 89
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
resolve-test-dependencies fail to update classpath to use some optional transitive dependencies coming from hpi included in overrideWar #391
Conversation
…al transitive dependencies coming from hpi included in overrideWar Signed-off-by: Olivier Lamy <olamy@apache.org>
…rAdditions Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Olivier Lamy <olamy@apache.org>
Unfortunately even if this approach the problem is resolve dependencies |
src/main/java/org/jenkinsci/maven/plugins/hpi/JenkinsHpiDependencyCollector.java
Outdated
Show resolved
Hide resolved
src/main/java/org/jenkinsci/maven/plugins/hpi/JenkinsHpiDependencyCollector.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Olivier Lamy <olamy@apache.org>
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.
No description?
@@ -344,6 +354,9 @@ | |||
<pomIncludes> | |||
<pomInclude>*/pom.xml</pomInclude> | |||
</pomIncludes> | |||
<setupIncludes> | |||
<setupInclude>setup_test-dependencies-transitive-optional-dep/pom.xml</setupInclude> |
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.
Does this really need to be done this way, or can you just do everything in one dir using a multimodule reactor?
<id>copy-jenkins-war</id> | ||
<phase>process-resources</phase> | ||
<goals> | ||
<goal>copy</goal> |
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.
This does not look anything like a real plugin POM so I am struggling to follow what bug this IT purports to reproduce.
but optional dependencies are not transitive so should not be present at all (so should not need updating). |
no of course optional dependencies are not transitive. But it looks there are some discrepancies between Jenkins plugins system (in PCT only?) and Maven dependencies (as you can read them in poms). What I can see from the current case (issue from jenkinsci/bom#3049) before
after
As we can think, optional is not transitive when running |
In general, if you need to delve into this kind of detail, you should switch to |
root cause of this is jenkinsci/bom#3231 |
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.
Given that the essence of all the changes to TestDependencyMojo
has been covered in other PRs, is there any reason to keep this PR open?
DependencyCollectorRequest dependencyCollectorRequest = | ||
new DependencyCollectorRequest(buildingRequest) | ||
.dependencySelector(new AndDependencySelector( | ||
new DirectScopeDependencySelector(JavaScopes.TEST), | ||
new DirectScopeDependencySelector(JavaScopes.PROVIDED))); | ||
node = dependencyCollectorBuilder.collectDependencyGraph(dependencyCollectorRequest); |
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.
Included in #673:
List<org.eclipse.aether.graph.Dependency> dependencies = shadow.getDependencies().stream()
.filter(d -> !d.isOptional())
.filter(d -> !List.of(Artifact.SCOPE_TEST, Artifact.SCOPE_PROVIDED)
.contains(d.getScope()))
.map(d -> RepositoryUtils.toDependency(d, artifactTypeRegistry))
.collect(Collectors.toList());
@@ -328,7 +335,7 @@ public void execute() throws MojoExecutionException { | |||
continue; | |||
} | |||
|
|||
getLog().debug("Copying " + artifactId + " as a test dependency"); | |||
getLog().debug("Copying " + artifactId + ":" + a.getVersion() + " as a test dependency"); |
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.
Included in #462:
getLog().debug("Copying " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + " as a test dependency");
pairs = new ArrayList<>(); | ||
keyToPairsMap.put(key, pairs); | ||
} | ||
List<DependencyNodeHopCountPair> pairs = keyToPairsMap.computeIfAbsent(key, s -> new ArrayList<>()); |
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.
Included in #402:
List<DependencyNodeHopCountPair> pairs = keyToPairsMap.computeIfAbsent(key, unused -> new ArrayList<>());
if (hopPair.getHopCount() < resolvedPair.getHopCount()) { | ||
if (hopPair.getHopCount() < resolvedPair.getHopCount() || | ||
// we can have dependencies with similar hop count but one is optional and the other not | ||
// Maven will use the non optional even if the version is higher | ||
(hopPair.getHopCount() == resolvedPair.getHopCount() && | ||
resolvedPair.getNode().getArtifact().isOptional()) && | ||
!hopPair.getNode().getArtifact().isOptional()) { |
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.
Deleted upstream and so also deleted in #673.
good to see the changes have been integrated smoothly via other PRs |
jenkinsci#3158 provides the fundamental information for the pull request. jenkinsci/maven-hpi-plugin#391 provides additional commentary. Also removes trailing spaces from lines in the file.
#3158 provides the fundamental information for the pull request. jenkinsci/maven-hpi-plugin#391 provides additional commentary. Also removes trailing spaces from lines in the file.
Signed-off-by: Olivier Lamy olamy@apache.org