Tuesday, January 29, 2008

How to create project directory structure with maven archetype plugin

Nowadays i am working on a new dynamic web project which uses spring-hibernate-richfaces trio.My first task to set up development environment of project.It involves many steps.I will write sth about it occasionally.

Here I will use Maven Archetype plugin to create directory structure of my project.Assume that dynamic webproject has 3 directory initially.

core
web
security

Because we will created an internal artifactory repository and configured it we dont care about jars anymore.Project will be simply involves java classes,resources like gifs,jpegs for web side,and our pom.xmls.Jars will reside in M2_REPO which is = Your home\.m2\repository as default.

1.Create an empty directory e.g myproject
2.Go inside it
3.write in command prompt

mvn archetype:create -DgroupId=com.mycompany.myproject.core
-DartifactId=myproject-core -DarchetypeArtifactId=maven-archetype-quickstart

It will create myproject-core directory.

4.write in command prompt

mvn archetype:create -DgroupId=com.mycompany.myproject.web
-DartifactId=myproject-web -DarchetypeArtifactId=maven-archetype-webapp

It will create myproject-web directory.

5..write in command prompt

mvn archetype:create-DgroupId=com.mycompany.myproject.security
-DartifactId=myproject-security-DarchetypeArtifactId=maven-archetype-quickstart

It will create myproject-security directory.

You will see that every directory has a pattern.Thanks to this plugin you dont need to think about directory structure of your project.

For more information
http://maven.apache.org/plugins/maven-archetype-plugin/

No comments: