Netbeans doesn't see packages inside a .jar generated with Maven plugin Shade.
Project using such jar compiles correctly in both embedded and external Maven, but code completion fail with "Package
xxx does not exist".
Created attachment 74779 [details]
Simple test project
Created attachment 74780 [details]
Simple test project
I uploaded a simple project to demonstrate it. Part 1 is the application, part 3 is some 3rd party library, part 2 is
supposed to merge a couple 3rd party libraries and their dependencies into a single jar.
Compiling and running does work. Code completion - doesn't. So I guess it's something in Netbeans.
I should mention I'm still pretty new to Maven - it could be my fault, I could have written something that partially
works or works but is very non-standard. But then it shouldn't work at all?
Also, the tooltip for part 2 in Maven Explorer window looks a bit strange - packaging null, and where's the "GroupId"
text? It would imply Netbeans isn't detecting that jar correctly?
Created attachment 74781 [details]
Created attachment 74782 [details]
Any ideas what could cause it? Or at least if the bug is in Netbeans, Maven, or my pom?
not really a bug anywhere I'd say, more likely a feature not supported by netbeans. not sure yet it it *can* be supported.
1. The pom of shadetest1_2 is different in repository and sources, specifically the dependency section. Therefor the 1_3
project never, ever appears on the classpath on 3rd party projects that use 1_2.
2. The IDE relies on keeping track of opened projects and re-routing the source-for-binary queries for local repository
binaries. That's essential to features like: I do change in project A, and the IDE marks all classes in project B as
3. if the shadetest1_2 project is opened or otherwise accessible to the IDE (might not be directly opened, just
references by an opened project), we reroute the classpath to the project to get the uptodate state of 1_2. However that
one misses out the sources for 1_3, as these are hidden in 1_2 binary.
we might try putting both live sources and repository sources on classpath, but that needs to be deeply investigated, it
could have nasty side-effects.
According to last comment and due to lack of user feedback changing to RFE.
Reassigning to default owner.
The only thing I can think to do is to report preferSources=false from SourceForBinaryQuery on a repository artifact built using Shade. Thus Ctrl-B etc. would work but changes made in the upstream project would not be immediately reflected in the downstream project's code completion - you would need to install upstream first. Dependencies on projects not using Shade would be unaffected.
Integrated into 'main-golden'
User: Jesse Glick <email@example.com>
Log: #155091: Netbeans doesn't see packages inside a .jar generated with Maven plugin Shade
Treat an artifact from a project using Shade as preferred to its sources, unless shadedArtifactAttached=true.