1. Introduction
1) As we can see, the hierarchy of dirs is pre-defined in maven. And we have to follow such principle to organize our project.
2) So maven has provided a plugin named archetype to help us generate required folder/directories.
3) The machenism of archetype plugin
2. How to use archtype to generate frame for JavaSE project
1) In CMD, step into the parent folder of the wanted generated root folder for our project.
Eg. c> cd: d:/workspace/maven02
2) Use archetype plugin to generate basic frame for our project
Eg. d:/workspace/maven02> mvn archetype:generate
3) Config params to generate param specified frame
Eg. 1) Choose a number: 6:
2) Define value for property 'groupId': : edu.xmu.maven
3) Define value for property 'artifactId': : MavenExample-ModuleTwo
4) Define value for property 'version': 1.0-SNAPSHOT: :
5) Define value for property 'package': edu.xmu.maven: :
4) Overview of the generated folder
3. Comments:
1) The generated project root is right in the current folder with the name of artifactId.
2) The generated pom.xml is inside project root folder. But the default jUnit compile level is 3.8.1, so we need to modify this to 4.x
4. How to use archtype to generate frame/skeleton for JavaWeb project
1) In CMD, step into the parent folder of the wanted generated root folder for our project.
Eg. c> cd: d:/workspace/maven03
2) Use archetype plugin to generate basic frame for our project
Eg. d:/workspace/maven03> mvn archetype:generate -DgroupId=edu.xmu.maven -DartifactId=MavenExample-ModuleThree -DarchetypeArtifactId=maven-archetype-webapp
3) Press Enter/Enter/Enter... Then a basic java web project in maven form will be generated.
4) Overview of the generated folder (There will be index.jsp inside webapp folder and web.xml inside WEB-INF folder)
5) We can use different -DarchetypeArtifactId=xxx for different folder generating strategy.
5. How to create customized archetype in order to generate our own project and customize folder organization.
Please refer to http://jwu.iteye.com/blog/612944
6. Useful links:
1) http://maven.apache.org/archetype/maven-archetype-plugin/
2) http://maven.apache.org/guides/mini/guide-creating-archetypes.html ---> Introduction in details how to create our project skeleton using self-defined archetype
3) http://myjeeva.com/exclusive-maven-archetype-list.html ---> List in details of all the pre-defined archetypeArtifactId we can use.