1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/differentreturntype/build.xml Sat Jun 14 09:50:51 2008 +0200
1.3 @@ -0,0 +1,106 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +<project name="differentreturntype" default="run" basedir=".">
1.6 + <target name="clean">
1.7 + <delete dir="build"/>
1.8 + </target>
1.9 +
1.10 + <!-- This is the target that does the whole trick - e,g. it compiles
1.11 + the Java source and then replaces tokens inside of the .class file
1.12 + -->
1.13 + <target name="-build-and-rename">
1.14 + <mkdir dir="build/apimerge/classes"/>
1.15 + <javac
1.16 + srcdir="src-apimerge"
1.17 + destdir="build/apimerge/classes"
1.18 + source="1.4" target="1.4"
1.19 + classpath="${cp}"
1.20 + />
1.21 +
1.22 + <!-- this is the replace. As the replace is done textually,
1.23 + we need to use some reasonable encoding that treats all byte values
1.24 + as characters. E.g. it is not possible to use UTF-8 as it does not
1.25 + like the standard Java header 0xCAFEBABE. Western Europe encoding is fine
1.26 + -->
1.27 + <replace dir="build/apimerge/classes" casesensitive="true" encoding="iso-8859-1" summary="true">
1.28 + <include name="**/*.class"/>
1.29 + <replacetoken>g3tIcon</replacetoken>
1.30 + <replacevalue>getIcon</replacevalue>
1.31 + </replace>
1.32 + </target>
1.33 +
1.34 + <target name="build" depends="clean">
1.35 + <antcall target="-build-one">
1.36 + <param name="version" value="api1.0"/>
1.37 + </antcall>
1.38 + <antcall target="-build-one">
1.39 + <param name="version" value="api2.0"/>
1.40 + </antcall>
1.41 + <antcall target="-build-and-rename"/>
1.42 + <antcall target="-build-one">
1.43 + <param name="version" value="impl"/>
1.44 + <param name="target" value="impl-with-api1.0"/>
1.45 + <param name="cp" location="build/api1.0/classes"/>
1.46 + </antcall>
1.47 + <antcall target="-build-one">
1.48 + <param name="version" value="impl"/>
1.49 + <param name="target" value="impl-with-api2.0"/>
1.50 + <param name="cp" location="build/api2.0/classes"/>
1.51 + </antcall>
1.52 + </target>
1.53 +
1.54 + <target name="run" depends="build">
1.55 + <echo level="info" message="Running the Implementation Compiled against Version 1.0 with Version 1.0. This should succeeds."/>
1.56 + <antcall target="-run-one">
1.57 + <param name="version" value="api1.0"/>
1.58 + </antcall>
1.59 + <echo level="info" message="Running the Implementation Compiled against Version 2.0 with Version 2.0. This should succeeds."/>
1.60 + <antcall target="-run-one">
1.61 + <param name="version" value="api2.0"/>
1.62 + </antcall>
1.63 + <echo level="info" message="Running the Implementation Compiled against Version 1.0 with Version 2.0. This should fail."/>
1.64 + <antcall target="-run-one">
1.65 + <param name="version" value="api2.0"/>
1.66 + <param name="target" value="api1.0"/>
1.67 + </antcall>
1.68 + <echo level="info" message="Running the Implementation Compiled against Version 2.0 with Version 1.0. This should fail."/>
1.69 + <antcall target="-run-one">
1.70 + <param name="version" value="api1.0"/>
1.71 + <param name="target" value="api2.0"/>
1.72 + </antcall>
1.73 + <echo level="info" message="Final success1: Running the Implementation Compiled against Version 1.0 with Merged Version."/>
1.74 + <antcall target="-run-one">
1.75 + <param name="version" value="apimerge"/>
1.76 + <param name="target" value="api1.0"/>
1.77 + </antcall>
1.78 + <echo level="info" message="Final success2: Running the Implementation Compiled against Version 2.0 with Merged Version."/>
1.79 + <antcall target="-run-one">
1.80 + <param name="version" value="apimerge"/>
1.81 + <param name="target" value="api2.0"/>
1.82 + </antcall>
1.83 + </target>
1.84 +
1.85 +
1.86 + <!-- support methods -->
1.87 +
1.88 + <target name="-run-one">
1.89 + <fail message="You need to specify API version number" unless="version"/>
1.90 + <property name="target" value="${version}"/>
1.91 + <java classpath="build/${version}/classes:build/impl-with-${target}/classes" classname="impl.Impl"
1.92 + failonerror="false"
1.93 + />
1.94 + </target>
1.95 +
1.96 + <target name="-build-one">
1.97 + <fail message="You need to specify version number" unless="version"/>
1.98 +
1.99 + <property name="cp" value=""/>
1.100 + <property name="target" value="${version}"/>
1.101 + <mkdir dir="build/${target}/classes"/>
1.102 + <javac
1.103 + srcdir="src-${version}"
1.104 + destdir="build/${target}/classes"
1.105 + source="1.4" target="1.4"
1.106 + classpath="${cp}"
1.107 + />
1.108 + </target>
1.109 +</project>