Friday, July 24, 2009

Ant refid resolution 1.5, 1.6, 1.7

I noticed some behaviour changes in Ant related to refids. In Ant 1.5.x a fileset refid has to be defined before being used. So for example if I define a fileset in target "a" and then call target "b" which uses the refid, the build will fail because target "a" was never run and never set up the refid.

This behaviour changed in Ant 1.6.x, so that Ant tries to be more intelligent and automatically searches for refids that are defined in the build, but not necessarily run. So in the above example, Ant silently succeeds and the refid is found in target "a" even though that target was never actually called. This seems like strange behaviour to me, because it's not well documented and seems like it could produce some tricky bugs. I guess the Ant developers also thought this behaviour was not ideal because in Ant 1.7 the same automatic refid resolution works but now produces a warning. I briefly tried to track down some discussion related to this in the ant developer mailing list archives, but I was unsuccessful in finding anything.

No comments: