samples/contravariance/build.xml
changeset 379 b632733724a8
parent 378 68bba7c8a1b3
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/samples/contravariance/build.xml	Tue Oct 18 06:55:12 2011 +0200
     1.3 @@ -0,0 +1,88 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<project name="co-contra-variance" default="run" basedir=".">
     1.6 +    <target name="clean">
     1.7 +        <delete dir="build"/>
     1.8 +    </target>
     1.9 +    <target name="test" depends="run"/>
    1.10 +    
    1.11 +    <target name="compile" depends="build"/>
    1.12 +    <target name="build">
    1.13 +        <antcall target="-build-one">
    1.14 +            <param name="version" value="api1.0"/>
    1.15 +        </antcall>
    1.16 +        <antcall target="-build-one">
    1.17 +            <param name="version" value="api2.0"/>
    1.18 +        </antcall>
    1.19 +        <echo level="info" message="Compiling the test against Version 1.0 of the API. This should succeeds."/>
    1.20 +        <antcall target="-build-one">
    1.21 +            <param name="version" value="impl"/>
    1.22 +            <param name="output" value="impl-with-1.0"/>
    1.23 +            <param name="cp" location="build/api1.0/classes"/>
    1.24 +        </antcall>
    1.25 +        <echo level="info" message="Compiling the test against Version 2.0 of the API. This should succeeds."/>
    1.26 +        <antcall target="-build-one">
    1.27 +            <param name="version" value="impl"/>
    1.28 +            <param name="output" value="impl-with-2.0"/>
    1.29 +            <param name="cp" location="build/api2.0/classes"/>
    1.30 +        </antcall>
    1.31 +    </target>
    1.32 +    
    1.33 +    <target name="run" depends="build">
    1.34 +        <echo level="info" message="Running the test compiled with version 1.0 of the API against version 1.0 of the API. This should succeeds."/>
    1.35 +        <antcall target="-run-one">
    1.36 +            <param name="version" value="api1.0"/>
    1.37 +            <param name="testversion" value="impl-with-1.0"/>
    1.38 +            <param name="result" value="0"/>
    1.39 +        </antcall>
    1.40 +        <echo level="info" message="Running the test compiled with version 2.0 of the API against version 2.0 of the API. This should succeeds."/>
    1.41 +        <antcall target="-run-one">
    1.42 +            <param name="version" value="api2.0"/>
    1.43 +            <param name="testversion" value="impl-with-2.0"/>
    1.44 +            <param name="result" value="0"/>
    1.45 +        </antcall>
    1.46 +        <echo level="info" message="Mixing should not work: Running the test compiled with version 1.0 of the API against version 2.0 of the API. This should fail."/>
    1.47 +        <antcall target="-run-one">
    1.48 +            <param name="version" value="api2.0"/>
    1.49 +            <param name="testversion" value="impl-with-1.0"/>
    1.50 +            <param name="result" value="1"/>
    1.51 +        </antcall>
    1.52 +        <echo level="info" message="Mixing does not work: Running the test compiled with version 2.0 of the API against version 1.0 of the API. This should fail."/>
    1.53 +        <antcall target="-run-one">
    1.54 +            <param name="version" value="api1.0"/>
    1.55 +            <param name="testversion" value="impl-with-2.0"/>
    1.56 +            <param name="result" value="1"/>
    1.57 +        </antcall>
    1.58 +    </target>
    1.59 +
    1.60 +    
    1.61 +    <!-- support methods -->
    1.62 +    
    1.63 +    <target name="-run-one">
    1.64 +        <fail message="You need to specify API version number" unless="version"/>
    1.65 +        <java classpath="build/${version}/classes:build/${testversion}/classes" classname="test.ContravarianceTest"
    1.66 +            resultproperty="result.real" failonerror="false" fork="true"
    1.67 +        />
    1.68 +        <fail message="Unexpected failure for ${version}: ${result.real}">
    1.69 +            <condition>
    1.70 +                <not>
    1.71 +                    <equals arg1="${result}" arg2="${result.real}"/>
    1.72 +                </not>
    1.73 +            </condition>
    1.74 +        </fail>
    1.75 +    </target>
    1.76 +    
    1.77 +    <target name="-build-one">
    1.78 +        <fail message="You need to specify version number" unless="version"/>
    1.79 +        
    1.80 +        <property name="output" value="${version}"/>
    1.81 +        <mkdir dir="build/${output}/classes"/>
    1.82 +        <property name="cp" value=""/>
    1.83 +        <javac 
    1.84 +            srcdir="src-${version}" 
    1.85 +            destdir="build/${output}/classes" 
    1.86 +            source="1.6" target="1.6"
    1.87 +            classpath="${cp}"
    1.88 +            includeantruntime="false"
    1.89 +        />
    1.90 +    </target>
    1.91 +</project>