The Road To Maven
Join the DZone community and get the full member experience.Join For Free
Maven is one of those projects I’ve looked at periodically over the
years but I’ve never been persuaded by the payback of a learning curve
that looks pretty steep from the bottom of a mound of XML. On my most
recent day trip to Maven, however, I found a reason to stay.
The reason was a Sonatype Video that showed materializing an Eclipse project from a dependency. I thought of the number of times I’d manually done this, and the time it took, and the payback was obvious.
So where to begin on the road to Maven? I quite like Oddjob’s own Oddjob/Ant build combination. It gives a graphical view to what would otherwise be a mass of Ant build files, and includes the ability to re-run parts without needing to re-run everything. Here is a picture of it in action:
I looked at embedding Maven so I could have a similar Oddjob Maven build but this did not seem a well trodden path. So, reluctant to give up my GUI in favour of a big messy console build, I decided against switching completely from Ant to Maven, at least for the time being.
Instead I decided to focus on getting the core Oddjob jars in Maven Central. The road most travelled appears to go via the Sonatype OSS Repository so down it I went. Documentation in the form of the Sonatype OSS Maven Repository Usage Guide was easy to follow and soon I had a variation of the example Ant task uploading jars to a Staging repository.
The docs were a bit light on testing the Staged artefacts but it proved as simple as deleting the locally installed jars from my .m2/repository/uk/co/rgordon repository location and adding the staging repository to my .m2/settings.xml file like this:
<profile> <id>stage</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>stage</id> <name>Nexus Staging Repo</name> <url>https://oss.sonatype.org/content/repositories/ukcorgordon-557/ </url> </repository> </repositories> </profile>
Which can be edited and updated using the Eclipse Preferences seen here:
(Although I seemed to need to restart Eclipse to pick up the new settings)
And before this will work YOU MUST CLOSE the staging repository!
Having proved my jars worked with a small project it’s a few more clicks to release the jars to Maven Central and here they are.
So now you too can embed Oddjob in your own Maven project. Just add these lines to your POM:
<dependency> <groupId>uk.co.rgordon</groupId> <artifactId>oddjob</artifactId> <version>1.1.0</version> </dependency>
Where next on the road to Maven? I don’t know yet but I’m quite looking forward to it.
Published at DZone with permission of Rob Gordon, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.