My blog has moved!

You should automatically be redirected in 6 seconds. If not, visit
http://blogs.i2m.dk/allan
and update your bookmarks.

Wednesday 19 March 2008

Shared libraries finally made it to NetBeans

Today I installed NetBeans 6.1 beta. I've always been a great fan of NetBeans and participated in the Community Acceptance Testing programme (NetCAT) for version 4.0 and 6.0.

I haven't had time to go through all the changes yet, but one thing caught my attention immediately, the "Shared Library" functionality. It has always amazed me that this feature was not implemented way sooner. I have never used the built-in library manager for third-party libraries as the information about the libraries were not included with the projects, i.e. when I create a third-party library in the Library manager for say Apache Commons Configuration and use that in my project, it will break the built for not only other developers by also my continuous integration server. The alternative is to simply add the third-party library directly to the project as jars. The downside about that is that you can't attach the source and JavaDocs, so the inline code completion becomes almost useless. A third alternative is to manage dependencies completely outside of the IDE using Ant and Maven build scripts. I use to do this when using Eclipse, however then you have to update the dependencies in both the IDE and the build script = twice the work.

Back to NetBeans 6.1. When creating a project you now get the offer to enable "sharable libraries". When enabling this feature you are asked to specify the location where the libraries should be saved. By default it will suggest ..\libraries, which is a bit strange considering that it is outside the project folder. I guess it depends on the configuration management practices used on the project. Personally I always check in third-party libraries (as long as there are no licensing issues preventing it). In that way I alaways know that I can build the software anywhere on any machine (that includes my CI box).



After having enabled sharable libraries, NetBeans will automatically copy library to the specified folder when you add dependencies to your project. Furthermore, if you find out that you'd rather have your sharable libraries in a different location, you can simply change the location click "Save" and it will re-create the sharable libraries. Very neat!

I can imagine that they will continue working on the feature at NetBeans and this feature will become even better before the next release.

5 comments:

Anonymous said...

BTW in 6.1 you can already attach source+javadoc to single jars on classpath, no need to create a library solely for this purpose.

Allan Lykke Christensen said...

Ah that's great, thanks for the info! However, I think I'll stick to the library manager now that shared libraries functionality has been implemented. It will save me time when working on multiple projects.

Anonymous said...

switch to maven and you won't have this problem either. Maven 2 rocks!

Allan Lykke Christensen said...

Actually I've used Maven 2 for quite some time, however, prior to version 6.0 the support in NetBeans was pretty poor. I might just switch back again now that there is official Maven support.

Anonymous said...

I'll second that. The Mevenide plug-in is really top-notch. Now there are still a few irksome aspects when dealing with multi-module projects, but over-all its worth it. Try it now.