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