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