Tuesday, April 8, 2008

Timestamp dependent task in Ant

Sometimes we need to do certain task in Ant that only need to be run if certain file or files has been updated. javac task has time dependency built-in already, but other tasks do not. Good thing we have ant-contrib library which has outofdate tasks.

Recently we have a need to do some manipulation on the content of an EAR file which require the EAR file to be expanded first. We do not want to keep expanding the EAR file if there is no update on the EAR file itself. This is a perfect situation to utilize the ant-contrib's outofdate task in combination with built-in ant's touch task.

So we have setup like this:
<target name="extract-source">
<ac:outofdate>
<sourcefiles>
<pathelement path="${app.name}.ear"/>
</sourcefiles>
<targetfiles path="${input.dir}/extract.ts"/>
<sequential>
<unjar src="${app.name}.ear"
dest="${input.dir}"
overwrite="yes"/>
<touch file="${input.dir}/extract.ts"/>
</sequential>
</ac:outofdate>
</target>

Where we have the timestamp of the ear file compared against a timestamp file that we generate/touch after the ear expansion. So if at any time there is a new ear file which is newer then it was last expanded we'll expand it again else we just go on with our life.

With so many built-in tasks in Ant, I wonder why a lot of the ant-contrib tasks are not merged into ant already.

Thursday, April 3, 2008

Redmine with Mercurial

Redmine just released a 0.7RC1 version. For those who does not know, Redmine is project management tools like Trac. It is developed using Ruby on Rails.

At the moment redmine has much more features that have been in Trac's request list for a while.

Some of the important features:
  • Multi projects support
  • Built-in support for numerable version controls. Pretty much most of the known open source tools out there, like: cvs, subversion, git, mercurial, bazaar, darcs.
This makes redmine one of my favorites tools at the moment.

Anyway, current integration between Redmine and mercurial has a slight incomplete feature where it does not able to show the different activities on the files between versions/revisions. So I had created a patch to mercurial_adapter.rb file to support that feature. The patch can be found here.

At the moment I am using hg status to pull the information, but it is not very efficient as it requires multiple calls to hg status for each revisions it processes. Originally I try to keep the original code calls to utilize the hg log which require 1 call and just parse the data. Unfortunately the regular hg log does not provide the file action information and I am unable to get the file_adds and files_dels to show anything on hg log --template.

I am currently running on Ubuntu 7.10 with standard ubuntu package of mercurial version 0.9.4. If anyone know how to get the file_adds and file_dels to work, please drop me a note.