Posterous theme by Cory Watilo

GMaven Projects in NetBeans

I recently decided to shift some of my Groovy code library projects from NetBeans class library projects to GMaven projects.  My motivations for doing this were first of all to teach myself more about Maven, which has been on my to-do list for a while, and secondly to take advantage of Maven's dependancy resolution features.  Some of my projects have quite large dependancy graphs, and it gets a little tiresome managing them manually.

The first step is to create a new Maven Project in NetBeans, selecting "GMaven Archetypes :: Basic (1.0-rc-3)" as the archetype to use.  Once you've completed the project information dialog, a GMaven template project is created for you.  The next thing to do is to go into the Project Properties, set the correct name for your project, set Packaging to "jar", and set the correct Souce/Binary format and encoding.

Next, the generated pom.xml file will need a little tweaking to get the project to build correctly.  Here's the basic configuration I settled on:

Once the basic setup is complete, you can add your projects source and test packages to "Groovy Packages" and "Groovy Test Packages" respectively.  Project dependencies and repositories can be now be configured as per a regular Maven project.

To compile, test, and install your project jar to your local repository in one fell swoop, simply run NetBeans' Build command (F11).  Your project jar is now available for reference as a dependency in your other Maven-managed projects.