samples/libs/build.xml
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:53:42 +0200
changeset 79 76b5dfab3745
parent 21 0aee50e597da
child 82 d098b8e4de15
permissions -rw-r--r--
support for download binaries from inside a build, tested on Lookup's JAR
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <project name="Downloads necessary libraries" default="libraries" basedir=".">
     3     <target name="clean">
     4         <delete dir="dist"/>
     5     </target>
     6     
     7     <target name="libraries">
     8         <antcall target="-library">
     9             <param name="library" value="junit-4.4"/>
    10             <param name="url" value="http://switch.dl.sourceforge.net/sourceforge/junit/junit-4.4.jar"/>
    11         </antcall>
    12         <antcall target="-library-from-zip">
    13             <param name="library" value="org-openide-util"/>
    14             <param name="library.include" value="**/org-openide-util.jar"/>
    15             <param name="url" value="http://deadlock.netbeans.org/hudson/job/javadoc-nbms/lastSuccessfulBuild/artifact/nbbuild/nbms/platform8/org-openide-util.nbm"/>
    16         </antcall>
    17     </target>
    18     
    19     <!-- support methods -->
    20     
    21     <target name="-library-check">
    22         <fail message="You need to specify library name" unless="library"/>
    23         <fail message="You need to specify url" unless="url"/>
    24         
    25         <property name="library.jar" location="dist/${library}.jar"/>
    26         <property name="library.zip" location="dist/${library}.zip"/>
    27         
    28         <echo message="Checking for ${library.jar}"/>
    29         <available file="${library.jar}" property="library.available"/>
    30     </target>
    31     <target name="-library" depends="-library-check" unless="library.available">
    32         <mkdir dir="dist"/>
    33         <get dest="${library.jar}" src="${url}"/>
    34         
    35         <fail message="Now the library ${library} should be downloaded">
    36             <condition>
    37                 <not><available file="${library.jar}"/></not>
    38             </condition>
    39         </fail>
    40     </target>
    41     <target name="-library-from-zip" depends="-library-check" unless="library.available">
    42         <mkdir dir="dist"/>
    43         <get dest="${library.zip}" src="${url}"/>
    44         <unzip dest="dist" src="${library.zip}">
    45             <patternset includes="${library.include}"/>
    46             <mapper type="flatten"/>
    47         </unzip>
    48         
    49         <fail message="Now the library ${library} should be downloaded">
    50             <condition>
    51                 <not><available file="${library.jar}"/></not>
    52             </condition>
    53         </fail>
    54     </target>
    55 </project>