Maven archetype catalog : specify custom location(s)

Viewed 10421

I'm deploying a Nexus repository for Maven, and custom archetypes on it.

I would like to execute mvn archetype:generate and be prompted a list of internal + custom archetypes.

The only way I found to prompt custom archetypes (in an ergonomic way, meaning no URL) is to define the archetype-catalog path as a property in the settings. This is not a valid solution because I want several catalogs (and this property cannot be overriden in CLI).

Does anybody have a clue on how to do that ?

Thanks in advance,


[EDIT] I found an issue report related : http://jira.codehaus.org/browse/ARCHETYPE-273

And I noticed that during archetype:generate, maven tries to reach the central repository :

[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2/archetype-catalog.xml
[DEBUG] Searching for remote catalog: http://repo1.maven.org/maven2

It ends by a "Connection Timed out" because I did not (and don't want to) specify a proxy...

I don't understand why maven doesn't check nexus catalog...

3 Answers

With maven-archetype-plugin:3.1.1 you have to

  • add/edit archetype-catalog.xml on your repo to list your custom archetypes
  • edit your settings.xml to add this repo with id archetype.
  • invoke mvn archetype:generate -DarchetypeCatalog=remote

From https://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html :

If you want the catalogs to come from a different repository, please add the following to your settings.xml

<repository>
  <id>archetype</id>
  <url>https://repository.domain.com/path/to/repo/</url>
</repository>
Related