ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Abley <james.ab...@volantis.com>
Subject Re: Delete files if error log exist
Date Wed, 07 Feb 2007 16:42:59 GMT
So work with ANT, not against it.

<target name="do-it" depends="check-available, handle-log-found, 
handle-no-log" />

<target name="check-available">
     <available file="..." type="file" property="error.log.exist" />
</target>

<target name="handle-log-found" if="error.log.exist">
     <delete>
        <fileset dir="..." />
     </delete>
     <fail message="ERROR: Probable errors in the mom. Check 'error.log' 
in ${log.dir}" />
</target>

<target name="handle-no-log">
     ...
</target>

Something like that?

Ninju Bohra wrote:
> Ooops...it appears you might have a problem (or two)...
> 
> First off... I do not believe you can nest abritary task nodes within a <fail>
task...the only sub-element permitted is a single <condition> element...I will defer
to the ANT docs but I believe that is right
> 
> Based on what you said...you want to delete the files if a file is available.
> 
> The problem is:
> 
> Either the <available> task will find your 'log' file and the property 'error.log.exist'
at which point the <fail> task will trigger which will emit your message to the console,
HOWEVER the ant script will then stop...will not delete the files
> 
> ON the other hand if <available> task is unable to find the file, the property
will not be set...the <fail> will not trigger...however the <delete> will still
execute.
> 
> My $.02 cents worth,
> 
> Ninju
> 
>  
> 
> 
> ----- Original Message ----
> From: Mikael Petterson (KI/EAB) <mikael.petterson@ericsson.com>
> To: user@ant.apache.org
> Sent: Tuesday, February 6, 2007 12:57:03 PM
> Subject: Delete files if error log exist
> 
> 
> Hi,
> 
> I would like to confirm with you experts if I can write ( as below) to
> delete some files if an
> error log exist. Or is there a better way?
> 
> Cheers,
> 
> //mikael 
> 
> 
> <available file="${log.dir}/${log}" type="file"
> property="error.log.exist"/>
>         <fail message="ERROR: Probable errors in the mom. Check
> 'error.log' in ${log.dir}" if="error.log.exist">
>          <!--When generation fails. Remove all files since
> we don't want the wrong files to be checked in.-->
>          <delete>
>           <fileset dir="${output.dir}/${gen.pkg}" includes="**/*.java"/>
>          </delete>
>        </fail>
> 
> 
>  
> ____________________________________________________________________________________
> Don't get soaked.  Take a quick peak at the forecast
> with the Yahoo! Search weather shortcut.
> http://tools.search.yahoo.com/shortcuts/#loc_weather
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message