Create archetype from an existing project for local Nexus

Preparation

  1. Develop a project using any IDE or text editor.
  2. Install Maven
  3. Install Nexus

Generate archetype

  1. Move to the project to be archetyped.
    cd ${project_path}
  2. 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.
  3. 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
  4. 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

  1. Access to Nexus.
    The default url is.
    http://{your-hostname}:8081/nexus/
  2. Login as admin.
    The default user/password is admin/admin123.
  3. Click Repositories under View/Repositories at left panel.
  4. Select Release reposotory and Artifact Upload tab.
  5. Select GAV Defition: “From POM”.
  6. Click “Select POM to Upload” and select ${project-path}/target/generated-sources/archetype/pom.xml.
  7. Click “Artifact(s) to Upload” and select generated jar file in ${project-path}/target/generated-sources/archetype/target.
  8. 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.

Done!!

シェアする

  • このエントリーをはてなブックマークに追加

フォローする