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