views:

1102

answers:

3

Hi,

I have Maven on Ubuntu server.

It seems to try lots and lots of places to download from but the download times out, but the timeout takes ages, so my whole build takes more than a hour.

Downloading: http://scala-tools.org/repo-releases/org/apache/maven/maven-repository-metadata/2.0.3/maven-repository-metadata-2.0.3.pom
[INFO] Unable to find resource 'org.apache.maven:maven-repository-metadata:pom:2.0.3' in repository scala-tools.org (http://scala-tools.org/repo-releases)
Downloading: http://download.java.net/maven/2/org/apache/maven/maven-repository-metadata/2.0.3/maven-repository-metadata-2.0.3.pom
[WARNING] Unable to get resource 'org.apache.maven:maven-repository-metadata:pom:2.0.3' from repository java.net (http://download.java.net/maven/2): Error transferring file: Connection timed out
Downloading: http://download.java.net/maven/1/org.apache.maven/poms/maven-repository-metadata-2.0.3.pom
[WARNING] Unable to get resource 'org.apache.maven:maven-repository-metadata:pom:2.0.3' from repository m1.java.net (http://download.java.net/maven/1): Error transferring file: Connection timed out
Downloading: http://download.java.net/maven/2/org/apache/maven/maven-repository-metadata/2.0.3/maven-repository-metadata-2.0.3.pom
[INFO] Unable to find resource 'org.apache.maven:maven-repository-metadata:pom:2.0.3' in repository maven2-repository.dev.java.net (http://download.java.net/maven/2)
Downloading: http://repository.jboss.org/maven2/org/apache/maven/maven-repository-metadata/2.0.3/maven-repository-metadata-2.0.3.pom
[INFO] Unable to find resource 'org.apache.maven:maven-repository-metadata:pom:2.0.3' in repository repository.jboss.org (http://repository.jboss.org/maven2)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-repository-metadata/2.0.3/maven-repository-metadata-2.0.3.pom

I only have two repos set in my maven build

<repository>
    <id>central</id>
    <name>Maven Repository Switchboard</name>
    <layout>default</layout>
    <url>http://repo1.maven.org/maven2&lt;/url&gt;
    <snapshots>
        <enabled>false</enabled>
    </snapshots>
</repository>

<repository>
  <id>maven2-repository.dev.java.net</id>
  <name>Java.net Repository for Maven</name>
  <url>http://download.java.net/maven/2&lt;/url&gt;
</repository>
<repository>
    <id>repository.jboss.org</id>
    <name>JBoss Repository</name>
    <url>http://repository.jboss.org/maven2&lt;/url&gt;
</repository>

Thanks, philip

+5  A: 

It seems that Ubuntu's packaged Maven version comes with a /etc/maven2/settings.xml. Have a look at this file to see if it contains additional repositories. Also check the file ~/.m2/settings.xml of the user you are using.

PS: I don't really like using .deb for this kind of software and recommend installing it "manually" (i.e. just download the archive, unzip it somewhere, set the M2_HOME env variable and add $M2_HOME/bin to the $PATH).

Pascal Thivent
I just want to second this. It's so easy to install java tools manually that it's almost always the best way to go.
jshen
A: 

Make sure you can access these resources (in your case the POMs) outside of Maven, if the machine has no network connectivity for example (or can't resolve hostnames), it will time out, and it will take a long time (as you noted).

If you don't need to re-download the resources every time, just run Maven in the "offline" mode with the -o switch.

Also, just a tip, you may want to create and install POMs, even for third party JARs, and then get them in your local repo. That way Maven will not have to go out to the tubes to get resources each time (it will check em, but they will be resolved locally).

For third party or otherwise non Maven JARs you can install then with the install plugin.

Charlie Collins
+2  A: 

Maybe overkill if you're the only one working on the project but I'd recommend installing a Maven repository manager like Artifactory (http://www.jfrog.org/products.php) or Nexus. I'm not familiar with Nexus but Artifactory installation is dead simple - just unzip and you're good to go (since it comes with an embedded jetty).

Why will this make your Maven builds faster ?

  • Repository managers employ more sophisticated caching than the Maven core itself
  • (at least with Artifactory) You can restrict which Maven repositories are queried for which group IDs. This speeds up things considerably if you need to fetch dependencies from multiple different Maven repositories
JavaGuy
+1 for nexus, setup is uncomplicated and additional features are well worth it.
crowne
btw, also +1 to install java tools manually and not use the ones that come with your distribution.
JavaGuy