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 Mon, 13 Apr 2009 00:21:47 GMT

That's because you should have specified the xmlns on the <type> child of the <restrict>
in the macrodef.

--- On Sun, 4/12/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: Sunday, April 12, 2009, 4:12 PM
> Matt,
> Thanks for your help.
> 
> I tried the latest nightly snapshot, which works.
> 
> 
> 1004  wget http://svn.apache.org/snapshots/ant/ant_20090411211853.tar.gz
>  1005  tar zxvf ant_20090411211853.tar.gz 
> 1008  bash build.sh 
> 1017  ./ant -f /tmp/blah.xml
> 
> -bash-3.1$ ./ant -f /tmp/blah.xml 
> Buildfile: /tmp/blah.xml
> 
> BUILD FAILED
> /tmp/blah.xml:28: Missing /tmp/bin:/tmp/chat:/tmp/client
> 
> 
> 
> It does not work on 1.7.1.
> 
> 
> On either windows or linux running ant 1.7.1 it gives the
> same error
> message:
> bash-3.1$ ant -f blah.xml 
> Buildfile: blah.xml
> 
> BUILD FAILED
> /tmp/blah.xml:28: restrict doesn't support the nested
> "type" element.
> 
> Total time: 0 seconds
> -bash-3.1$ ant -version
> Apache Ant version 1.7.1 compiled on June 27 2008
> 
> <project name="main">
>   <type
> xmlns="antlib:org.apache.tools.ant.types.resources.selectors"
> type="dir" />
> 
> 
>   <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: Friday, April 10, 2009 9:32 PM
> To: Ant Users List
> Subject: RE: fail task if subdirectories do not exist.
> 
> 
> 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
> 
> 
> 
> ---------------------------------------------------------------------
> 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