Maven archetype catalog : specify custom location(s)

Benjamin picture Benjamin · Jul 6, 2011 · Viewed 9.6k times · Source

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...

Answer

leroyse picture leroyse · Sep 21, 2011

I also have a Nexus configured to mirror the Maven repositories and thus the remote catalog too.

<mirror>
    <!--This sends everything else to /public -->
    <id>nexus</id>
    <mirrorOf>*</mirrorOf>
    <url>http://afbwt03:8081/nexus/content/groups/JavaRepo/</url>
</mirror>

and:

<profile>
    <id>nexus</id>
    <repositories>
        <repository>
            <id>central</id>
            <url>http://central</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <url>http://central</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</profile>

I am able to access the remote catalog only when I use the following Maven command line:

mvn archetype:generate -DarchetypeCatalog=http://afbwt03:8081/nexus/content/groups/JavaRepo

If I don't define the archetypeCatalog variable, I get the same behavior as you do: trying to access the repo1. ... although some mirrors are configured.