Saturday, December 11, 2010

Set up a Maven Repository Manager

My basic requirements are
  1. rich and intuitive user interface
  2. ease of setting network proxy
  3. ease of deploying 3rd party and internal artifacts
I got a chance to try several different products and finally installed one of them. Here are my impressions and the problems I encountered and luckily fixed.

Sonatype Nexus
No one can ignore it. De facto standard and from the company behind Maven. It's not my first time to use the interface, so no surprise and everything works just as expected.

JFog Artifactory
I had to say I love the design, and the auto discovery of ArtifactId, Version and Type during deploying artifacts, although some GroupId are wrongly set to be the same as ArtifactId.

Apache Archiva
It has quite good UI, but needs work on usabilities. If you have several remote repositories and need to apply the same (is there anyone need to set different proxies?) network proxy, it's a joke. Also it lacks some commonly used artifacts, which the other two players have no such problem.

I tried each of them for half day or so and decided to go with Artifactory.

Problem
Downloading: http://localhost:8081/artifactory/repo/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.jar

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-compiler-plugin:2.3.2: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 in artifactory (http://localhost:8081/artifactory/repo)

Solution
Set network proxy.

Problem
[WARNING] While downloading poi:poi:3.1-FINAL

This artifact has been relocated to org.apache.poi:poi:3.1-FINAL.

Solution
It's not repository manager's problem and it's better to follow the new location defined in pom file.

Problem
HTTP ERROR 409

Problem accessing /artifactory/repo/commons-fileupload/commons-fileupload/1.2.2/commons-fileupload-1.2.2.pom. Reason:

Rejected artifact download request: Checksum policy 'GEN_IF_ABSENT' rejected the artifact 'commons-fileupload-1.2.2.pom'. Checksums info: [ChecksumInfo{type=SHA-1, original='ad3fda4adc95eb0d061341228cc94845ddb9a6fe', actual='0ce5d4a03b07c8b00ab60252e5cacdc708a4e6d8'}, ChecksumInfo{type=MD5, original='c938bb047b88d2b85b47da0be9d901ec', actual='b219248b081b6b44abf436f41e16e9e1'}]

Solution
Go to Configure Repositories, in Edit Remote Repository, change Checksum Policy from default "Generate if absent" to "Ignore and generate".

Problem
HTTP ERROR 409

Problem accessing /artifactory/repo/velocity/velocity/1.5/velocity-1.5.pom. Reason:

The target deployment path 'velocity/velocity/1.5/velocity-1.5.pom' does not match the POM's expected path prefix 'org/apache/velocity/velocity/1.5'. Please verify your POM content for correctness and make sure the source path is a valid Maven 2 repository root path.

Solution
This is not repository manager's problem. Change the dependency definition as suggested.

Problem
HTTP ERROR 404

Problem accessing /artifactory/repo/hsqldb/hsqldb/1.8.0.2/hsqldb-1.8.0.2.pom. Reason:

Could not find resource

Solution
None of the default remote repositories has this artifact. Add a remote repository (in this case, http://repository.jboss.org/maven2/) and assign it to remote-repos.

Problem
Error messages in Maven Console in Eclipse
Unable to update index for snapshots|http://localhost:8081/artifactory/plugins-snapshot: Resource nexus-maven-repository-index.properties does not exist

Updating index central|http://localhost:8081/artifactory/plugins-release

Unable to update index for central|http://localhost:8081/artifactory/plugins-release: Resource nexus-maven-repository-index.properties does not exist

Updating index snapshots|http://localhost:8081/artifactory/libs-snapshot

Unable to update index for snapshots|http://localhost:8081/artifactory/libs-snapshot: Resource nexus-maven-repository-index.properties does not exist

Updating index central|http://localhost:8081/artifactory/libs-release

Unable to update index for central|http://localhost:8081/artifactory/libs-release: Resource nexus-maven-repository-index.properties does not exist

Updating index snapshots|http://localhost:8081/artifactory/plugins-snapshot

Solution
Maven Settings Generator generated wrong URLs in settings.xml. Use following URLs instead.
<repositories>
    <repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>libs-releases</name>
        <url>http://localhost:8081/artifactory/libs-release-local</url>
    </repository>
    <repository>
        <snapshots />
        <id>snapshots</id>
        <name>libs-snapshots</name>
        <url>http://localhost:8081/artifactory/libs-snapshot-local</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>plugins-releases</name>
        <url>http://localhost:8081/artifactory/plugins-release-local</url>
    </pluginRepository>
    <pluginRepository>
        <snapshots />
        <id>snapshots</id>
        <name>plugins-snapshots</name>
        <url>http://localhost:8081/artifactory/plugins-snapshot-local</url>
    </pluginRepository>
</pluginRepositories>