samples/differentreturntype/build.xml
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 18:51:38 +0200
changeset 263 7e8e995065c5
parent 154 0fd5e9c500b9
permissions -rw-r--r--
Tests of all modules are executed and can fail the build
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <project name="differentreturntype" default="run" basedir=".">
     3     <target name="clean">
     4         <delete dir="build"/>
     5     </target>
     6     <target name="test"/>
     7     
     8     <!-- BEGIN: theory.binary.differentreturntype.ant -->
     9     <!-- This is the target that does the whole trick - e,g. it compiles
    10         the Java source and then replaces tokens 
    11         inside of the .class file
    12      -->
    13     <target name="-build-and-rename">
    14         <mkdir dir="build/apimerge/classes"/>
    15         <javac 
    16             srcdir="src-apimerge" destdir="build/apimerge/classes" 
    17             source="1.4" target="1.4" classpath="${cp}"
    18         />
    19         
    20         <!-- this is the replace. As the replace is done textually,
    21             we need to use some reasonable encoding that treats all 
    22             byte values as characters. E.g. it is not possible to 
    23             use UTF-8 as it does not like the standard Java header 
    24             0xCAFEBABE. Western Europe encoding is fine
    25         -->
    26         <replace 
    27             dir="build/apimerge/classes" casesensitive="true" 
    28             encoding="iso-8859-1" summary="true"
    29         >
    30             <include name="**/*.class"/>
    31             <replacetoken>g3tIcon</replacetoken>
    32             <replacevalue>getIcon</replacevalue>
    33         </replace>
    34     </target>
    35     <!-- END: theory.binary.differentreturntype.ant -->
    36     
    37     <target name="compile" depends="build"/>
    38     <target name="build" depends="clean">
    39         <antcall target="-build-one">
    40             <param name="version" value="api1.0"/>
    41         </antcall>
    42         <antcall target="-build-one">
    43             <param name="version" value="api2.0"/>
    44         </antcall>
    45         <antcall target="-build-and-rename"/>
    46         <antcall target="-build-one">
    47             <param name="version" value="impl"/>
    48             <param name="target" value="impl-with-api1.0"/>
    49             <param name="cp" location="build/api1.0/classes"/>
    50         </antcall>
    51         <antcall target="-build-one">
    52             <param name="version" value="impl"/>
    53             <param name="target" value="impl-with-api2.0"/>
    54             <param name="cp" location="build/api2.0/classes"/>
    55         </antcall>
    56     </target>
    57     
    58     <target name="run" depends="build">
    59         <echo level="info" message="Running the Implementation Compiled against Version 1.0 with Version 1.0. This should succeeds."/>
    60         <antcall target="-run-one">
    61             <param name="version" value="api1.0"/>
    62         </antcall>
    63         <echo level="info" message="Running the Implementation Compiled against Version 2.0 with Version 2.0. This should succeeds."/>
    64         <antcall target="-run-one">
    65             <param name="version" value="api2.0"/>
    66         </antcall>
    67         <echo level="info" message="Running the Implementation Compiled against Version 1.0 with Version 2.0. This should fail."/>
    68         <antcall target="-run-one">
    69             <param name="version" value="api2.0"/>
    70             <param name="target" value="api1.0"/>
    71         </antcall>
    72         <echo level="info" message="Running the Implementation Compiled against Version 2.0 with Version 1.0. This should fail."/>
    73         <antcall target="-run-one">
    74             <param name="version" value="api1.0"/>
    75             <param name="target" value="api2.0"/>
    76         </antcall>
    77         <echo level="info" message="Final success1: Running the Implementation Compiled against Version 1.0 with Merged Version."/>
    78         <antcall target="-run-one">
    79             <param name="version" value="apimerge"/>
    80             <param name="target" value="api1.0"/>
    81         </antcall>
    82         <echo level="info" message="Final success2: Running the Implementation Compiled against Version 2.0 with Merged Version."/>
    83         <antcall target="-run-one">
    84             <param name="version" value="apimerge"/>
    85             <param name="target" value="api2.0"/>
    86         </antcall>
    87     </target>
    88 
    89     
    90     <!-- support methods -->
    91     
    92     <target name="-run-one">
    93         <fail message="You need to specify API version number" unless="version"/>
    94         <property name="target" value="${version}"/>
    95         <java classpath="build/${version}/classes:build/impl-with-${target}/classes" classname="impl.Impl"
    96             failonerror="false"
    97         />
    98     </target>
    99     
   100     <target name="-build-one">
   101         <fail message="You need to specify version number" unless="version"/>
   102         
   103         <property name="cp" value=""/>
   104         <property name="target" value="${version}"/>
   105         <mkdir dir="build/${target}/classes"/>
   106         <javac 
   107             srcdir="src-${version}" 
   108             destdir="build/${target}/classes" 
   109             source="1.4" target="1.4"
   110             classpath="${cp}"
   111         />
   112     </target>
   113 </project>