Monday, 11 April 2011

GMaven Archetype – minor fixes

I became so irritated by the bugs in the GMaven archetype that I decided to do something about it.  There is a link somewhere below to a BitBucket project containing my fixed-up version of 1.4.  The rest of this piece describes what got me so annoyed and what I did about it.

To see the problems, create a new Maven project using the archetype “GMaven Archetypes :: Basic”, the latest version being, as far as I can tell,1.3.  The Maven coordinates are:

GroupId: org.codehaus.gmaven.archetypes
ArtifactId: gmaven-archetype-basic
Version: 1.3

You can find it on this page in the mvnrepository site. The three big issues are:

  1. Project coordinates entered by user are not used in the generated project.  The generated project’s coordinates are just copies of the archetype’s coordinates.
  2. Generated stub source-files have syntax errors.  Once you have generated the project, look at the source files in GroovyTestPackages.  e.g. HelperTest.groovy. The package declaration appears after the import statements and the import statements need to qualify the classes fully.
  3. GMaven depends on a rather old version of Groovy (1.6.9) and the GMaven runtime (1.6-1.3, which I think means v1.3 of the runtime built against Groovy 1.6).

These problems have been picked up by other folk – I eventually discovered that issues have already been raised in Codehaus JIRA for these. See:

This project attempts to fix these, plus updates some dependencies to bring the generated project up to date, notably the Groovy runtime (to 1.7.10) and JUnit (to 4.7).  These are small changes, but make the archetype much more convenient to use.

Currently, the fixed version of 1.4-SNAPSHOT is distinguished only by the archetype description – look for “(fixed)” in the description text.  If I’ve made these changes correctly then I’ll contribute to the next official release.  (Not sure exactly how I submit them for approval).

If you’re using NetBeans (if you’re not, then I do recommend you give it a try), the first-class Maven support extends to creating new projects from Maven archetypes. Below is how the fixed archetype will appear, once imported into your local repository:


In the next stage of project creation, NetBeans will prompt you for the Maven coordinates for your new artifact, and also for a project name, which is an ‘additional property’ shown at the bottom of the dialog:


In the fixed archetype, all of these properties are correctly processed. The resulting NetBeans project will carry the name assigned in the additional property and use the coordinates you assign here. 

Update: there is another important change to the prototype POM (src\main\filtered-resources\archetype-resources\pom.xml) which I missed in the original posting.  In order to use a newer version of Groovy, it’s necessary to exclude the older version from the gmaven-runtime dependency in the gmaven-plugin, and include a dependency on the version of Groovy used in the rest of the POM.

The code is available from the gmaven-archetype-basic project in my BitBucket repository. You can download a zip from there or pull from the Mercurial repository:

hg clone

I hope this is some help to others. I’m keen to hear whether the small changes I made are fully correct and consistent as I’m still relatively new to Maven. If the changes are OK then I’d be happy to push / checkin to Codehaus.

Technorati Tags: ,,,

Sunday, 3 April 2011

HAPI v1.1 released

Just relaying this announcement from James Agnew:
HAPI 1.1 is now out!

This release features a few new features, and a number of bug fixes, including contributions from a number of people around the world.

This release is available on Sourceforge, and thanks to Francis De Brabandere it's available in the Maven Central Repo too, meaning that you no longer need to add the HAPI repo to your pom.xml file if you are a Maven user.

It's really good to see HAPI is such a healthy state, and good to see the release going straight into Maven Central.

Thanks to James and other contributors for making this happen.