1 <?xml version="1.0" encoding="UTF-8"?>
2 <project name="differentreturntype" default="run" basedir=".">
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
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}"/>
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
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>
26 <!-- END: theory.binary.differentreturntype.ant -->
28 <target name="build" depends="clean">
29 <antcall target="-build-one">
30 <param name="version" value="api1.0"/>
32 <antcall target="-build-one">
33 <param name="version" value="api2.0"/>
35 <antcall target="-build-and-rename"/>
36 <antcall target="-build-one">
37 <param name="version" value="impl"/>
38 <param name="target" value="impl-with-api1.0"/>
39 <param name="cp" location="build/api1.0/classes"/>
41 <antcall target="-build-one">
42 <param name="version" value="impl"/>
43 <param name="target" value="impl-with-api2.0"/>
44 <param name="cp" location="build/api2.0/classes"/>
48 <target name="run" depends="build">
49 <echo level="info" message="Running the Implementation Compiled against Version 1.0 with Version 1.0. This should succeeds."/>
50 <antcall target="-run-one">
51 <param name="version" value="api1.0"/>
53 <echo level="info" message="Running the Implementation Compiled against Version 2.0 with Version 2.0. This should succeeds."/>
54 <antcall target="-run-one">
55 <param name="version" value="api2.0"/>
57 <echo level="info" message="Running the Implementation Compiled against Version 1.0 with Version 2.0. This should fail."/>
58 <antcall target="-run-one">
59 <param name="version" value="api2.0"/>
60 <param name="target" value="api1.0"/>
62 <echo level="info" message="Running the Implementation Compiled against Version 2.0 with Version 1.0. This should fail."/>
63 <antcall target="-run-one">
64 <param name="version" value="api1.0"/>
65 <param name="target" value="api2.0"/>
67 <echo level="info" message="Final success1: Running the Implementation Compiled against Version 1.0 with Merged Version."/>
68 <antcall target="-run-one">
69 <param name="version" value="apimerge"/>
70 <param name="target" value="api1.0"/>
72 <echo level="info" message="Final success2: Running the Implementation Compiled against Version 2.0 with Merged Version."/>
73 <antcall target="-run-one">
74 <param name="version" value="apimerge"/>
75 <param name="target" value="api2.0"/>
80 <!-- support methods -->
82 <target name="-run-one">
83 <fail message="You need to specify API version number" unless="version"/>
84 <property name="target" value="${version}"/>
85 <java classpath="build/${version}/classes:build/impl-with-${target}/classes" classname="impl.Impl"
90 <target name="-build-one">
91 <fail message="You need to specify version number" unless="version"/>
93 <property name="cp" value=""/>
94 <property name="target" value="${version}"/>
95 <mkdir dir="build/${target}/classes"/>
97 srcdir="src-${version}"
98 destdir="build/${target}/classes"
99 source="1.4" target="1.4"