Limmy
Limmy

Reputation: 746

Maven archetype:generate plugin 3.0 how to specify remote repository

I tried to create maven project using archetype which is absent in Maven central repo, but exists in another remote repository. In maven-archetype-plugin version 2.4 I could use -DarchetypeRepository param for specify another repo where maven should look for my archetype. In the new version (3.0) this param doesn't work. (Proof: http://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html#archetypeCatalog)

So I needed to use old version of plugin and wrote long command such as

$ mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DarchetypeGroupId=some.id -DarchetypeArtifactId=some.another.id -DarchetypeVersion=some.version -DarchetypeRepository=repo.url

How can I do the same command using maven-archetype-plugin:3.0?

I tried to use archetypeCatalog=repo.url, but it doesn't work this way, I can only set local or remote repo with it.

Thanks.


Plugin developer's answer:

Allowing to set a URL via commandline is considered to be a security leak, so specifying the repository (id: archetype) in the settings.xml is the right way.

Upvotes: 2

Views: 9944

Answers (2)

Hassenboy
Hassenboy

Reputation: 175

From the Maven Archetype plugin reference:

As of Maven Archetype Plugin 3.0.0 the archetype resolution has changed: it is not possible anymore to specify the repository via the command line (with -DarchetypeRepository=repo.url), but instead the repositories as already defined for Maven are used.

This means that you must add a repository entry to your settings.xml, see the link above.

Upvotes: 2

GauravJ
GauravJ

Reputation: 2262

You can specify your repository in your settings.xml as [archetypeArtifactId]-repo. This is defined as one of the FAQs.

If you do not have authentication, don't specify it in settings.xml.

OR

I just ran the following command,

mvn org.apache.maven.plugins:maven-archetype-plugin:3.0.0:generate 
     -DarchetypeGroupId=org.grails 
     -DarchetypeArtifactId=grails-maven-archetype
     -DarchetypeVersion=1.0
     -DarchetypeCatalog=http://snapshots.repository.codehaus.org

and it gave me following warning,

[WARNING] Archetype not found in any catalog. Falling back to central repository (http://repo.maven.apache.org/maven2).

[WARNING] Use -DarchetypeRepository= if archetype's repository is elsewhere.

Upvotes: 0

Related Questions