Repository for maven plugin dependency defined in

2019-02-21 18:10发布

问题:

I switched to a SNAPSHOT version of a plugin I use, and declared the corresponding snapshot repository in the POM like this:

<project>
    <!-- ... -->

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.openjpa</groupId>
                    <artifactId>openjpa-maven-plugin</artifactId>
                    <version>2.3.0-SNAPSHOT</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <repositories>
        <repository>
            <id>apache.snapshots</id>
            <name>Apache Snapshot Repository</name>
            <url>http://repository.apache.org/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
    </repositories>
</project>

Now Maven keeps complaining about not being able to download the plugin from our corporate repository (which does not mirror anything on the internet) - it just ignores the repository defined in the POM.

回答1:

I forgot (again) that Maven distinguishes between repositories and pluginRepositories. The following code works fine:

<project>
    <!-- ... -->

    <pluginRepositories>
        <pluginRepository>
            <id>apache.snapshots</id>
            <name>Apache Snapshot Repository</name>
            <url>http://repository.apache.org/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>
</project>


标签: maven pom.xml