You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Jeffrey E Care <ca...@us.ibm.com> on 2010/04/15 04:36:15 UTC

Check that path elements exist?

Before I write my own, if there a way to check that the elements of a path 
actually exist (or optionally that at least one exists)?

I've checked the manual backwards & forwards and I don't see a way to 
check this with existing tasks or conditions.

____________________________________________________________________________________________ 

Jeffrey E. (Jeff) Care 
carej@us.ibm.com 
IBM WebSphere Application Server 
WAS Release Engineering 




Re: Check that path elements exist?

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-04-15, Jason Trump <tr...@gmail.com> wrote:

> is there an 'ant cookbook' somewhere on the web to collect stuff like
> this?

A few things are inside the Wiki but I don't think there is a structured
page collecting snippets.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: Check that path elements exist?

Posted by Jason Trump <tr...@gmail.com>.
that's a clever formula.  is there an 'ant cookbook' somewhere on the web to
collect stuff like this?  sorry to be slightly off-topic, but seems like it
would be a valuable community resource.

jason

On Wed, Apr 14, 2010 at 9:01 PM, Stefan Bodewig <bo...@apache.org> wrote:

> On 2010-04-15, Jeffrey E Care <ca...@us.ibm.com> wrote:
>
> > Before I write my own, if there a way to check that the elements of a
> path
> > actually exist (or optionally that at least one exists)?
>
> I assume you mean the <pathelement>'s of a <path>.  <resourcecount>,
> <restrict> and <exists> are the ingredients that should help.
>
> If you wrap your <path> in a <restrict> using <exists> as selector you
> get only the existing elements.  <resourcecount> will count them and if
> it is greater than 0 you obviously have at least one - likewise if you
> count the path itself and compare the numbers you'll know whether all
> elements exist.
>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

Re: Check that path elements exist?

Posted by Jeffrey E Care <ca...@us.ibm.com>.
Stefan Bodewig <bo...@apache.org> wrote on 04/15/2010 12:01:56 AM:

> On 2010-04-15, Jeffrey E Care <ca...@us.ibm.com> wrote:
> 
> > Before I write my own, if there a way to check that the elements of a 
path
> > actually exist (or optionally that at least one exists)?
> 
> I assume you mean the <pathelement>'s of a <path>.  <resourcecount>,
> <restrict> and <exists> are the ingredients that should help.
> 
> If you wrap your <path> in a <restrict> using <exists> as selector you
> get only the existing elements.  <resourcecount> will count them and if
> it is greater than 0 you obviously have at least one - likewise if you
> count the path itself and compare the numbers you'll know whether all
> elements exist.

That worked perfectly, thanks.

And shame on me for posting this to dev instead of user...

Re: Check that path elements exist?

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-04-15, Jeffrey E Care <ca...@us.ibm.com> wrote:

> Before I write my own, if there a way to check that the elements of a path
> actually exist (or optionally that at least one exists)?

I assume you mean the <pathelement>'s of a <path>.  <resourcecount>,
<restrict> and <exists> are the ingredients that should help.

If you wrap your <path> in a <restrict> using <exists> as selector you
get only the existing elements.  <resourcecount> will count them and if
it is greater than 0 you obviously have at least one - likewise if you
count the path itself and compare the numbers you'll know whether all
elements exist.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org