Thanks Dominique. I'll try this. -Vincent
> -----Original Message----- > From: Dominique Devienne [mailto:[EMAIL PROTECTED] > Sent: 24 May 2004 01:15 > To: 'Ant Users List' > Subject: RE: How to create paths that depend on a condition? > > > From: Vincent Massol [mailto:[EMAIL PROTECTED] > > > > Ok, I've found a solutiob but it looks really ugly: > > > > <dirset dir="${src.test.dir}/share-13-14"> > > <and> > > <filename name="share-13-14"/> > > <or> > > <selector if="j2ee13.available"/> > > <selector if="j2ee14.available"/> > > </or> > > </and> > > </dirset> > > > > Any better solution? > > Maybe... If I understand correctly, you want to include the share-12-13-14 > path element only if either j2ee1[34]* properties are defined. I haven't > tested this, but I think I remember the 'path' attribute of <pathelement> > will accept an empty value, simply ignoring it. So > > <condition property="j2ee1[34].srcdir" > value="${src.test.dir}/share-13-14"> > <or> > <isset property="j2ee13.available" /> > <isset property="j2ee14.available" /> > </or> > <condition> > <property name="j2ee1[34].srcdir" value="" /> > > <javac [...]> > <src> > <pathelement location="${src.test.dir}/share-12-13-14"/> > <pathelement path="${j2ee1[34].srcdir}"/> > </src> > </javac> > > Should do what you want, is easy enough to read, and is pure Ant. --DD > > <usual-lamentation> > I'd rather have if/unless on all Ant elements, as I lament often, > rather than rely on knowledge of edge cases behavior in <pathelement> > though. I've created for my own task a Path-derivative that accepts > nested <element>s, with built-in if/unless/iftrue/unlessTrue/os/osFamily > condition attributes, but it's only really useful in my own tasks only, > unless you id/refid that Path, or when using the semi-official ant:type > magic attribute (which still works only with tasks with add*(Path), > and not the ones using create*(Path)). > > Anyways, I think your use case is yet more evidence for the usefulness > of generalized if/unless. > </usual-lamentation> > > > > -----Original Message----- > > > From: Vincent Massol [mailto:[EMAIL PROTECTED] > > > > > > I'd like to create a <path> that depends on some property being > > > defined or not. This is for putting inside the <javac> task. > > > I cannot find the right combination. Here's what I'd like to do: > > > > > > <javac [...]> > > > <src> > > > <pathelement location="${src.test.dir}/share-12-13-14"/> > > > ---> start here > > > <dirset dir="${src.test.dir}/share-13-14"> > > > <and> > > > <depth max="0"/> > > > <or> > > > <selector if="j2ee13.available"/> > > > <selector if="j2ee14.available"/> > > > </or> > > > </and> > > > </dirset> > > > ---> stop here > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]