ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charlton_R...@daifukuamerica.com
Subject RE: fileset fails when base dir is missing
Date Mon, 06 Dec 2004 21:00:06 GMT
Approach #1 is in fact what I ended up doing.  (Actually, I used the 
"available" task, not the generalized "condition" task.  But the result 
was the same.)  It wasn't aesthetically pleasing, but it worked.  Any time 
you have a dummy directory sitting around, you know there's been a hack, 
don't you? :-)

"Murray, Mike" <mbm@ptc.com> wrote on 12/06/2004 01:52:48 PM:

> I know of no direct way to do it, so how best to complete it depends
> on the scope.  If you have many such optional directories, I can 
> come up with a couple ugly things to try. 
> 
> 1) Conditionally define properties that point to the real location, 
> or a dummy location, depending on the existence of the real 
> location.  Then use this property in your fileset.
>       <condition property="lib_dir" value="lib">
>          <available file="lib" type="dir"/>
>       </condition>
>    <property name="lib_dir"   value="empty_dummy_dir"/>
> 
> 2) Define each fileset in its own target, and then combine all 10 
> together in a separate definition.  (Not sure if this would work.)
> 
> These are two ideas that immediately come to mind.  Maybe there is 
> something more clever that would be better.
> 
> -----Original Message-----
> From: Charlton_Rose@daifukuamerica.com
> [mailto:Charlton_Rose@daifukuamerica.com]
> Sent: Monday, December 06, 2004 2:19 PM
> To: Ant Users List
> Subject: RE: fileset fails when base dir is missing
> 
> I thought of this, actually.  But what puzzles me is how to leverage the 

> value of "mod_classdir.check", once it has been set (or not set), inside 

> my path defnition.  I could, conceivably, have two path definitions, one 

> which includes the offendiring fileset, and another which does not,, and 

> then I could select the appropriate path based on the the value of 
> mod_classdir.check.  However, this approach certainly is not scalable, 
> since if I had 10 filesets involved, then I would need 1024 different 
path 
> specifications.
> 
> How would you get to a conditionally included fileset from a 
conditionally 
> set property?  Does <fileset> have an "if" or "unless" attribute like 
the 
> "target" tag does?
> 
> "Murray, Mike" <mbm@ptc.com> wrote on 12/06/2004 01:09:36 PM:
> 
> > It sure would be nice, but since it isn't you're left doing it the 
> > long, and complicated, way.  That is, creating additional targets 
> > with dependencies and conditions to get the desired conditional 
> > behavior. The property can be set as follows.
> > 
> >    <target name="mod_classdir.check">
> >       <condition property="mod_classdir.exists">
> >          <available file="${mod_classdir}" type="dir"/>
> >       </condition>
> >    </target>
> > 
> > -----Original Message-----
> > From: Charlton_Rose@daifukuamerica.com
> > [mailto:Charlton_Rose@daifukuamerica.com]
> > Sent: Monday, December 06, 2004 1:58 PM
> > To: Ant Users List
> > Subject: Re: fileset fails when base dir is missing
> > 
> > That's a clever hack, but it won't work well in my situation, since 
some 
> 
> > of the filesets may be rooted in directories that cannot be created. 
> > Wouldn't it be nice if the <fileset> tag had an attribute that allowed 

> you 
> > do say, "It's OK if it doesn't exist"?  Something like this:
> > 
> > <fileset dir="somedir" if-base-dir-is-missing="ignore">...</fileset>
> > 
> > Anyone else have a good idea?
> > 
> > "Alexey N. Solofnenko" <A.Solofnenko@mdl.com> wrote on 12/06/2004 
> 12:44:29 
> > PM:
> > 
> > > I usually execute <mkdir> in this situation - an empty directory 
does 
> > > not affect anything else and makes some commands happy.
> > > 
> > > - Alexey.
> > > 
> > > Charlton_Rose@daifukuamerica.com wrote:
> > > 
> > > >I am constructing a classpath that includes a fileset.  Sometimes, 
> the 
> > > >base directory for that fileset does not exist.  I would like Ant 
to 
> > > >simply accept this as an empty fileset and move on.  Instead, Ant 
> quits 
> > 
> > > >with an error, complaining that the directory is not found.  How 
> should
> > > >I 
> > > >resolve this problem?
> > > >
> > > >In other words...
> > > >
> > > ><path id="cp">
> > > >        <fileset dir="lib" includes="**/*.jar"/>
> > > >        <pathelement location="a.jar"/>
> > > >        <pathelement location="b.jar"/>
> > > >        <pathelement location="c.jar"/>
> > > ></path>
> > > ><javac
> > > >        destdir="${classes}"
> > > > 
> > > >
> > > >        <src path="${src}"/>
> > > >        <classpath>
> > > >                <path refid="cp"/>
> > > >        </classpath>
> > > ></javac>
> > > >
> > > >...fails if the "lib" folder does not exist.  I would rather have 
Ant
> > > >just 
> > > >keep on going.  Any ideas?
> > > > 
> > > >
> > > 
> > > 
> > > 
---------------------------------------------------------------------
> > > 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message