How to add a maven archetype from mvncentral to local archetype-repo.xml

Ivonet :

I have created an archetype and added it to maven central (https://repo.maven.apache.org/maven2/nl/ivonet/javaee8-essentials-archetype/)

Now to test if I can get it from the central repo I removed my local versions from ~/.m2/repository and also removed the references form ~/.m2/repository/archetype-catalog.xml

I tried mvn archetype:generate -Dfilter=nl.ivonet:javaee8-essentials-archetype -U to generate a new project but I don't get my archetype in the filtered list.

How do I get the apache central hosted archetype in my local catalog? without having to build it myself that is

The goal is to get it offline available again...

taygetos :

Option 1

You can get the dependencies with the maven dependency plugin as follows

mvn dependency:get -DgroupId=nl.ivonet \
   -DartifactId=javaee8-essentials-archetype -Dversion=0.0.2

And then next time when you are offline or you want to work with your cache, you call the generate with -o flag (offline)

mvn archetype:generate (...) -o

Option 2

Use mvn archetype:crawl which searches your local repository for available archetypes and creates a catalog file under ~/.m2/repository/archetype-catalog.xml.

Then you can use the catalog file when generating archetype:

mvn archetype:generate -DarchetypeCatalog=file://path/to/catalog (...)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=81321&siteId=1