Preparation
Generate archetype
- Move to the project to be archetyped.
cd ${project_path}
- Generate archetype.
mvn archetype:create-from-project
The pom.xml is generated in${project-path}/target/generated-sources/archetype/src/main/resources/archetype-resources/pom.xml
. - Modify source files as required.
The files are in${project-path}/target/generated-sources/archetype/src/main/resources/archetype-resources
You may use${groupId}
,${artifactId}
and${version}
.
For example,<h1>Hello world! ${artifactId}</h1>
in${project-path}/target/generated-sources/archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/views/home.jsp
- Create jar.
Please note that the SNAPSHOT cann’t be published into release repository.
cd ${project-path}/target/generated-sources/archetype/
mvn install
The folder structure shall be look like this.
Publish to Nexus
- Access to Nexus.
The default url is.
http://{your-hostname}:8081/nexus/
- Login as admin.
The default user/password isadmin
/admin123
. - Click Repositories under View/Repositories at left panel.
- Select Release reposotory and Artifact Upload tab.
- Select GAV Defition: “From POM”.
- Click “Select POM to Upload” and select
${project-path}/target/generated-sources/archetype/pom.xml
. - Click “Artifact(s) to Upload” and select generated jar file in
${project-path}/target/generated-sources/archetype/target
.
- Click “Add Articact” and “Upload Artifact(s)”.
Create New Project from Published Archetype
Create from http://localhost:8081/nexus/content/repositories/releases/ as other public archetype.
When I use myApp as Artifact Id, the home.jsp is rendered ${artifactId} as myApp.