How do you configure maven to ignore repositories specified in POM files?
As a workaround, define another repository in your settings.xml
with the same ID (is it oss.sonatype.org
, defined in jetty-parent:19
, that's the problem?) and point it at your repo. Maven will use that definition in favour of the one in the pom.
There's an open issue filed against Maven (MNG-3056) to allow this to be configured so only your repo would be used; in general, if you have a local repository, that would be the behaviour you would want.
That's a great answer Joe. Thank you. I was looking for it for quite some time.
I just quote an example, in which I had the same problem as Nathan.
I use a Maven enterprise repository (Nexus or Artifactory) and I am behind a proxy, that means that I cannot download directly (and do not want to) from any other repositories than mine.
Jasper reports net.sf.jasperreports:jasperreports:6.2.0 defines in its pom a couple of repositories.
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.2.0</version>
...
<repositories>
<repository>
<id>jasperreports</id>
<url>http://jasperreports.sourceforge.net/maven2</url>
</repository>
<repository>
<id>jaspersoft-third-party</id>
<url>http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts/</url>
</repository>
</repositories>
This causes the following exception:
C:\my-project>mvn verify
[INFO] Scanning for projects...
[INFO] Building my-project 1.0.0-SNAPSHOT
[INFO]
Downloading: http://mynexus/nexus/content/groups/ch-public/com/lowagie/itext/2.1.7.js4/itext-2.1.7.js4.pom
Downloading: http://jasperreports.sourceforge.net/maven2/com/lowagie/itext/2.1.7.js4/itext-2.1.7.js4.pom
Downloading: http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts/com/lowagie/itext/2.1.7.js4/itext-2.1.7.js4.pom
[INFO] BUILD FAILURE
[INFO] Could not resolve dependencies for project ... :
Failed to collect dependencies at net.sf.jasperreports:jasperreports:jar:6.2.0 ->
com.lowagie:itext:jar:2.1.7.js4: Failed to read artifact descriptor for com.lowagie:itext:jar:2.1.7.js4:
Could not transfer artifact com.lowagie:itext:pom:2.1.7.js4
from/to jasperreports (http://jasperreports.sourceforge.net/maven2):
Connect to jasperreports.sourceforge.net:80 [jasperreports.sourceforge.net/216.34.181.96]
failed: Connection timed out:
The solution as described by Joe is: In global settings.xml (C:/maven-installation/conf/settings.xml) or private settings.xml (~/.m2/settings.xml) add the following profile:
<profiles>
<profile>
<id>ignore-repositories</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<repositories>
<repository>
<id>jasperreports</id>
<url>http://mynexus/nexus/content/groups/ch-public/
</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>jaspersoft-third-party</id>
<url>http://mynexus/nexus/content/groups/ch-public/
</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
Important: the repository id in the profiles (jasperreports , jaspersoft-third-party) matches exactly the id of the repository used in pom.xml - in this case the pom.xml of net.sf.jasperreports:jasperreports:6.2.0
Do not forget to add the "external" repositories to the "proxy" list of your Maven Enterprise Repository