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