ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "michael sorens" <>
Subject Re: manipulating property strings
Date Wed, 02 Feb 2005 15:18:48 GMT
With the pointer to the <redirector>, I was able to rewrite the task to avoid a temp
file. However, that introduced a different problem.

When I do this sequence (i.e. *with* a temp file):
	<exec error="tempfile"...
	<loadfile srcfile="tempfile" property="errors.present"><filterchain>...
	<fail if "errors.present">...
and there are NO errors (i.e. the filterchain that greps for error messages left errors.present
unset), the fail is not executed. (This is the desired behavior.)

However, when I do this (without a temp file):
	<exec...><redirector errorproperty="errors.present"><errorfilterchain>...
	<fail if "errors.present">...
then the fail *is* executed even when there are NO error messages collected by the errorfilterchain.

The problem, of course, is that the property is being set (albeit to an empty value) which,
to ant, means it is true.

So: any way to make CASE 2 behave like CASE 1? Or, failing that, is there anyway to examine
a property with "higher" resolution, i.e. to notice that it has an empty string or a non-empty

Here's a concrete example. As shown, two lines contain error messages, so the fail is executed
showing those two lines. If you delete the "ERR" from both lines, the "fail" is still executed.

     <target name="redirect-test">
		<property name="testfile" value="/usr/tmp/test.dat"/>
		<echo file="${testfile}">
line one
ERR line two
line three
line ERR four
		<exec executable="perl" dir=".">
			<arg line="-ne 'print' ${testfile}"/>
			<redirector outputproperty="redirector.out">
						<contains value="ERR"/>
		<delete file="${testfile}"/>
		<fail message="[[${redirector.out}]]" if="redirector.out"/>

On Mon, 31 Jan 2005 08:17:52 -0800 (PST), Matt Benson <> wrote:

> --- michael sorens <> wrote:
>> Is there a way to manipulate the contents of a
>> multi-line property string as if it were a file?
>> Right now I collect stderr of an exec to a temp-file
>> (error="filename") then read the temp-file and
>> manipulate via filterchain, storing into a property,
> [SNIP]
>> ...then deleting the temp-file.
>> I'm looking for a more elegant solution.
> Jan's example on redirector is not quite cut & paste
> but it should give you the idea.  If you can't get it
> working after reading the manual and playing around
> for a while let us know.
> Thanks,
> Matt
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - Easier than ever with enhanced search. Learn more.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message