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