Install Maven Archetype

Alex Epelde picture Alex Epelde · Oct 26, 2012 · Viewed 20.2k times · Source

I have created a Maven archetype from an existing project. I have even installed the archetype in my local repository and used it to create a new project. Everything went perfect (incredible).

The thing is that I want to distribute this archetype so anybody can install it in his local machine or even deploy to a maven repo in order to use it. I was thinking about distributing the generated the artifact JAR, not the source of my project, and let people install it but it seems like it doesn't install as an archetype or at least it isn't recognized when I try to use it.

I used mvn install:install-file goal to do this.

Is this the best way to do this? Is it posible to distribute this JAR file in order to install it as an archetype? Is the JAR file missing something?

Thanks in advance.

Answer

LAFK says Reinstate Monica picture LAFK says Reinstate Monica · Apr 11, 2016

Few clarifications here:

// installs the project to your local repository (jar, archetype, etc.)
mvn install
// AND updates archetype catalog
mvn install archetype:update-local-catalog
// calls plugin archetype goal crawl
mvn archetype:crawl

Crawl goes through Maven repo and CREATES catalog.

If you wish to use archetype interactively, you either need to call if with full coordinates or have it listed in the catalog.

// use local catalog
mvn archetype:generate -DarchetypeCatalog=local
// full coordinate set, my example
mvn archetype:generate -DarchetypeGroupId=pl.lafk -DarchetypeArtifactId=simple-testng-quickstart -DarchetypeVersion=1.0 -DgroupId=pl.lafk -DartifactId=sample-app

When you call mvn deploy you do all that install does plus push the package to remote repository - if you have it configured.

Link I used was Maven site for plugin: https://maven.apache.org/archetype/archetype-packaging/index.html

Additionally: mvn archetype:help