samples/visitor/01-notevolutionready/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         <echo level="info" message="Next compilation will fails, as adding methods into interface is not binary compatible"/>
    22         <antcall target="-build-one">
    23             <param name="version" value="test"/>
    24             <param name="out" value="will-not-compile"/>
    25             <param name="cp" value="build/api2.0/classes:${junit.jar}"/>
    26             <param name="failonerror" value="false"/>
    27         </antcall>
    28 
    29         <antcall target="-build-one">
    30             <param name="version" value="test2.0"/>
    31             <param name="cp" value="build/api2.0/classes:build/test/classes:${junit.jar}"/>
    32         </antcall>
    33     </target>
    34     
    35     <target name="test" depends="build">
    36         <echo level="info" message="PrintVisitor on old API. This should succeeds."/>
    37         <antcall target="-run-one">
    38             <param name="version" value="api1.0"/>
    39         </antcall>
    40         <echo level="info" message="PrintVisitor on old API. This would not compile, but it runs as it does not deal with minus at all."/>
    41         <antcall target="-run-one">
    42             <param name="version" value="api2.0"/>
    43         </antcall>
    44         <echo level="info" message="PrintVisitor on new API. This yields runtime error."/>
    45         <antcall target="-run-one">
    46             <param name="test" value="test2.0"/>
    47             <param name="extra.cp" value="build/test/classes"/>
    48             <param name="version" value="api2.0"/>
    49         </antcall>
    50     </target>
    51     
    52     <!-- support methods -->
    53     
    54     <target name="-libraries">
    55         <ant dir="../../libs/"/>
    56         
    57         <property name="junit.jar" location="../../libs/dist/junit-4.4.jar"/>
    58     </target>
    59     
    60     <target name="-run-one">
    61         <fail message="You need to specify API version number" unless="version"/>
    62         <property name="test" value="test"/>
    63         <mkdir dir="build/${test}results${version}"/>
    64         <junit dir="build/test/classes" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
    65             <batchtest todir="build/${test}results${version}">
    66                 <fileset dir="build/${test}/classes">
    67                     <filename name="**/*Test.class"/>
    68                 </fileset>
    69             </batchtest>
    70             <classpath>
    71                 <path location="build/${version}/classes"/>
    72                 <path location="build/${test}/classes"/>
    73                 <path location="${junit.jar}"/>
    74                 <path path="${extra.cp}"/>
    75             </classpath>
    76             <syspropertyset>
    77                 <propertyref prefix="test-sys-prop."/>
    78                 <mapper from="test-sys-prop.*" to="*" type="glob"/>
    79             </syspropertyset>
    80             <formatter type="brief" usefile="false"/>
    81             <formatter type="xml"/>
    82         </junit>
    83     </target>
    84     
    85     <target name="-build-one">
    86         <fail message="You need to specify version number" unless="version"/>
    87         
    88         <property name="cp" value=""/>
    89         <property name="out" value="${version}"/>
    90         <property name="failonerror" value="true"/>
    91         <mkdir dir="build/${out}/classes"/>
    92         <javac 
    93             srcdir="src-${version}" 
    94             destdir="build/${out}/classes" 
    95             source="1.5" target="1.5"
    96             classpath="${cp}"
    97             failonerror="${failonerror}"
    98             debug="true"
    99         />
   100     </target>
   101 </project>