Tuesday, September 01, 2009

Maven Archetype quick notes

maven-archetype-plugin allows the user to create a Maven 2 project from an existing template caled an archetype.

If you just use an IDE to generate Maven project, you can be familiar with default project structure of Maven:

Let's consider an example using it to create a "todo-list" project which contains 2 sub-projects: todo-core and todo-web

cd workspace

mkdir -p todo-list

cd todo-list

Old-fashioned way:
mvn archetype:create -DartifactId=todo-core -DgroupId=org.vnoss

mvn archetype:create -DartifactId=todo-web -DgroupId=org.vnoss -DarchetypeArtifactId=maven-archetype-webapp

New way:
mvn archetype:generate

mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp

Now we can edit the pom.xml to get desired result.

No comments: