Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repository for maven plugin dependency defined in pom is not used

Tags:

maven

pom.xml

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.

like image 470
Jens Bannmann Avatar asked Aug 13 '13 07:08

Jens Bannmann


People also ask

Where are Maven repositories defined?

By default, Maven will always look in the official Maven repository, which is http://repo1.maven.org. When Maven tries to build a project, it will look in your local repository (by default ~/. m2/repository but you can configure it by changing the <localRepository> value in your ~/. m2/settings.

Where do I put POM repository?

Putting non-standard repositories in the pom. xml file (which gets checked into source control) means every developer can build. But YES, your authentication for a repository server should be in your private settings. xml file.

How do I find my Maven repository URL?

Google's Maven repository can be accessed from https://maven.google.com (an alternative URL is https://dl.google.com/dl/android/maven2/). If you are using Gradle 4.1 or higher, you can use it by adding google() to your repositories configuration in your build.


1 Answers

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>
like image 140
Jens Bannmann Avatar answered Sep 20 '22 16:09

Jens Bannmann