Welcome back old friend
[ kevin ] 20:27, Thursday, 25 September 2003

In a moment of weakness at the start of a project I decided to use Maven for build management (hey all the cool kids were doing it and I felt really square). Now Maven is great as long as your happy to play in it's sandbox with the toys it provides. Beware if you step outside of the sandbox though. Nanny will come and slap your botty hard. You see nanny manges all the dependencies between "plugins" so if you want to use the new version of aspectj to weave some sexy aspects through your code and a couple of third party libs and that's not the way nanny does it, well put it this way, your bot bot is going to be sore.

So I looked at adding custom targets to my maven.xml file (effectivley duplicating a lot of the code in the plugins to reorder the dependencies), but it looked like more effort than it was worth so I decided to go back to crawling back to my old friend Ant.

My favorite thing about Maven is its jar loading. Add a dependency to your project and down comes the jar. It's added to your compile classpath and into your war lib dir, no mess, no fuss. I wanted this in Ant.

I grabbed a copy of the latest and greatest source code and built a nice fresh version. 1.6 has some nice new features the one I was really interested in was import . I'd used an early version of this when I was playing with Centipede a year or so ago.

I grabbed the dependency section out of my Maven project.xml file and stuck it into a seperate file (dependencies.xml ).

<dependencies>
  <dependency>
    <id>concurrent</id>
    <version>1.3.2</version>
    <url>http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html</url>
    <properties>
      <war.bundle>true</war.bundle>
    </properties>
  </dependency>
</dependencies>

Then I created an XSLT (dependency-targets.xslt) that created the ant targets to make the project class path and fetch each of the jars I didn't have it in my local jar repository.

All that was left was add the style and import tasks to my build.xml and make my compile target depend on the generated fetch-dependencies target.

<!-- import dependencies targets -->
<style
  basedir="${basedir}"
  out="${work.dir}/dependency-targets.xml"
  in="dependencies.xml"
  style="${src.build}/dependency-targets.xslt">

  <param name="project-name" expression="${ant.project.name}"/>
  <param name="local-repository" expression="${repository.local}"/>
  <param name="remote-repository" expression="${repository.remote}"/>
</style>

<import file="${work.dir}/dependency-targets.xml"/>

45 minutes and it was all good. Now my friend Ant and I can play together and nannys spankings are a distant and best forgotten memory.

TrackBack
Comments

Thanks for that interesting post. It makes great reading! Do you need a payday loans?

--payday loans, November 30, 2004 11:11 AM

Thanks for that insightful comment! It makes interesting reading, especially when I need a payday advance .

--payday advance , November 30, 2004 02:58 PM

Nanny

--Jeff Anderson, August 3, 2005 08:18 PM

It was not that hard , ah?

--Helen , December 17, 2005 05:21 PM
Post a comment









Remember personal info?