Create a custom archetype using Maven3

Source: Internet
Author: User

There are two ways to create your own archetype, and the simpler one is the create from project

1 , first use Eclipse to create a new MAVEN project, and then put the configuration of some common things under the corresponding directory
For example, some common Java code will be stored under the Src/main/java directory;
Some common configuration files will be placed under the Src/main/resources directory;

If it is a javeee project, there will be some JSP, and so on the file into the Src/main/webapp directory


2. Then add the plug-in to the MAVEN project's Pom.xml file (same as the dependencies node sibling )
================================================

<build>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-archetype-plugin</artifactId>

<version>2.2</version>

</plugin>

</plugins>

</build>

================================================

For example:




3, open the CMD window, CD to the root of the MAVEN project you just created, run the MAVEN command (which can be very slow and patient):
    mvn archetype:create-from-project
The generated-sources directory is then generated under the target directory, which is the generated archetype

4. CD into the Generated-sourced/archetype directory and run the MAVEN command:
    mvn Install
This installs the custom archetype to the local repository.
The address of the archetype installation is specified in the conf/settings.xml file (<localRepository> bytes) under the MAVEN installation directory.
The default is to generate a Archetype-catalog.xml file (and the default settings.xml in the same directory) under the ~/.M2 directory.
declares the GroupID, Artifactid, and other properties of the archetype.
since Eclipse created the MAVEN project, the selected "Default Local" points to the address is ~/.m2,
so the file Archetype-catalog.xml will be automatically read by Eclipse,
When you create a MAVEN project using Eclipse, you can find the custom archetype name in the "Default Local" item.
    
5. In the MAVEN settings of Eclipse, User settings Select the settings.xml point to the local warehouse address and the MAVEN installation directory
Settings.xml, Eclipse will be able to read the source file of the custom archetype that was just installed, as it points to the path in the
This allows eclipse to copy the source files and create the project.

6. If you want to uninstall the archetype you just installed, simply delete the corresponding <archetype> byte segment in the Archetype-catalog.xml file below the ~/.m2 directory .
and the local warehouse in the corresponding GroupID and artifactid the following files are deleted.

7, installed in the local warehouse archetype can only be used by themselves, if you want to share, then in the fourth step, use the Deploy command, do not use the install command.
=======================================================================
=======================================================================


Create a custom archetype using Maven3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.