Anyone who has studied Maven knows that using the MyEclipse Maven plugin to build a skeleton of the project, such as Maven-archetype-quickstart, is one of the most common.
When the skeleton was first used, it felt good, reduced duplication of effort and improved development efficiency. With a long time to use, you will find that the project skeleton provided by Maven archetype can not meet the company's prescribed project structure, and it is unavoidable to manually change something.
At this point, it is natural to think that if you can upload the project structure of a company (or project team) as a skeleton prototype for use as a template, you do not need to modify any files. Also reduces the project environment to build time, reduces the error rate and so on.
Simple to create and use the Maven-archetype-plugin method, can refer to: http://www.colorfuldays.org/tag/archetype/write simple, but said very clear.
1, into the template project root directory, the implementation of the command: MVN archetype:create-from-project
Generate a project prototype (archetype) with the project as a template, with a specific project structure under the Target/generated-sources directory;
Note: The generated archetype contains all the documents in the template project, avoids redundancy, removes redundant files, and does some sorting on their project structure!!!
A, modify the archetype directory Pom.xml, the name of the archetype to modify into your favorite;
b, you can change the folder to _rootartifactid_, so that when you build the project structure, the directory name becomes the new project name;
Once these are all sorted out, they can be published to the Nexus warehouse for use by other colleagues, and the method is published as follows:
2, add the Maven warehouse configuration in the Pom.xml in the archetype directory:
<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.10.254:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.10.254:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
3, publish archetype, to the ${basedir}/target/generated-sources/archetype directory, execute the command:
MVN Deploy
4, use the prototype to create a new project, any directory to execute the command:
MVN Archetype:generate-darchetypegroupid=com.ktr-darchetypeversion=1.0-darchetypeartifactid=ktr-archetype
Note: The contents of the table are reproduced.
The above method is based on the Nexus, if there are no servers, you can refer to the http://maven.apache.org/archetype/maven-archetype-plugin/advanced-usage.html
Detailed information on how to create and use archetype quickly.