ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: How to detect missing jars in a <path>?
Date Mon, 12 Dec 2005 10:26:03 GMT
Quick hack:

<project>

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


    <scriptdef name="checkpath" language="javascript">
        <attribute name="refid"/>
        <attribute name="message"/>
        <![CDATA[
            refid  = attributes.get("refid");
            message = attributes.get("message");
            sb = new java.lang.StringBuffer();
            
            path = project.getReference(refid);
            includedFiles = path.list();                            
            for(i=0; i<includedFiles.length; i++) {
                file = new java.io.File(includedFiles[i]);
                if (!file.exists()) {
                    if (sb.length() > 0) sb.append(",");
                    sb.append(includedFiles[i]);
                }
            }
            
            if (sb.length() > 0) {
                project.setNewProperty(message, sb.toString());
            }
        ]]>
    </scriptdef>


    <checkpath refid="xyz" message="missed"/>
    <fail if="missed" message="Missing files: ${missed}"/>

</project>


Jan
 

>-----Urspr√ľngliche Nachricht-----
>Von: Bertrand Delacretaz [mailto:bdelacretaz@apache.org] 
>Gesendet: Montag, 12. Dezember 2005 10:20
>An: user@ant.apache.org
>Betreff: How to detect missing jars in a <path>?
>
>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
>
>

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


Mime
View raw message