ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ylan Segal" <>
Subject RE: Failing build on attempted evaluation of undefined properties?
Date Tue, 19 Mar 2002 22:01:03 GMT

> Hi,
> 	We are having problems with builds that do *not* fail when
> they use an undefined property as part of a file or directory name.

I use a check target that checks if all needed properties are set, and fails
if they are not.

It looks like this:

<target name="check" description="Checks weather project is ready for
	<condition property="">
			<equals arg1="${}" arg2="$${}"/>
			<equals arg1="${depend.cache.home}" arg2="$${depend.cache.home}"/>
			<equals arg1="${dist.home}" arg2="$${dist.home}"/>
			<equals arg1="${javadoc.home}" arg2="$${javadoc.home}"/>
			<equals arg1="${doccheck.home}" arg2="$${docheck.home}"/>
			<equals arg1="${packages}" arg2="$${packages}"/>
			<equals arg1="${lib.home}" arg2="$${lib.home}"/>
			<equals arg1="${extlibs.home}" arg2="$${extlibs.home}"/>
	<antcall target="help"/>

<target name="help" if="">
	<echo>Please set all properties!!! (or a more helpfull message).
	<fail message="Not all needed properties are set!!!"/>

If all other targets depend on check, then if properties are missing the
build will fail.
I have found this does the trick.

Since the release of ant 1.4.1 (which is the one I use) there has been an
adition to the condition task that now supports the <isset> element that
checks for a property being set.

> PS: I know I can achive this result by using <fail> tasks with
> the unless modifiers; but then I have to do it explicitly for
> every property I use. I don't want to do that.

In my example, you end up having two extra targets, but not one extra for
each property you need (which would quickly become unmanagable).

Does this help?

Ylan Segal.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message