You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ken Gentle <j....@acm.org> on 2000/11/30 19:19:36 UTC

Conditionally constructing path elements?

Hey y'all!

I'm trying to make a cross platform build.xml, and I'm having some 
difficulty because the classpath is different (contains different path 
elements) on UNIX than on Win/NT.

On NT, there is an additional directory of jars that I need to include that 
aren't present on UNIX.

I was trying to use the :

     <classpath>
       <pathelement path="${classpath}" />
       <fileset dir="lib">
         <include name="**/*.jar" />
       </fileset;>
       <pathelement location="classes" />
     </classpath>

idiom, but I need to conditionally include one of the 'fileset' elements.

Any ideas/suggestions/examples/RTFMs?

Thanks!

         Ken
==========================================================================
J. Kenneth Gentle (Ken)       | Phone: (610)255-0361   FAX:(610)255-0418
Gentle Software, LLC          | Email: j.kenneth.gentle@acm.org
==========================================================================


Re: Conditionally constructing path elements?

Posted by Stefan Bodewig <bo...@apache.org>.
Ken Gentle <j....@acm.org> wrote:

> The interesting(!?) part of the issue is that a "normal" java
> CLASSPATH (or a UNIX or DOS PATH) wouldn't have any problem at all
> if one of the path elements did not exist - and that is what I'm
> trying to construct.

<path> doesn't have a problem if <pathelement> doesn't exist either,
the problem is <fileset> that insists on the dir to exist. 

You wouldn't be able to do what you want to do with a "normal"
CLASSPATH - if you could, you could use <pathelement>s as well and
you'd be done.

> I tried combinations of the 'available' tag and the 'if' attribute
> that of course failed - fileset doesn't implement the 'if'
> attribute.

Hmm, if you could define the whole <path> inside a <target>, you could
use the target's if attribute (currently it's not possible to define
<path>s as children of <target>).

Stefan

Re: Conditionally constructing path elements?

Posted by Ken Gentle <j....@acm.org>.
The interesting(!?) part of the issue is that a "normal" java CLASSPATH (or 
a UNIX or DOS PATH) wouldn't have any problem at all if one of the path 
elements did not exist - and that is what I'm trying to construct.

Perhaps the task could be made to skip a non-existent path element?

I tried combinations of the 'available' tag and the 'if' attribute that of 
course failed - fileset doesn't implement the 'if' attribute.  Perhaps the 
addition of an 'if' attribute to the fileset element or one of the other 
elements would be flexible enough to address this (and probably other) 
scenarios?

         Ken

At 01:26 PM 12/01/2000 +0100, Stefan Bodewig wrote:
>Ken Gentle <j....@acm.org> wrote:
>
> >>Right now I don't see an easy way to achieve what you want to do, so
> >>maybe creating and empty directory on Unix and point the fileset
> >>there might be a workaround.
> >
> > The directory in question is "owned" by a third party package
> > (thanks iPlanet), and I've an aversion to mucking with structures
> > owned by someone else.  In this case we may have to make an
> > allowance, eh? :^/
>
>Probably. Even when thinking about how to implement it (from the XML
>syntax point of view) so you could drop the directory once 1.3 is out
>(not too soon anyway), I don't get too far.
>
>Stefan

==========================================================================
J. Kenneth Gentle (Ken)       | Phone: (610)255-0361   FAX:(610)255-0418
Gentle Software, LLC          | Email: j.kenneth.gentle@acm.org
==========================================================================



Re: Conditionally constructing path elements?

Posted by Stefan Bodewig <bo...@apache.org>.
Ken Gentle <j....@acm.org> wrote:

>>Right now I don't see an easy way to achieve what you want to do, so
>>maybe creating and empty directory on Unix and point the fileset
>>there might be a workaround.
> 
> The directory in question is "owned" by a third party package
> (thanks iPlanet), and I've an aversion to mucking with structures
> owned by someone else.  In this case we may have to make an
> allowance, eh? :^/

Probably. Even when thinking about how to implement it (from the XML
syntax point of view) so you could drop the directory once 1.3 is out
(not too soon anyway), I don't get too far.

Stefan

Re: Conditionally constructing path elements?

Posted by Ken Gentle <j....@acm.org>.
Thanks for the response, Stefan.

At 09:34 AM 12/01/2000 +0100, Stefan Bodewig wrote:
>Ken Gentle <j....@acm.org> wrote:
>
> > I'm trying to make a cross platform build.xml, and I'm having some
> > difficulty because the classpath is different (contains different
> > path elements) on UNIX than on Win/NT.
> >
> >
> > On NT, there is an additional directory of jars that I need to
> > include that aren't present on UNIX.
>
>Does the directory exist and is empty or is the directory itself not
>present? The first case would be easy, you'd end up with an empty
>fileset that won't do any harm.

The directory does not exist on UNIX.


>Right now I don't see an easy way to achieve what you want to do, so
>maybe creating and empty directory on Unix and point the fileset there
>might be a workaround.

The directory in question is "owned" by a third party package (thanks 
iPlanet), and I've an aversion to mucking with structures owned by someone 
else.  In this case we may have to make an allowance, eh? :^/

>Stefan

==========================================================================
J. Kenneth Gentle (Ken)       | Phone: (610)255-0361   FAX:(610)255-0418
Gentle Software, LLC          | Email: j.kenneth.gentle@acm.org
==========================================================================



Re: Conditionally constructing path elements?

Posted by Stefan Bodewig <bo...@apache.org>.
Ken Gentle <j....@acm.org> wrote:

> I'm trying to make a cross platform build.xml, and I'm having some
> difficulty because the classpath is different (contains different
> path elements) on UNIX than on Win/NT.
> 
> 
> On NT, there is an additional directory of jars that I need to
> include that aren't present on UNIX.

Does the directory exist and is empty or is the directory itself not
present? The first case would be easy, you'd end up with an empty
fileset that won't do any harm.

Right now I don't see an easy way to achieve what you want to do, so
maybe creating and empty directory on Unix and point the fileset there
might be a workaround.

Stefan