ant-user mailing list archives

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

> 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
building">
	<condition property="missing.properties">
		<or>
			<equals arg1="${compile.to}" arg2="$${compile.to}"/>
			<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}"/>
		</or>
	</condition>
	<antcall target="help"/>
</target>

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

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:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message