Tuesday, June 01, 2010

Using a maven SNAPSHOT plugin from repository.apache.org

I was working on a project and hitting a bug in the maven eclipse plugin which was causing the JRE to be placed incorrectly in the Eclipse .classpath. If it was just a single project I'd have gone and edited the resulting file manually but it affected a few, so I thought I'd try and grab a newer copy of the maven eclipse plugin. I did this by first adding a profile to my maven setttings.xml file ($HOME/.m2/settings.xml on UNIX).

<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

   <profiles>

     <!-- This is the additional bit you need -->
     <profile>
       <id>apache-plugin-snapshots</id>
       <pluginRepositories>
         <pluginRepository>
           <id>apache-snapshots</id>
           <name>Apache Snapshot Repository</name>
           <url>https://repository.apache.org/content/groups/snapshots-group/</url>
           <releases>
             <enabled>false</enabled>
           </releases>
           <snapshots>
             <enabled>true</enabled>
           </snapshots>
         </pluginRepository>
       </pluginRepositories>
     </profile>

   </profiles>

</settings>

and then run the mvn eclipse command:

mvn -Papache-plugin-snapshots org.apache.maven.plugins:maven-eclipse-plugin:2.9-SNAPSHOT:eclipse

which downloaded the newer plugin and then ran it against the project I had checked out.