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
[MNG-6357] Dependency order should be nearest first #281
base: master
Are you sure you want to change the base?
Conversation
Please review this patch. Tested it and seems to solve: |
Looks good at first sight. This code deserves a unittest, that's better than relying on plugins. I don't think the unittest is too hard to write. |
@rfscholte We have more serious problems that introducing fancy Java 8 features. |
@@ -112,6 +113,27 @@ private static String nullify( String string ) | |||
public static void toArtifacts( Collection<org.apache.maven.artifact.Artifact> artifacts, | |||
Collection<? extends DependencyNode> nodes, List<String> trail, | |||
DependencyFilter filter ) | |||
{ | |||
Map<Integer, List<org.apache.maven.artifact.Artifact>> artifactsByDepth = | |||
new TreeMap<Integer, List<org.apache.maven.artifact.Artifact>>(); |
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.
you can use diamond <>
. It is Java 1.7 feature.
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.
If i open IDEA, it shows me these issues related to Java version.
Map<Integer, List<org.apache.maven.artifact.Artifact>> artifactsByDepth = | ||
new TreeMap<Integer, List<org.apache.maven.artifact.Artifact>>(); | ||
|
||
ArrayList<org.apache.maven.artifact.Artifact> firstLevelArtifacts = |
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.
aaa, Collection
or List
better than ArrayList.
new TreeMap<Integer, List<org.apache.maven.artifact.Artifact>>(); | ||
|
||
ArrayList<org.apache.maven.artifact.Artifact> firstLevelArtifacts = | ||
new ArrayList<org.apache.maven.artifact.Artifact>( nodes.size() ); |
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.
same here
List<org.apache.maven.artifact.Artifact> artifactsCurrentDepth = artifactsByDepth.get( currentDepth ); | ||
if ( artifactsCurrentDepth == null ) | ||
{ | ||
artifactsCurrentDepth = new ArrayList<org.apache.maven.artifact.Artifact>(); |
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.
same here
The merge conflict is pretty straight-forward to fix (it's a simple collision in the pom.xml). Would love to see this go in! Happy to provide a new PR if that's preferable |
Save the artifacts temporarily in a Map ordered by tree depth, and only after finishing iterating over the dependency tree are the artifacts added to the collection in depth order.
- used diamond <> operator. - changed ArrayList for List in variable declaration. - Added unit test.
- Re added maven-resolver-test-util as a test dependency. - Changed tests to JUnit 5.
Per https://maven.apache.org/download.cgi Maven 4.x requires JDK 8. What is needed to move this PR forward? |
Save the artifacts temporarily in a Map ordered by tree depth, and only
after finishing iterating over the dependency tree are the artifacts
added to the collection in depth order.
Note: IT-core test needs to be added replacing IT 3813 which does not apply any longer for a maven version containing this change.
Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MNG-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MNG-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verify
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.