Sonatype Nexus 3.1: Archetype catalog not generate

2019-07-24 07:14发布

问题:

Ever since we've upgraded to Sonatype Nexus 3.x we are missing our custom archetypes in the repository.

When browsing to http://repo/repository/maven-releases/archetype-catalog.xml I am being shown an empty archetype XML:

I have tried rebuilding the index of the repository and also tried deploying a new archetype version, but nothing seems to populate the archetype-catalog.xml. The catalog was working with version 2 of Nexus.

回答1:

Ok, I found the culprit. I had to use the maven-archetype packaging from archetype-packaging:

<project>
    <groupId>com.example</groupId>
    <artifactId>example-archetype</artifactId>
    <version>1.0.0</version>
    <packaging>maven-archetype</packaging>

    ...

    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.archetype</groupId>
                <artifactId>archetype-packaging</artifactId>
                <version>2.4</version>
            </extension>
        </extensions>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-archetype-plugin</artifactId>
                    <version>2.4</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

When deploying with that packaging, the archetypes will show up in Nexus' archetype-catalog.