ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject RE: fail task if subdirectories do not exist.
Date Sat, 11 Apr 2009 03:32:19 GMT

Sorry--in Ant trunk this works as posted--I thought maybe in 1.7.1 as well, so upgrade if
you're on 1.7.0!  :)  Otherwise, you can use:

<type xmlns="antlib:org.apache.tools.ant.types.resources.selectors" type="dir" />

Regards,
Matt

--- On Fri, 4/10/09, Lucas Albers <smurfbait@hotmail.com> wrote:

> From: Lucas Albers <smurfbait@hotmail.com>
> Subject: RE: fail task if subdirectories do  not exist.
> To: "'Ant Users List'" <user@ant.apache.org>
> Date: Friday, April 10, 2009, 5:39 PM
> This error occurs:
> /tmp/build2.xml:22: restrict doesn't support the nested
> "type" element.
> 
> 
> <project name="main">
> 
>   <macrodef name="assertDirs"
> backtrace="false">
>     <element name="rc" implicit="true" />
>     <sequential>
>       <difference
> id="assertDirs.missing">
>         <rc />
>         <restrict>
>           <rc />
>           <type type="dir"
> />
>         </restrict>
>       </difference>
> 
>       <fail message="Missing
> ${toString:assertDirs.missing}">
>         <condition>
>           <resourcecount
> when="gt" count="0" refid="assertDirs.missing" />
>         </condition>
>       </fail>
>     </sequential>
>   </macrodef>
> 
>   <assertDirs>
>     <filelist id="dirs" dir="${basedir}"
> files="bin,chat,client" />
>   </assertDirs>
> </project>
> 
> 
> -----Original Message-----
> From: Matt Benson [mailto:gudnabrsam@yahoo.com]
> 
> Sent: Thursday, April 09, 2009 4:21 PM
> To: Ant Users List
> Subject: Re: fail task if subdirectories do not exist.
> 
> 
> Here's a cool example if I do say so myself:
> 
> <project>
> 
>   <macrodef name="assertDirs"
> backtrace="false">
>     <element name="rc" implicit="true" />
>     <sequential>
>       <difference
> id="assertDirs.missing">
>         <rc />
>         <restrict>
>           <rc />
>           <type type="dir"
> />
>         </restrict>
>       </difference>
> 
>       <fail message="Missing
> ${toString:assertDirs.missing}">
>         <condition>
>           <resourcecount
> when="gt" count="0" refid="assertDirs.missing" />
>         </condition>
>       </fail>
>     </sequential>
>   </macrodef>
> 
>   <assertDirs>
>     <filelist id="dirs" dir="${basedir}"
> files="bin,chat,client" />
>   </assertDirs>
> </project>
> 
> Wrap that macrodef up and take it wherever you like!
> 
> HTH,
> Matt
> 
> --- On Thu, 4/9/09, Lucas Albers <smurfbait@hotmail.com>
> wrote:
> 
> > From: Lucas Albers <smurfbait@hotmail.com>
> > Subject: fail task if subdirectories do  not
> exist.
> > To: "'Ant Users List'" <user@ant.apache.org>
> > Date: Thursday, April 9, 2009, 4:35 PM
> > How can I a fail task for a directory
> > resource count?
> > I can see the syntax for failing if a file does not
> exists
> > as part of a
> > resource.
> > I do not know the syntax to fail if a directory that
> is
> > part of a resource
> > does not exist:
> > 
> > See sample code:
> > 
> > 
> > Item 1:
> > <fail message="Files are missing.">
> >     <condition>
> >         <not>
> >         
>    <resourcecount
> > count="2">
> >               
> 
> > <fileset id="fs" dir="."
> includes="one.txt,two.txt"/>
> >            
> > </resourcecount>
> >         </not>
> >     </condition>
> > </fail>
> > 
> > Item 2:
> > <fail message="missing dir:
> > bin"><condition><not><available
> > file="bin"
> >
> type="dir"/></not></condition></fail>
> > <fail message="missing dir:
> > chat"><condition><not><available
> > file="chat"
> >
> type="dir"/></not></condition></fail>
> > <fail message="missing dir:
> > client"><condition><not><available
> > file="client"
> >
> type="dir"/></not></condition></fail>
> > 
> > 
> > 
> > How can I use a resource count to check for the
> existence
> > of subdirectories?
> > I can see how to it it by defining each one, and I
> would
> > prefer to check it
> > via a property value in a resourecount thingamabob.
> > 
> > Thx. 
> > 
> > Ps:
> > I read the documentation but problem lies between
> keyboard
> > and chair.
> > 
> > 
> >
> ---------------------------------------------------------------------
> > 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
> 
> 
> 
> ---------------------------------------------------------------------
> 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