You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2005/12/12 10:20:25 UTC

How to detect missing jars in a ?

Hi,

I'd like a construct like

<path id="xyz">
   <pathelement path="ok.jar"/>
   <pathelement path="missing.jar"/>
</path>

to fail if missing.jar is not available.

Is there a way without using a separate <available/> element (which 
means having the missing.jar name in two places, unless I'm missing 
something)?

Making the Path class configurable to cause an error instead of logging 
the "dropping " + f + " from path as it doesn't exist" could be a 
solution, but I'm wondering if there's an easier way, without 
duplicating jar names.

--
   Bertrand Delacretaz
   independent consultant, Lausanne, Switzerland
   http://www.codeconsult.ch


Re: How to detect missing jars in a ?

Posted by Ken Gentle <j....@acm.org>.
I *knew* there was a solution to this problem (as I'd used it several 
years ago to demonstrate to an unbelieving group that application 
classpath was full of junk) - and it only took me two hours to find it again...

JWhich, by Mike Clark, has a mode to validate classpaths:

To validate the class path and report any non-existent or invalid 
class path entries:
java JWhich -validate
I toyed with an ant task for this way back then, but can't put my 
hands on it. :(.  I think I trashed it when the "whichresource" task 
made it's debut.

JWhich is available at http://www.clarkware.com/software/jwhich.zip

HTH

         Ken


At 04:20 2005-12-12, you wrote:
>Hi,
>
>I'd like a construct like
>
><path id="xyz">
>   <pathelement path="ok.jar"/>
>   <pathelement path="missing.jar"/>
></path>
>
>to fail if missing.jar is not available.
>
>Is there a way without using a separate <available/> element (which 
>means having the missing.jar name in two places, unless I'm missing something)?
>
>Making the Path class configurable to cause an error instead of 
>logging the "dropping " + f + " from path as it doesn't exist" could 
>be a solution, but I'm wondering if there's an easier way, without 
>duplicating jar names.
>
>--
>   Bertrand Delacretaz
>   independent consultant, Lausanne, Switzerland
>   http://www.codeconsult.ch
>
>
>

Re: How to detect missing jars in a ?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 12 déc. 05, à 11:57, Steve Loughran a écrit :

> ...Sounds to me like you've just added a new condition to Ant, 
> Monsieur Delacretaz, called something like <pathexists> , which 
> verifies that every element in a path is present, logs at -verbose 
> level if one is missing (and perhaps sets a property to a 
> filelist/path of missing items)...

Thanks for confirming that it doesn't exist yet, I was wondering if I 
was missing something obvious.

> something like
> <condition property="missing.path">
>   <available pathref="xyz" missingpathid="xyz.missing" 
> textproperty="message" />
> </condition>
> <fail if="missing.path">Missing files ${message}</fail>

Sounds good, I'll try to come up with something in my Copious Free 
Time...

Actually, if the JVMs would check existence of all jar files passed in 
the classpath, it would make our lives easier in many places.

-Bertrand

Re: How to detect missing jars in a ?

Posted by Steve Loughran <st...@apache.org>.
Bertrand Delacretaz wrote:
> Hi,
> 
> I'd like a construct like
> 
> <path id="xyz">
>   <pathelement path="ok.jar"/>
>   <pathelement path="missing.jar"/>
> </path>
> 
> to fail if missing.jar is not available.
> 
> Is there a way without using a separate <available/> element (which 
> means having the missing.jar name in two places, unless I'm missing 
> something)?
> 
> Making the Path class configurable to cause an error instead of logging 
> the "dropping " + f + " from path as it doesn't exist" could be a 
> solution, but I'm wondering if there's an easier way, without 
> duplicating jar names.
> 

Sounds to me like you've just added a new condition to Ant, Monsieur 
Delacretaz, called something like <pathexists> , which verifies that 
every element in a path is present, logs at -verbose level if one is 
missing (and perhaps sets a property to a filelist/path of missing items).

something like
<condition property="missing.path">
   <available pathref="xyz" missingpathid="xyz.missing" 
textproperty="message" />
</condition>
<fail if="missing.path">Missing files ${message}</fail>

implementations & tests gratefully accepted

-steve

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