Friday, February 10, 2006

Universe of Maven 2 Archetypes

Maven 2 has this really neat feature called "archtypes" useful for creating a skeleton directory structure for a project. It allows you to specify an "archetype type" that identifies the project as an api (default), webapp or other types.

For example, you could start a brand new project like this:
mvn archetype:create              -DgroupId=com.mycompany.app              -DartifactId=my-app

Maven then creates a directory structure that Maven can understand:
my-app
|-- pom.xml
`-- src
|-- main
| `-- java
| `-- com
| `-- mycompany
| `-- app
| `-- App.java
`-- test
`-- java
`-- com
`-- mycompany
`-- app
`-- AppTest.java


This directory structure is used when your app is a jar, i.e. an API, or application.

Maven also hints that there are other types of archetypes for other types of applications, but then they don't explain anywhere what these are!

You can create a web-app project by specifying the web-app archetype:
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp
The only problem is that the Apache Maven group doesn't seem to realize that when users see this neat feature, the first questions are "Great! What types of archtypes are offered?" or "Where can I find in the documentation the list of available archetypes?". The result is that the documentation (well, "mini guides") show some examples of different archtypes used, describe an introduction to archetypes, and even show you how to create your own archetype. (Worse yet, is that "How to create archteypes" is listed before, "Introduction to Archteypes" ... duh!) . But programmers are lazy, and we want to know what archetypes have you created for us!!

To find the answer, I did a little google searching and found two links that pointed me in very unobvious directions:

One link pointed me to the unobvious subdirectories of the build distribution for Maven 2 found here: http://www.ibiblio.org/maven2/org/apache/maven/archetypes/

From here, you can see the possible archetypes are:
maven-archetype-marmalade-mojo
maven-archetype-mojo
maven-archetype-quickstart
maven-archetype-site
maven-archetype-webapp
Another site pointed me to the SVN repository for Maven. Drilling down to the archetypes, it looks like there are a few more available:
maven-archetype-j2ee
maven-archetype-mojo
maven-archetype-portlet
maven-archetype-profiles
maven-archetype-quickstart
maven-archetype-site
maven-archetype-webapp
The directory structure that these archetypes actually create is up to you to try. I've used the default (i.e., don't specify one) API archetype and the web-app and am happy with the directory structure that it creates.

Maybe one day I will report on the directory structures of these archetypes, but really that should be done in the Maven documentation ... (Hint!!!)

3 Comments:

At 8:39 AM, Blogger Robert Hanson said...

Errr... what is a "mojo" archetype? I did a search for "mojo java", and this is what it came up with...

http://www.mojojava.net/

:)

 
At 6:37 AM, Blogger Janet Moyer said...

Thanks for posting this. I've been struggling with the same issue, trying to find what Maven archetypes exist, and looking for J2EE archetypes. Maven's such a great idea, too bad it lacks strong user documentation.

 
At 8:05 PM, Blogger wow said...

Welcome to our website for you World of Warcraft Gold,Wow Gold,Cheap World of Warcraft Gold,cheap wow gold,buy cheap wow gold,real wow gold,sell wow gold, ...
Here wow gold of 1000 gold at $68.99-$80.99 ,World Of Warcraft Gold,buy wow gold,sell world of warcraft gold(wow gold),buy euro gold wow Cheap wow gold,cheapest wow gold store ... ffxi gil buy euro gold wow wow gold--buy cheap wow gold,sell wow gold.welcome to buy cheap wow gold--cheap, easy, wow gold purchasing.World of Warcraft,wow gold Super ...

 

Post a Comment

<< Home