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:
You can find it on this page in the mvnrepository site. The three big issues are:
- 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.
- 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.
- 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.
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.