Home | History | Annotate | Download | only in ant
      1 <project name="testng" default="dev" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
      2   
      3   <!-- ====================================================================== -->
      4   <!-- TestNG build file                                                      -->
      5   <!-- Created cbeust, April 26th, 2004                                       -->
      6   <!-- ====================================================================== -->
      7 
      8   <property file="build.properties" />
      9   <property name="optimize" value="false" />
     10 
     11   <!-- ====================================================================== -->
     12   <!-- PREPARE                                                                -->
     13   <!-- ====================================================================== -->
     14   <target name="prepare" depends="retrieve-dependencies"
     15           description="Performs all preparations required to build.">
     16     <tstamp />
     17     <mkdir dir="${build.dir}" />
     18     <mkdir dir="${other.jars.dir}" />
     19   </target>
     20 
     21   <!-- ====================================================================== -->
     22   <!-- DUMP                                                                   -->
     23   <!-- ====================================================================== -->
     24   <target name="dump" description="Dumps all properties." depends="prepare">
     25     <echoproperties />
     26   </target>
     27 
     28 	<!-- ====================================================================== -->
     29   <!-- VALIDATE                                                               -->
     30   <!-- ====================================================================== -->
     31 
     32   <target name="validate" description="Validates the build environment.">
     33     <!-- java greater than 1.6 required to build -->
     34     <condition property="requiredJavaVersion">
     35       <or>
     36         <equals arg1="${ant.java.version}" arg2="1.9" />
     37         <equals arg1="${ant.java.version}" arg2="1.8" />
     38         <equals arg1="${ant.java.version}" arg2="1.7" />
     39       </or>
     40     </condition>
     41     <fail unless="requiredJavaVersion"
     42           message="Java version 1.7 required." />
     43     <!-- validate ant version too ... -->
     44   </target>
     45 
     46   <!-- ==================================================================== -->
     47   <!-- COPY-RESOURCES                                                       -->
     48   <!-- ==================================================================== -->
     49 
     50   <target name="copy-resources" description="Copies resources.">
     51     <copy verbose="false"
     52           file="${src.resources.dir}/testngtasks"
     53           todir="${build.dir}" />
     54     <copy todir="${build.dir}">
     55       <fileset dir="${src.resources.dir}">
     56         <exclude name="**/.*" />
     57         <exclude name="**/CVS/*" />
     58       </fileset>
     59     </copy>
     60   </target>
     61 
     62 
     63   <target name="dev"
     64           depends="prepare,validate,copy-resources,build,tests" />
     65 
     66   <target name="all"
     67           depends="prepare,validate,copy-resources,build,dist,tests,test-ant,javadocs,dist" />
     68 
     69   <target name="build" depends="prepare,compile,testng-jar-all" />
     70 
     71   <target name="testng-jar-all">
     72     <antcall target="create-jar">
     73       <param name="jar.file" value="${testng.jar}" />
     74     </antcall>
     75     <jar jarfile="${testng.jar}" update="true">
     76       <zipfileset src="${lib.dir}/${beanshell.jar}" />
     77       <zipfileset src="${lib.dir}/${jcommander.jar}" />
     78       <zipfileset src="${lib.dir}/${yaml.jar}" />
     79     </jar>
     80 
     81   </target>
     82 
     83   <target name="single">
     84     <ant antfile="build-tests.xml" target="run:single"/>
     85   </target>
     86 
     87   <!-- ==================================================================== -->
     88   <!-- Compile                                                              -->
     89   <!-- ==================================================================== -->
     90 
     91   <path id="compile2.cp">
     92     <fileset dir="${lib.dir}" includes="${all.jar.files}" />
     93   </path>
     94 
     95   <target name="compile"
     96           depends="prepare,copy-resources"
     97           description="Compiles sources">
     98     <echo message="                                 -- Compiling sources --" />
     99 
    100     <echo>Src:${src.dir}</echo>
    101     <javac classpathref="compile2.cp"
    102            verbose="false"
    103            target="1.7"
    104            debug="true"
    105            optimize="${optimize}"
    106            destdir="${build.dir}">
    107       <src path="${src.dir}" />
    108     </javac>
    109   </target>
    110 
    111   <target name="compile:all" depends="compile" />
    112 
    113   <target name="examples">
    114     <ant inheritall="no" antfile="examples/build.xml" />
    115   </target>
    116 
    117   <target name="tests" depends="build" description="runs all JDK5 tests with JDK5 distro">
    118     <ant inheritall="no" antfile="build-tests.xml" />
    119   </target>
    120   
    121   <target name="test-ant" depends="build">
    122     <echo message="                                 -- Testing ant testng task functionality --" />
    123     <ant inheritall="no" antfile="build-ant.xml" />
    124   </target>
    125 
    126   <!-- ==================================================================== -->
    127   <!-- Documentation                                                        -->
    128   <!-- ==================================================================== -->
    129 
    130   <target name="javadocs" depends="build,javadocs-current" />
    131 
    132   <target name="doclava">
    133     <javadoc
    134       docletpath="3rdparty/doclava-1.0.3.jar"
    135       bootclasspath="${javahome}/jre/lib/rt.jar"
    136       classpath="${testng.jar}:lib/${ant.jar}:lib/${guice2.jar}:lib/aopalliance-1.0.jar"
    137       maxmemory="2048M"
    138       additionalparam="-quiet"
    139       verbose="false"
    140       destdir="javadocs"
    141       >
    142       <fileset dir="${src.dir}" defaultexcludes="yes">
    143         <include name="org/testng/*.java" />
    144       </fileset>
    145       <fileset dir="${src.dir}" defaultexcludes="yes">
    146         <include name="org/testng/xml/Xml*.java" />
    147       </fileset>
    148       <fileset dir="${src.dir}" defaultexcludes="yes">
    149         <include name="org/testng/annotations/**" />
    150       </fileset>
    151       <doclet name="com.google.doclava.Doclava">
    152         <param name="-stubs" value="build/stubs" />
    153         <param name="-hdf"/>
    154         <param name="project.name" value="TestNG" />
    155         <!-- versioning -->
    156         <param name="-since"/>
    157         <param name="doclava/previous.xml"/>
    158         <param name="v1" />
    159         <param name="-apiversion" value="v2"/>
    160         <!-- federation -->
    161         <param name="-federate" />
    162         <param name="JDK"/>
    163         <param name="http://download.oracle.com/javase/6/docs/api/index.html?"/>
    164         <param name="-federationxml"/><param name="JDK"/>
    165         <param name="http://doclava.googlecode.com/svn/static/api/openjdk-6.xml"/>
    166       </doclet>
    167     </javadoc>
    168   </target>
    169 
    170   <target name="javadocs-current">
    171     <javadoc additionalparam="-quiet" destdir="javadocs" source="1.7" windowtitle="TestNG"
    172       classpath="${testng.jar}" classpathref="compile2.cp" verbose="false">
    173       <fileset dir="${src.dir}" defaultexcludes="yes">
    174         <include name="org/testng/*.java" />
    175       </fileset>
    176       <fileset dir="${src.dir}" defaultexcludes="yes">
    177         <include name="org/testng/xml/Xml*.java" />
    178       </fileset>
    179       <fileset dir="${src.dir}" defaultexcludes="yes">
    180         <include name="org/testng/annotations/**" />
    181       </fileset>
    182     </javadoc>
    183   </target>
    184 
    185   <!-- ==================================================================== -->
    186   <!-- Distribution                                                         -->
    187   <!-- ==================================================================== -->
    188 
    189   <target name="dist" depends="build,all-jar-flavors,dist-all-zip,eclipse" />
    190 
    191   <target name="all-jar-flavors" depends="dist-junit,dist-nobsh-guice,dist-bsh-noguice,dist-nobsh-noguice,dist-testng-dist,dist-testng-javadoc" />
    192 
    193   <target name="dist-junit">
    194     <antcall target="create-jar">
    195       <param name="jar.file" value="${other.jars.dir}/${testng.junit.jar}" />
    196     </antcall>
    197     <jar jarfile="${other.jars.dir}/${testng.junit.jar}" update="true">
    198       <zipfileset src="${lib.dir}/${beanshell.jar}" />
    199       <zipfileset src="${lib.dir}/${jcommander.jar}" />
    200       <zipfileset src="${lib.dir}/${junit.jar}" />
    201       <zipfileset src="${lib.dir}/${yaml.jar}" />
    202     </jar>
    203   </target>
    204 
    205   <target name="dist-nobsh-guice">
    206     <antcall target="create-jar">
    207       <param name="jar.file" value="${other.jars.dir}/${testng.nobsh.guice.jar}" />
    208     </antcall>
    209     <jar jarfile="${other.jars.dir}/${testng.nobsh.guice.jar}" update="true">
    210       <zipfileset src="${lib.dir}/${guice2.jar}" />
    211       <zipfileset src="${lib.dir}/${jcommander.jar}" />
    212       <zipfileset src="${lib.dir}/${junit.jar}" />
    213     </jar>
    214   </target>
    215 
    216   <target name="dist-bsh-noguice">
    217     <antcall target="create-jar">
    218       <param name="jar.file" value="${other.jars.dir}/${testng.bsh.noguice.jar}" />
    219     </antcall>
    220     <jar jarfile="${other.jars.dir}/${testng.bsh.noguice.jar}" update="true">
    221       <zipfileset src="${lib.dir}/${beanshell.jar}" />
    222       <zipfileset src="${lib.dir}/${jcommander.jar}" />
    223       <zipfileset src="${lib.dir}/${junit.jar}" />
    224     </jar>
    225   </target>
    226 
    227   <target name="dist-nobsh-noguice">
    228     <antcall target="create-jar">
    229       <param name="jar.file" value="${other.jars.dir}/${testng.nobsh.noguice.jar}" />
    230     </antcall>
    231     <jar jarfile="${other.jars.dir}/${testng.bsh.noguice.jar}" update="true">
    232       <zipfileset src="${lib.dir}/${jcommander.jar}" />
    233       <zipfileset src="${lib.dir}/${junit.jar}" />
    234     </jar>
    235   </target>
    236 
    237   <target name="dist-testng-dist">
    238     <antcall target="create-jar">
    239       <param name="jar.file" value="${other.jars.dir}/${testng.dist.jar}" />
    240     </antcall>
    241     <jar jarfile="${other.jars.dir}/${testng.dist.jar}" update="true">
    242       <zipfileset src="${lib.dir}/${jcommander.jar}" />
    243     </jar>
    244   </target>
    245 
    246   <target name="dist-testng-javadoc" depends="javadocs">
    247     <zip destfile="${other.jars.dir}/${testng.javadoc.zip}">
    248         <fileset dir="javadocs"/>
    249     </zip>
    250   </target>
    251 
    252   <target name="create-jar" description="Create a jar file with the Testng classes and nothing else" 
    253           depends="compile">
    254     <delete file="${jar.file}" />
    255     <jar destfile="${jar.file}" >
    256       <manifest>
    257         <attribute name="Main-Class" value="org.testng.TestNG" />
    258         <attribute name="Implementation-Version" value="${testng.version}-${DSTAMP}${TSTAMP}" />
    259       </manifest>
    260       <fileset dir="${build.dir}" />
    261       <fileset file="TESTNG-${testng.version}" />
    262     </jar>
    263   </target>
    264 
    265   <target name="dist-all-zip" depends="dist-prepare,javadocs">
    266     <property name="zip.dir" value="testng-${testng.version}" />
    267     <echo>Adding ${testng.fullname}</echo>
    268     <zip zipfile="${testng.zip}">
    269       <zipfileset prefix="${zip.dir}" dir="${target}">
    270         <include name="${testng.fullname}.jar" />
    271       </zipfileset>
    272       <zipfileset prefix="${zip.dir}" dir="${basedir}" includesfile="FILES" />
    273       <zipfileset dir="${other.jars.dir}" prefix="${zip.dir}/other-jars"/>
    274       <zipfileset dir="javadocs" prefix="${zip.dir}/javadocs" />
    275       <zipfileset dir="src" prefix="${zip.dir}/src" />
    276       <zipfileset dir="spring" prefix="${zip.dir}/spring" />
    277       <zipfileset dir="doc" prefix="${zip.dir}/doc" />
    278       <zipfileset dir="${src.resources.dir}"
    279                prefix="${zip.dir}/resources" 
    280             includes="**/*.css"/>
    281     </zip>
    282   </target>
    283   
    284 <!--
    285   <target name="dist-maven-bundle" depends="dist-all-zip">
    286     <mkdir dir="${build.maven-bundle.dir}" />
    287     <copy file="bundle-pom.xml" tofile="${build.maven-bundle.dir}/pom.xml" overwrite="true">
    288       <filterchain>
    289         <expandproperties/>
    290       </filterchain>
    291     </copy>
    292     <jar destfile="${build.maven-bundle.dir}/${sources.testng.jar}">
    293       <fileset dir="${src.dir}" />
    294     </jar>
    295 
    296     <exec executable="gpg">
    297       <arg value="- -yes" />
    298       <arg value="-ab" />
    299       <arg value="${testng.jar}" />
    300     </exec>
    301 
    302     <exec executable="gpg">
    303       <arg value="- -yes" />
    304       <arg value="-ab" />
    305       <arg value="${build.maven-bundle.dir}/pom.xml" />
    306     </exec>
    307 
    308     <exec executable="gpg">
    309       <arg value="- -yes" />
    310       <arg value="-ab" />
    311       <arg value="${build.maven-bundle.dir}/${sources.testng.jar}" />
    312     </exec>
    313 
    314     <jar destfile="${testng.maven-bundle}">
    315       <fileset file="${build.maven-bundle.dir}/pom.xml" />
    316       <fileset file="${build.maven-bundle.dir}/${sources.testng.jar}" />
    317       <fileset file="${build.maven-bundle.dir}/*asc" />
    318       <fileset file="${testng.jar}" />
    319       <fileset file="${testng.jar}.asc" />
    320     </jar>
    321   </target>
    322 -->
    323 
    324   <target name="dist-prepare" depends="update-readme">
    325     <delete file="{other.jars.dir}/${testng.nobsh.jar}" />
    326     <mkdir dir="${other.jars.dir}" />
    327   </target>
    328 
    329   <target name="update-readme">
    330     <copy file="README.template" tofile="README.md" />
    331     <replace file="README.md" token="${version}" value="${testng.version}" />
    332     <touch file="TESTNG-${testng.version}" />
    333   </target>
    334       
    335   <target name="eclipse" description="Used by Cedric to build distributions">
    336     <property name="jdk15.jar"
    337               value="${testng-eclipse.dir}/lib/testng.jar" />
    338 
    339     <delete file="${jdk15.jar}" />
    340     <copy file="${testng.jar}" tofile="${jdk15.jar}" />
    341 
    342     <!-- sources -->
    343     <property name="sources" value="${testng-eclipse.dir}/lib/testng-sources.jar"/>
    344     <echo>Sources: ${sources}</echo>
    345     <jar destfile="${sources}" basedir="src/main/java/" />
    346   </target>
    347 
    348   <target name="ftp">
    349     <!--
    350           <ftp action="put"
    351              server="beust.com"
    352              remotedir="w/testng/test-output"
    353              userid="${userid}"
    354              password="${password}">
    355               <fileset dir="c:\weblogic\dev\sandbox\cbeust\testng\test\test-output">
    356                 <include name="index.html" />
    357                 <include name="main.html" />
    358                 <include name="toc.html" />
    359                 <include name="*egression*" />
    360              </fileset>
    361         </ftp>
    362       -->
    363     <ftp action="put"
    364          server="beust.com"
    365          remotedir="w/testng"
    366          userid="${userid}"
    367          password="${password}">
    368       <fileset dir="${root.dir}">
    369         <include name="${testng.zip}" />
    370         <include name="javadocs/**" />
    371         <include name="testng-1.0.dtd" />
    372       </fileset>
    373       <fileset dir="${root.dir}/doc">
    374         <include name="*.html" />
    375       </fileset>
    376     </ftp>
    377 
    378   </target>
    379 
    380   <target name="ftp2">
    381     <ftp action="put"
    382          server="beust.com"
    383          remotedir="w/testng"
    384          userid="${userid}"
    385          password="${password}">
    386       <fileset dir="${root.dir}/test">
    387         <include name="test-output/*" />
    388       </fileset>
    389       <fileset dir="${root.dir}/test">
    390         <include name="test-report/*" />
    391       </fileset>
    392     </ftp>
    393   </target>
    394 
    395   <target name="clean">
    396     <delete dir="${build.dir}" />
    397     <delete dir="${target}" />
    398     <delete dir="${build.maven-bundle.dir}" />
    399     <delete failonerror="false">
    400       <fileset dir="." includes="testng*.jar,*.zip" />
    401     </delete>
    402     <delete dir="test-output" failonerror="false" />
    403     <delete dir="test-output-tests" failonerror="false" />
    404     <ant antfile="build-tests.xml" target="clean" />
    405     <ant dir="examples" target="clean" />
    406   </target>
    407 
    408   <!-- ==================================================================== -->
    409   <!-- Maven1/2 Distribution                                                -->
    410   <!-- ==================================================================== -->
    411 
    412 <!--
    413   <target name="maven-plugin">
    414     <jar destfile="maven-testng-plugin-${testng-maven.version}.jar"
    415          basedir="./maven/" />
    416   </target>
    417 -->
    418 
    419   <!-- ==================================================================== -->
    420   <!-- Ivy                                                                  -->
    421   <!-- ==================================================================== -->
    422 
    423   <target name="retrieve-dependencies" description="Retrieve dependencies with ivy">
    424     <ivy:retrieve log="quiet" />
    425   </target>
    426 
    427   <target name="publish">
    428     <ivy:resolve />
    429     <mkdir dir="dist/jars" />
    430     <copy file="${testng.jar}" todir="dist/jars" />
    431     <ivy:publish organisation="org.testng" resolver="local" overwrite="true"/>
    432   </target>
    433 
    434   <target name="pom">
    435     <ivy:makepom ivyfile="ivy.xml" pomfile="ivy-pom.xml" />
    436   </target>
    437 
    438   <!-- ==================================================================== -->
    439   <!-- Code coverage                                                        -->
    440   <!-- ==================================================================== -->
    441 
    442 <!--
    443   <property name="cobertura.dir" value="../cobertura-1.9.4.1" />
    444 
    445   <path id="cobertura.classpath">
    446       <fileset dir="${cobertura.dir}">
    447           <include name="cobertura.jar" />
    448           <include name="lib/**/*.jar" />
    449       </fileset>
    450   </path>
    451 
    452   <taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
    453 
    454   <target name="coverage:create">
    455     <cobertura-instrument classpath="cobertura-1.9.4.1/lib/*" todir="target/instrumented-classes">
    456       <fileset dir="${build.dir}">
    457         <include name="**/*.class" />
    458       </fileset>
    459     </cobertura-instrument>
    460   </target>
    461 
    462   <target name="coverage">
    463     <cobertura-report srcdir="${src.dir}" destdir="target/coverage-report"/>
    464   </target>
    465 -->
    466 
    467 </project>
    468