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