Thursday, February 14, 2008

Maven Archetype Upgraded

Finally, it is here. An upgraded of the Maven plugin, archetype, was just recently released. Well, according to JIRA, it was actually released last week, but just recently have I taken notice :).

One of the slams that Maven receives is related to the verbosity necessary in order to use the Archetype plugin to create new projects. In order to create a new simple java project using the older version of the Maven Archetype plugin, you had to do something similar to the following:

mvn archetype:create "-DgroupId=com.sagetech.example" "-DartifactId=dummyProject"

The above would create a simple project with the jar packaging type. If you wanted to do something a little more complex, like create a project of a different packaging type, (ejb, ear, web module), you had to specify even more properties to the archetype plugin, something similar to...

mvn archetype:create "-DgroupId=com.sagetech.example" "-DartifactId=dummyProjectWeb"
"-DarchetypeArtifactId="

Although the above approaches work without any issues, it still seemed to be a cold way for a developer to get started with an application. And it appears that I am not the only one who thought so.

With the recent release of the Archetype plugin, you don't have to specify any properties at all. Simply type the command:

mvn archetype:generate

...and during the course of the execution of the plugin, it will prompt you for the following information:

1.) Choose the archetype
2.) Choose the groupId
3.) Define the artifactId
4.) Define the version
5.) Define the package

A friend of mine has always given me a hard time about how verbose you have to be in order to create a java application using the Maven Archetype Plugin. I cannot wait until he reads this post...Dave Brondsema, this one is for you.... :)

2 comments:

Dave Brondsema said...

Thanks Carlus :) http://www.oreillynet.com/onjava/blog/2008/02/changing_the_maven_pom.html also looks like a step in the right direction. Not that I like XML for stuff that is normally hand-edited.. I'd prefer YAML any day.

Anonymous said...

Nice blog. I've added it to my iGoogle page!

b5