Wednesday, 9 October 2013

Create Custom Archetype and Deploy on Remote Artifactory

This post explains creating a maven archetype from already existing Maven project and deploying it on Remote Artifactory

If remote artifactory does not exists, it can be created by using jFrog

1. Creating Archetype

Go to Project Root directory from command prompt and type

mvn archetype:create-from-project

This will create a {project_root}/target/generated-sources/archtype folder.

2. Installing Archetype to local Repo

Go to {project_root}/target/generated-sources/archtype and type

mvn install

3. Installing Archetype to Remote Repo

Login to Remote Artifactory with credentials as admin/password
Go to Deploy tag. In the Uploaded File field choose the
and Click upload

Choose a valid Target Repository. For e.g. ext-release-local
In GroupId, ArtifactId, Version enter values from pom.xml present at

Click Deploy Artifact

4. Create a Catalog file and upload it with you archetype
Now this archetype is deployed on your artifact. We will need a catalog file to use this archetype.

Create archetype-catalog.xml
<?xml version="1.0" encoding="UTF-8"?>
              <description>Nihilent Spring Based REST Webservice Project </description>

Login to Remote Artifactory with credentials as admin/password
Go to Artifacts and check the libs-release-local folder
if their is a file present at location <Artifactory_Path>artifactory/libs-release-local/archetype-catalog/archetype-catalog/1.0/

than download the file and add the below snippet in it in the archetypes section

If this file is not present than create a new file as given above and upload it from Deploy tab

Go to Deploy tag and choose the archetype-catalog.xml and click Upload. Choose a valid Target Repository. For e.g. Libs-release-localIn GroupId : archetype-catalog, ArtifactId : archetype-catalog, Version : 1.0 and upload it.

5. Configure Eclipse to use this catalog

Go to Window--> Preferences - >>maven --> Archetypes

Click Add Remote Catalog and in Catalog File mention the or else you can choose Local Catalog and provide the path of the downloaded catalog xml file. 

In Decription enter Nihilent Archetype

Click Verify to verify that some archetypes are present at this location.

6. Creating Project from custom Archetype

File->New->Project..->Maven Project->Next
       In Catalog Drop Down select Nihilent Archetype
       And select the required Archetype as shown below

Share the post