Create Maven archetype
-
02-07-2021 - |
Question
I have some Eclipse maven project which I typically, copy-and-paste/modify which serves as a "template" application. How can I make this a maven archetype such that I can create these template project with maven and where is the best place to publish it perhaps?
Such that I can do something like:
mvn archetype:generate -DarchetypeRepository=repo1.maven.org -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0
Solution
Try to see this :
- this excellent book from Sonatype : http://books.sonatype.com/mvnref-book/reference/archetypes.html
- the official documentation http://maven.apache.org/guides/mini/guide-creating-archetypes.html (see Noahz's comment)
With maven official website, this is THE documentation.
Those tutorials may help you more than one of our answer.
About location, you should put them into your corporate repository.
OTHER TIPS
I recently had to do this and I wrote a tutorial which may help. It's using Eclipse and gives a few pointers on how to create directories, using conditional statements and installing it in Eclipse.
There's also a download there of the archetype itself so you are free to copy it. It's been a real life saver so I hope it helps you too:
https://www.aplossystems.co.uk/article/create-a-maven-archetype.aplos?content_id=1&cp_id=28