jump to navigation

Ant, dependencies, and slow servers January 26, 2009

Posted by Phill in General J2EE.
Tags: , ,
comments closed

At work I’m working on an application which uses an Apache Ant script to build it. Unfortunately we haven’t yet got around to using Apache Ivy, however all dependencies are stored in a text file and then downloaded from a central server in the build script. Not an ideal solution but it works for our needs.

The problem comes when the central server we use to store the JAR files slows down to a crawl (which has happened quite a lot recently). The past few days, the build script has taken over 4 minutes to complete – and most of that time is spent downloading JAR files (unfortunately there are two JAR files which needed to be downloaded each time – it’s too complicated to go into now…)! So I decided to make a change to the build script.

Now, it should only download when I update the text file with the list of dependencies. How is this accomplished? By using the <condition> task:

<condition property="lib.uptodate">
<uptodate srcfile="${basedir}/lib-jarlist" targetfile="${lib.dir}/lastupdated.txt" />
<uptodate srcfile="${basedir}/lib-jarlist-compile-only" targetfile="${lib.dir}/lastupdated.txt" />

What this code is doing is checking two files (lib-jarlist and lib-jarlist-compile-only). If either of these two files have a newer timestamp than the target file (lastupdated.txt), than the condition will be TRUE. Then, all I need to do is put this in the download dependencies target:

<target name="download-deps" unless="lib.uptodate">
(download dependencies....)
<touch file="${lib}/uptodate.txt">

So, the target will only run if one of the JAR list files have been updated. Note the touch command at the end – this is important: it updates the file timestamp so that next time the script will see the update dependencies and not go off to the slow server for them.

It’s not a perfect solution, but will do until we can move to Ivy!


Building applications November 1, 2007

Posted by Phill in General J2EE, Other Stuff.
Tags: , , , ,
comments closed

I came across this email exchange today, courtesy of today’s post at Jeff Atwood’s blog.

Unfortunately the scenario was all-too-familiar for me: in my first job as a developer, I was working for a small company. This meant that we were very busy, and little things like documentation were often missed (of course, this is something which bigger companies have been guilty of as well…) My development workstation became “The development machine”. This meant that when we needed to deploy an application, someone would come to me and say “Phill, we need a new EAR file for application x” (it wasn’t actually called ‘application x’, but actually that would have been kind of cool). I would then go into my IDE, open up the project, and run the build process.

The problem came when I needed to get someone else up to speed on the project… trying to get someone else’s IDE to be exactly the same as yours is a total nightmare. The dependencies were all over the place, it took hours to get it all up and running.