Reputation: 3016
Suppose a set of simple projects, A, B, C, each needing to use the same common project Z. All parts are under ongoing development.
So we add project Z as a library to A, B and C.
As example details: Class A has a single method, main(). Class Z is a simple JFrame-based form. Z includes NB IDE's default main() to instantiate the form, so it can be run separately, but, in example use, A.main() calls Z.main() to show the form.
This works fine for a simple form in class Z.
However, suppose we add components to class Z's form from SwingX or other non-standard libraries. This auto adds corresponding library dependencies to project Z. We can test Z by running Z.main() directly -- works fine. However if we now recompile and run A.main(), an exception is thrown: can't find the SwingX (or whatever) library.
This can be made to work by adding Z's dependencies also to A. So the issue appears to be that this mechanism to add some project as a library doesn't take care of adding the dependencies of that other library/project.
What's the right solution to this?
Netbeans 7.2, using ANT.
May be a duplicate of these similar questions that lack checked answers:
add other projects as library in netbeans
Netbeans - Add library that is currently being edited
Upvotes: 4
Views: 3786
Reputation: 3016
The subject of this question is covered in this NetBeans bug report: Bug 47507 - [40cat] Transitively required libraries not automatically added to runtime classpath
Somewhat incredibly, this has been active for over eight years, and subject to 19 duplicate issues. There is a lengthy thread of discussions attached to the issue. There is one moderately useful workaround, by user "fommil" on 2008-01-10:
"my workaround is that for every "[depended-upon library] project" I define a library in the Library Manager called "library.dep". Here is where I define the classpath, sources and javadocs for that project's dependencies. Then if another project ever depends on "project", I add "project.dep" to its runtime (and test runtime) dependencies."
fommil goes on to discuss shortcomings of that approach, but perhaps it's better than nothing.
Anyhow, I'm going to declare this question "answered", even if not "solved".
Upvotes: 3