How to prevent Maven from using a <repository> in a dependency's pom-file?

By accident we discovered that one of our dependencies (spring-data-jpa 1.1.0.RELEASE, see its pom-file) includes a <repository>.

This means that our builds directly go to that repository, circumventing our own central Maven repository.

However, we want our builds to be controlled: all artifacts should come from our department's Maven repository, and that we configure to have or get everything we need from the places we want.

Question: How can we instruct Maven to ignore <repositories> from dependent artifacts' pom-files?

Upvotes: 3

Views: 470

Answers (1)

Moritz Petersen
Moritz Petersen

Reputation: 13057

You can disable a repository like this:

<repository>
    <id>spring-libs-release</id>
    <url>http://repo.springsource.org/libs-release</url>
    <releases>
        <enabled>false</enabled>
    </releases>
    <snapshots>
        <enabled>false</enabled>
    </snapshots>
</repository>

Or you can try using a mirrorOf declaration, to use a single repository:

<mirrors>
    <mirror>
        <id>internal-repository</id>
        <name>Maven Repository Manager running on repo.mycompany.com</name>
        <url>http://repo.mycompany.com/proxy</url>
        <mirrorOf>*</mirrorOf>
    </mirror>
</mirrors>

Upvotes: 2

Related Questions