Friday, October 10, 2008

Maven

Sonatype Nexus is great as it simplifies maven. Maven is a useful java tool that allows for simplification of development within a team by removing unnecessary complexity within build scripts however it may seem overwhelming with configuration and repository management.

Development teams should use Sonatype Nexus to provide a cache of public repositories. This also ensures that each developer is using the same internal repository and simplifies configuration on each machine.

The following public repositories should be added to nexus. Note: www.ibiblio.org is a maven 1 repository and you would have to tell nexus to remap virtually present this as a maven 2 repository.

* http://repo1.maven.org/maven2/
* http://download.java.net/maven/2/
* http://repository.codehaus.org/
* http://www.ibiblio.org/maven/



Flexibility



If you need to still need to customise your build you can still use ant by using the antrun plugin.


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<tasks>
<echo message="Hello World"/>
<mkdir dir="target/sample"/>
<javac classname="tim.HelloWorld" classpathref="maven.plugin.classpath" fork="true" dir="target/sample"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>tim.example</groupId>
<artifactId>MyHelloWorld</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>

2 comments:

Kai Hendry said...

That build XML is ridiculous!

Use a Makefile dude.

Anonymous said...

Very good......