NetBeans Quick Tip #16 - Using Dependent Projects
One NetBeans user asked me recently by e-mail when will NetBeans support dependent projects. So I replied how to define dependencies and asked if he wanted more from this features... and the reply was no, he just didn't know that the feature exists! So here's a tip for people who didn't find it yet, hopefully easily accessible via Google (which puts texts from blogs on top of search results).
Why would you want to use dependent projects? If your project gets big enough it is a good idea to divide it into smaller projects. By dividing them this way your code can be better structured by separating logical parts into individual projects. However if you do this, you need to define in first project how to access classes from the second project.
For Java SE projects this is quite straightforward, go to properties of the main project (right-click on the project and choose properties). Go to the Libraries section and choose Add Project. Now you need to find the project folder on your disk and by selecting it, the project's jar is added to the compile classpath:
If you compile the main project then all dependent projects are checked if they are up-to-date and any updated classes they contain are compiled as well.
There are other advantages of having dependent projects, especially if you work in a team, it's handy to have the projects divided than to work on one big project, because people can work on each of them separately. The only drawback I know of is that speed of compilation is slower if you divide your projects too much and define too many dependencies, then compiling the main project takes longer because NetBeans has to check status of all dependent projects.
Note that for NetBeans plug-in projects the dependence mechanism is quite different - either you depend on one of the NetBeans modules or you define dependence on an external library.
Is there a way to add a dependency project that is a non-netbeans project with an Ant script? In other words, can I define the jar location and an Ant target to run? Or do I have to edit the dependent project's build.xml?
Posted by Greg Trasuk on listopad 06, 2005 at 05:46 odp. CET #
Posted by Roumen on listopad 06, 2005 at 05:50 odp. CET #
Posted by Greg Trasuk on listopad 07, 2005 at 01:44 dop. CET #
Posted by Roumen on listopad 07, 2005 at 10:39 dop. CET #
Posted by David Caldwell on listopad 07, 2005 at 06:22 odp. CET #
Posted by Charles Simon on listopad 14, 2005 at 07:14 odp. CET #
Posted by Matthieu on únor 18, 2006 at 02:07 odp. CET #