26

What are the main/best Maven repositories to use that will include the majority of your open source Java package dependencies.

Also in what order should these be included? Does it matter?

Hank Gay
  • 70,339
  • 36
  • 160
  • 222
Keith Lyall
  • 285
  • 1
  • 3
  • 3

2 Answers2

27

This is the current setup in the project we are building:

  • MavenCentral
  • ObjectWeb
  • JBoss Maven2
  • and some snapshots (see below)

    <repository>
        <id>MavenCentral</id>
        <name>Maven repository</name>
        <url>http://repo1.maven.org/maven2</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>objectweb</id>
        <name>Objectweb repository</name>
        <url>http://maven.objectweb.org/maven2</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>jboss</id>
        <name>JBoss Maven2 repository</name>
        <url>http://repository.jboss.com/maven2/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <releases>
            <enabled>true</enabled>
        </releases>
    </repository>
    <repository>
        <id>glassfish</id>
        <name>Glassfish repository</name>
        <url>http://download.java.net/maven/1</url>
        <layout>legacy</layout>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>apache.snapshots</id>
        <name>Apache Snapshot Repository</name>
        <url>
            http://people.apache.org/repo/m2-snapshot-repository
        </url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>ops4j.repository</id>
        <name>OPS4J Repository</name>
        <url>http://repository.ops4j.org/maven2</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>Codehaus Snapshots</id>
        <url>http://snapshots.repository.codehaus.org/</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <releases>
            <enabled>false</enabled>
        </releases>
    </repository>
    
Jorge Ferreira
  • 96,051
  • 25
  • 122
  • 132
5

I would suggest using a Maven proxy like Archiva, Artifactory or Nexus and defining your repo list on the server side. The order matters only to the extent that the proxy server tries the proxied repos one by one and specifying a fringe repository as first will slow down the resolution of uncached artifacts (Artifactory allows you to specify whitelist and blacklist expressions for each proxied repo, which solves this problem)

Overall using your own repo gives you more control and reliable builds ('central' is often painfully slow). It also gives you a place to put your own artifacts and any non-free 3rd party artifacts.

ddimitrov
  • 3,293
  • 3
  • 31
  • 46
  • Great idea. The only caveat I would add is that if you are releasing your project as open source then you should explicitly list the external repository dependencies in your POM. – Brian Matthews Oct 02 '08 at 22:55
  • Irrelevant answer. The question is which "public" repository is best or shall be used. – wh81752 Aug 07 '15 at 12:41