samples/visitor/04-traversal/build.xml
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 30 Oct 2014 20:46:27 +0100
changeset 408 9a439a79c6d0
parent 167 ab8c04922abe
permissions -rw-r--r--
Use scala 2.10.4 to compile on JDK8
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <project name="Build Script" default="test" basedir=".">
     3     <target name="clean">
     4         <delete dir="build"/>
     5     </target>
     6     
     7     <target name="compile" depends="build"/>
     8     <target name="build" depends="-libraries">
     9         <antcall target="-build-one">
    10             <param name="version" value="api1.0"/>
    11         </antcall>
    12         <antcall target="-build-one">
    13             <param name="version" value="api2.0"/>
    14         </antcall>
    15         
    16         <antcall target="-build-one">
    17             <param name="version" value="test"/>
    18             <param name="cp" value="build/api1.0/classes:${junit.jar}"/>
    19         </antcall>
    20 
    21         <antcall target="-build-one">
    22             <param name="version" value="test"/>
    23             <param name="out" value="will-not-compile"/>
    24             <param name="cp" value="build/api2.0/classes:${junit.jar}"/>
    25         </antcall>
    26 
    27         <antcall target="-build-one">
    28             <param name="version" value="test2.0"/>
    29             <param name="cp" value="build/api2.0/classes:build/test/classes:${junit.jar}"/>
    30         </antcall>
    31     </target>
    32     
    33     <target name="test" depends="build">
    34         <echo level="info" message="PrintVisitor on old API. This should succeeds."/>
    35         <antcall target="-run-one">
    36             <param name="version" value="api1.0"/>
    37         </antcall>
    38         <echo level="info" message="PrintVisitor on old API. This would not compile, but it runs as it does not deal with minus at all."/>
    39         <antcall target="-run-one">
    40             <param name="version" value="api2.0"/>
    41         </antcall>
    42         <echo level="info" message="PrintVisitor on new API. This yields runtime error."/>
    43         <antcall target="-run-one">
    44             <param name="test" value="test2.0"/>
    45             <param name="extra.cp" value="build/test/classes"/>
    46             <param name="version" value="api2.0"/>
    47         </antcall>
    48     </target>
    49     
    50     <!-- support methods -->
    51     
    52     <target name="-libraries">
    53         <ant dir="../../libs/"/>
    54         
    55         <property name="junit.jar" location="../../libs/dist/junit-4.4.jar"/>
    56     </target>
    57     
    58     <target name="-run-one">
    59         <fail message="You need to specify API version number" unless="version"/>
    60         <property name="test" value="test"/>
    61         <mkdir dir="build/${test}results${version}"/>
    62         <junit dir="build/test/classes" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
    63             <batchtest todir="build/${test}results${version}">
    64                 <fileset dir="build/${test}/classes">
    65                     <filename name="**/*Test.class"/>
    66                 </fileset>
    67             </batchtest>
    68             <classpath>
    69                 <path location="build/${version}/classes"/>
    70                 <path location="build/${test}/classes"/>
    71                 <path location="${junit.jar}"/>
    72                 <path path="${extra.cp}"/>
    73             </classpath>
    74             <syspropertyset>
    75                 <propertyref prefix="test-sys-prop."/>
    76                 <mapper from="test-sys-prop.*" to="*" type="glob"/>
    77             </syspropertyset>
    78             <formatter type="brief" usefile="false"/>
    79             <formatter type="xml"/>
    80         </junit>
    81     </target>
    82     
    83     <target name="-build-one">
    84         <fail message="You need to specify version number" unless="version"/>
    85         
    86         <property name="cp" value=""/>
    87         <property name="out" value="${version}"/>
    88         <property name="failonerror" value="true"/>
    89         <mkdir dir="build/${out}/classes"/>
    90         <javac 
    91             srcdir="src-${version}" 
    92             destdir="build/${out}/classes" 
    93             source="1.5" target="1.5"
    94             classpath="${cp}"
    95             failonerror="${failonerror}"
    96             debug="true"
    97         />
    98     </target>
    99 </project>