samples/contravariance/build.xml
author Jaroslav Tulach <jtulach@netbeans.org>
Tue, 18 Oct 2011 06:55:12 +0200
changeset 379 b632733724a8
parent 378 samples/covariance/build.xml@68bba7c8a1b3
permissions -rw-r--r--
A contravariance example
jtulach@7
     1
<?xml version="1.0" encoding="UTF-8"?>
jtulach@378
     2
<project name="co-contra-variance" default="run" basedir=".">
jtulach@7
     3
    <target name="clean">
jtulach@7
     4
        <delete dir="build"/>
jtulach@7
     5
    </target>
jtulach@263
     6
    <target name="test" depends="run"/>
jtulach@7
     7
    
jtulach@128
     8
    <target name="compile" depends="build"/>
jtulach@7
     9
    <target name="build">
jtulach@7
    10
        <antcall target="-build-one">
jtulach@7
    11
            <param name="version" value="api1.0"/>
jtulach@7
    12
        </antcall>
jtulach@7
    13
        <antcall target="-build-one">
jtulach@7
    14
            <param name="version" value="api2.0"/>
jtulach@7
    15
        </antcall>
jtulach@378
    16
        <echo level="info" message="Compiling the test against Version 1.0 of the API. This should succeeds."/>
jtulach@7
    17
        <antcall target="-build-one">
jtulach@7
    18
            <param name="version" value="impl"/>
jtulach@378
    19
            <param name="output" value="impl-with-1.0"/>
jtulach@7
    20
            <param name="cp" location="build/api1.0/classes"/>
jtulach@7
    21
        </antcall>
jtulach@378
    22
        <echo level="info" message="Compiling the test against Version 2.0 of the API. This should succeeds."/>
jtulach@378
    23
        <antcall target="-build-one">
jtulach@378
    24
            <param name="version" value="impl"/>
jtulach@378
    25
            <param name="output" value="impl-with-2.0"/>
jtulach@378
    26
            <param name="cp" location="build/api2.0/classes"/>
jtulach@378
    27
        </antcall>
jtulach@7
    28
    </target>
jtulach@7
    29
    
jtulach@7
    30
    <target name="run" depends="build">
jtulach@378
    31
        <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."/>
jtulach@7
    32
        <antcall target="-run-one">
jtulach@7
    33
            <param name="version" value="api1.0"/>
jtulach@378
    34
            <param name="testversion" value="impl-with-1.0"/>
jtulach@263
    35
            <param name="result" value="0"/>
jtulach@7
    36
        </antcall>
jtulach@378
    37
        <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."/>
jtulach@7
    38
        <antcall target="-run-one">
jtulach@8
    39
            <param name="version" value="api2.0"/>
jtulach@378
    40
            <param name="testversion" value="impl-with-2.0"/>
jtulach@378
    41
            <param name="result" value="0"/>
jtulach@378
    42
        </antcall>
jtulach@378
    43
        <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."/>
jtulach@378
    44
        <antcall target="-run-one">
jtulach@378
    45
            <param name="version" value="api2.0"/>
jtulach@378
    46
            <param name="testversion" value="impl-with-1.0"/>
jtulach@378
    47
            <param name="result" value="1"/>
jtulach@378
    48
        </antcall>
jtulach@378
    49
        <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."/>
jtulach@378
    50
        <antcall target="-run-one">
jtulach@378
    51
            <param name="version" value="api1.0"/>
jtulach@378
    52
            <param name="testversion" value="impl-with-2.0"/>
jtulach@263
    53
            <param name="result" value="1"/>
jtulach@7
    54
        </antcall>
jtulach@7
    55
    </target>
jtulach@7
    56
jtulach@7
    57
    
jtulach@7
    58
    <!-- support methods -->
jtulach@7
    59
    
jtulach@7
    60
    <target name="-run-one">
jtulach@7
    61
        <fail message="You need to specify API version number" unless="version"/>
jtulach@379
    62
        <java classpath="build/${version}/classes:build/${testversion}/classes" classname="test.ContravarianceTest"
jtulach@264
    63
            resultproperty="result.real" failonerror="false" fork="true"
jtulach@7
    64
        />
jtulach@263
    65
        <fail message="Unexpected failure for ${version}: ${result.real}">
jtulach@263
    66
            <condition>
jtulach@263
    67
                <not>
jtulach@263
    68
                    <equals arg1="${result}" arg2="${result.real}"/>
jtulach@263
    69
                </not>
jtulach@263
    70
            </condition>
jtulach@263
    71
        </fail>
jtulach@7
    72
    </target>
jtulach@7
    73
    
jtulach@7
    74
    <target name="-build-one">
jtulach@7
    75
        <fail message="You need to specify version number" unless="version"/>
jtulach@7
    76
        
jtulach@378
    77
        <property name="output" value="${version}"/>
jtulach@378
    78
        <mkdir dir="build/${output}/classes"/>
jtulach@7
    79
        <property name="cp" value=""/>
jtulach@7
    80
        <javac 
jtulach@8
    81
            srcdir="src-${version}" 
jtulach@378
    82
            destdir="build/${output}/classes" 
jtulach@378
    83
            source="1.6" target="1.6"
jtulach@7
    84
            classpath="${cp}"
jtulach@378
    85
            includeantruntime="false"
jtulach@7
    86
        />
jtulach@7
    87
    </target>
jtulach@7
    88
</project>