One of the most useful features of the java.net portal is its Maven 2 repository, where project owners can publish their project artifacts using standard Maven features. Following the instructions of the maven2-repositoryproject, you should:
- Request a "Maven Publisher" role
- Setup your project to deploy into the java.net maven2 repository. You should include the configuration in your parent pom (if you have a multi-module project). Here you can find my latest version of pom.xml, which includes the configuration like the one below:
<repositories> <repository> <id>maven2-repository.dev.java.net</id> <name>Java.net Repository for Maven</name> <url>http://download.java.net/maven/2/</url> </repository> </repositories> <build> <extensions> <extension> <groupId>org.jvnet.wagon-svn</groupId> <artifactId>wagon-svn</artifactId> <-- suppress the version to get the latest one --> </extension> </extensions> </build> <distributionManagement> <repository> <uniqueVersion>false</uniqueVersion> <id>java.net-maven2-repository</id> <url>java-net:/maven2-repository/trunk/repository/</url> </repository> </distributionManagement>
- Create a file with your authentication credentials:
vim ~/.java.net userName=yourJavaNetLogin password=yourPassword save the file and apply permission 600 to restrict the access to your personal information: chmod 600 ~/.java.net
mvn deployin your project root folder. Here I have problems with my Ubuntu installation, because the default maven installed by the Synaptic Package Manager does not work with the java.net repository protocol java-net. I explain below how to workaround on that.
Cannot find wagon which supports the requested protocol: java-net
After following the java.net instructions, I got a strange error in the terminal:
~/svn/footprint$ mvn deploy Deploying artifacts to http://download.java.net/maven/2/ Deploying the main artifact pom.xml [INFO ] Retrieving previous build number from ERROR: Error deploying artifact: Failed to transfer file: http://download.java.net/maven/2//net/java/dev/footprint/footprint/1.0-SNAPSHOT/footprint-1.0-SNAPSHOT.pom Return code is: 401 [INFO] Error retrieving previous build number for artifact 'net.java.dev.footprint:footprint:pom': repository metadata for: 'snapshot net.java.dev.footprint:footprint:1.0-SNAPSHOT' could not be retrieved from repository: java.net-maven2-repository due to an error: Unsupported Protocol: 'java-net': Cannot find wagon which supports the requested protocol: java-net
I double checked the
~/.java.net file and other permissions around - like the settings.xml in the mvn folder - but the error was in a tricky detail:
The maven installed by the synaptic package manager of Ubuntu is not the latest apache maven distribution. You should remove the Ubuntu default maven package and manually install the Apache Maven for Linux.
This detail is particularly difficult to figure out due to the fact that most of Java developers do not use Linux - so many of the responses in the mailing lists are something like never heard about it... did you follow the instructions properly? The first sign of something related to the OS configuration came from my Eclipse, because when I tried to run the same maven commands through the IDE, the maven started downloading again some libraries - on that moment I realized it was using a different repository. After that, a tip of Julio Viegas helped me to replace the default Ubuntu maven package by the latest Apache distribution - problem fixed!
You can find the instructions to install the software here:
If everything works, you should see something like this in the terminal:
~/svn/footprint$ mvn --version Maven version: 2.1.0-M1 Java version: 1.6.0_12 Default locale: en_US, platform encoding: UTF-8 OS name: "linux" version: "2.6.27-11-generic" arch: "i386" family: "unix"
Special hint for Hudson installation
If your system hosts a Hudson application, be sure to update the installation folders of Maven and Java in the Hudson before starting your next build sessions - otherwise Hudson will get lost. Just login in Hudson, go to http://localhost:8080/hudson/configureand update the path of the applications.