nickdos
nickdos

Reputation: 8414

Maven repository URL is timing out and build is taking forever

It seems that one of the repositories is temporarily unavailable and is causing a warning like:

[WARNING] Could not transfer metadata org.gbif:gbif-common:0.5-SNAPSHOT/maven-metadata.xml 
from/to eclipselink (http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo):
Error transferring file: Operation timed out

I do not reference that repository in my app's pom file but it is coming from a downline repository or dependent project(?). Hitting the URL http://ftp.ing.umu.se in my browser results in a spinning progress bar, followed eventually by a "could not connect to..." message in the browser.

The problem is that for every artifact, it tries that URL and times out after 75 seconds and then continues. Thus my build is taking forever (over an hour and counting).

Is there some way to either prevent it checking that repository or reducing the timeout, etc. So far Googling has got me no where.

EDIT: running maven as mvn clean package -DskipTests=true

Upvotes: 3

Views: 2348

Answers (1)

Dev
Dev

Reputation: 12196

You can use a repository mirror to redirect requests to a known good repository. It is actually recommended that you set up a global mirror "*" to a repo of your choice to prevent fetching code from a random repository someone declared in a pom file.

Example for ~/.m2/settings.xml:

<settings>
  ...
  <mirrors>
    <mirror>
      <id>global</id>
      <name>Maven Central</name>
      <url>http://repo1.maven.org/maven2</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>

In this example I'm using Maven Central as the target, but you could redirect requests to anywhere you wanted such as a private repository. If you have to fetch code from more than one repo you can create an exception by using "!" and then the repo id as declared in your settings like so.

...
<mirrorOf>*, !otherRepo</mirrorOf>
...

This will prevent requets to 'otherRepo' from being redirected to the mirror target.

Of course, if you turn out to need an artifact that is really only stored on this cranky repository, you will still be out of luck.

Upvotes: 3

Related Questions