This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 212530 - Ability to set a sort order for dependencies (for maven projects)
Summary: Ability to set a sort order for dependencies (for maven projects)
Status: RESOLVED INVALID
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.2
Hardware: PC Linux
: P3 normal (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-15 13:07 UTC by pcornelissen
Modified: 2012-05-18 14:59 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
duplicate dependencies (4.75 KB, image/png)
2012-05-18 13:18 UTC, pcornelissen
Details
First screenful of Mercurial plugin's dependencies (31.56 KB, image/png)
2012-05-18 14:59 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pcornelissen 2012-05-15 13:07:55 UTC
It's pretty hard to find a dependency in the project tree if the project has many (transitive) dependencies. The order looks somehow random and you have to search through the whole list of dependencies.
it would be really nice to be able to sort them alphabetically by name (or maybe by "group id" and then by "artifact id" in case of maven deps)
Comment 1 Jesse Glick 2012-05-17 19:47:44 UTC
Not sure exactly how this would work. Currently we show dependencies in natural order as returned from the model, which would be direct dependencies first in POM order, then transitive dependencies (maybe via breadth-first traversal?). If resorting the list, presumably you would still want to keep direct dependencies at the top. And this cannot I think be the default, since it would lose information: the current view shows how the classpath will be constructed, which could matter in case two artifacts contain a class of the same name.
Comment 2 pcornelissen 2012-05-18 13:00:31 UTC
Hmm, well so the current way also has its merits...

The reason I'd like to have this is so I can quickly see multiple versions of the same lib (which is currently pretty hard, because everything is so cluttered in the dependencies subtree) and to browse through a specific dependency.

Maybe you can think of another way of achieving this?

Maybe another small list window with sort and browse capability?
Comment 3 Milos Kleint 2012-05-18 13:08:51 UTC
(In reply to comment #2)
> The reason I'd like to have this is so I can quickly see multiple versions of
> the same lib (which is currently pretty hard, because everything is so
> cluttered in the dependencies subtree) and to browse through a specific
> dependency.
> 

Can you elaborate more on the usecase? in my understanding you can always have just one version of any library in the resolved dependencies only. Always just one version wins for a given artifact, or the build fails if ranges required don't overlap.

might not be what you want but if you start typing in the projects explorer with dependencies node expanded, the first node matching your query will be selected.
Comment 4 pcornelissen 2012-05-18 13:18:03 UTC
Created attachment 119615 [details]
duplicate dependencies
Comment 5 pcornelissen 2012-05-18 13:18:47 UTC
Hi!

Well, I have proof in front of me ;-)
(Although due to NDAs I can't share it with you. At least I made a small screenshot...)

I have a project that depends on another Project, both define a dependency to a certain lib in different versions.
The result was that I had two versions of the lib in the dependencies subtree.
It compiled and worked as far as I could see, but I excluded the other dependency afterwards to avoid problems.

The find as you type hint is good, I didn't knew that!
Comment 6 Milos Kleint 2012-05-18 13:23:58 UTC
fine, on the UI side it's possible mainly because we show the artifactId in view, but 2 distinct artifacts can have the same artifactId but different groupId.
Comment 7 pcornelissen 2012-05-18 13:26:44 UTC
OMG, you are right...
One package belongs to another group id.
Sorry for the disturbance, I need to go to hit the developer responsible for the name with a large bat... ;-)
Comment 8 pcornelissen 2012-05-18 13:27:07 UTC
sorry
Comment 9 Jesse Glick 2012-05-18 14:57:13 UTC
In fact it seems the IDE already _does_ sort dependencies by artifactId, with direct first. DependenciesNode.DependenciesComparator has:

boolean transitive1 = art1.getArtifact().getDependencyTrail().size() > 2;
boolean transitive2 = art2.getArtifact().getDependencyTrail().size() > 2;
if (transitive1 && !transitive2) {
    return 1;
}
if (!transitive1 && transitive2)  {
    return -1;
}
int ret = art1.getArtifact().getArtifactId().compareTo(art2.getArtifact().getArtifactId());
if (ret != 0) {
    return ret;
}
return art1.getArtifact().compareTo(art2.getArtifact());

Tested on Hudson/Jenkins plugin for Mercurial, which has more than a screenful of dependencies, and it seemed reasonable.
Comment 10 Jesse Glick 2012-05-18 14:59:38 UTC
Created attachment 119620 [details]
First screenful of Mercurial plugin's dependencies