build.xml
author Jaroslav Tulach <jtulach@netbeans.org>
Tue, 16 Jun 2009 17:53:32 +0200
changeset 1238 57914fd9382f
parent 1237 3021779e58a1
child 1240 4b353465cd30
permissions -rw-r--r--
Separatelly compiling Beans and Applet modules. Using 'code injection' to allow Beans class to perform its Applet related functionality if Applet module is around.
jtulach@1237
     1
<?xml version="1.0" encoding="UTF-8"?>
jtulach@1237
     2
<project name="modularize" default="all" basedir=".">
jtulach@1237
     3
    <description>Scripts to build JDK Java sources in modularized way</description>
jtulach@1237
     4
jtulach@1237
     5
    <target name="all">
jtulach@1238
     6
        <antcall target="base"/>
jtulach@1237
     7
        <antcall target="beans"/>
jtulach@1237
     8
        <antcall target="applet"/>
jtulach@1237
     9
    </target>
jtulach@1237
    10
    <!-- basic parameters -->
jtulach@1237
    11
    <path id="src.path">
jtulach@1237
    12
        <pathelement location="src/share/classes"/>
jtulach@1237
    13
        <pathelement location="src/windows/classes"/>
jtulach@1237
    14
        <pathelement location="src/solaris/classes"/>
jtulach@1237
    15
    </path>
jtulach@1237
    16
    <property name="build.dir" location="build/modularize"/>
jtulach@1237
    17
jtulach@1237
    18
    <!-- this is the core of the separation - definition
jtulach@1237
    19
      of what classes belong into what compilation group.
jtulach@1237
    20
    -->
jtulach@1237
    21
    <selector id="applet">
jtulach@1237
    22
        <or>
jtulach@1238
    23
            <filename name="java/beans/AppletInitializer*"/>
jtulach@1237
    24
            <filename name="java/applet/**"/>
jtulach@1237
    25
            <filename name="sun/applet/**"/>
jtulach@1238
    26
            <filename name="META-INF/services/sun.beans.AppletProxy"/>
jtulach@1237
    27
        </or>
jtulach@1237
    28
    </selector>
jtulach@1237
    29
    <selector id="beans">
jtulach@1238
    30
        <and>
jtulach@1238
    31
            <or>
jtulach@1238
    32
                <filename name="java/beans/**"/>
jtulach@1238
    33
                <filename name="sun/beans/**"/>
jtulach@1238
    34
                <filename name="com/sun/beans/**"/>
jtulach@1238
    35
            </or>
jtulach@1238
    36
            <none>
jtulach@1238
    37
                <selector refid="applet"/>
jtulach@1238
    38
            </none>
jtulach@1238
    39
        </and>
jtulach@1237
    40
    </selector>
jtulach@1237
    41
jtulach@1237
    42
    <selector id="corba">
jtulach@1237
    43
        <or>
jtulach@1237
    44
            <filename name="org/omg/**"/>
jtulach@1237
    45
            <filename name="com/sun/corba/**"/>
jtulach@1237
    46
        </or>
jtulach@1237
    47
    </selector>
jtulach@1237
    48
    
jtulach@1237
    49
    <selector id="base">
jtulach@1237
    50
        <none>
jtulach@1237
    51
            <selector refid="applet"/>
jtulach@1237
    52
            <selector refid="beans"/>
jtulach@1237
    53
            <selector refid="corba"/>
jtulach@1237
    54
        </none>
jtulach@1237
    55
    </selector>
jtulach@1237
    56
jtulach@1237
    57
    <!-- individual compilation tasks -->
jtulach@1237
    58
jtulach@1237
    59
    <target name="applet">
jtulach@1237
    60
        <antcall target="-compile-one-module">
jtulach@1237
    61
            <param name="module" value="applet"/>
jtulach@1238
    62
            <param name="depends" value="beans"/>
jtulach@1237
    63
        </antcall>
jtulach@1237
    64
    </target>
jtulach@1237
    65
    <target name="beans">
jtulach@1237
    66
        <antcall target="-compile-one-module">
jtulach@1237
    67
            <param name="module" value="beans"/>
jtulach@1237
    68
        </antcall>
jtulach@1237
    69
    </target>
jtulach@1237
    70
    
jtulach@1237
    71
jtulach@1237
    72
    <!-- as I am currently unable to build JDK myself, I'll start
jtulach@1237
    73
      the modularization by extracting the base module from an existing
jtulach@1237
    74
      classes
jtulach@1237
    75
    -->
jtulach@1238
    76
    <target name="base">
jtulach@1237
    77
        <property name="rt.jar" location="${java.home}/lib/rt.jar"/>
jtulach@1237
    78
        <fail message="Cannot find rt.jar, specify with -Drt.jar=...">
jtulach@1237
    79
            <condition><not><available file="${rt.jar}"/></not></condition>
jtulach@1237
    80
        </fail>
jtulach@1237
    81
jtulach@1237
    82
        <mkdir dir="${build.dir}/rt"/>
jtulach@1237
    83
        <unzip src="${rt.jar}" dest="${build.dir}/rt"/>
jtulach@1238
    84
        <jar file="${build.dir}/base.jar" compress="false">
jtulach@1237
    85
            <fileset dir="${build.dir}/rt">
jtulach@1237
    86
                <selector refid="base"/>
jtulach@1237
    87
            </fileset>
jtulach@1237
    88
        </jar>
jtulach@1237
    89
    </target>
jtulach@1237
    90
jtulach@1237
    91
    <!-- shared routine to compile one of the modules -->
jtulach@1237
    92
    <target name="-compile-one-module">
jtulach@1237
    93
        <mkdir dir="${build.dir}/classes/${module}"/>
jtulach@1238
    94
        <pathconvert pathsep="," property="module.cp">
jtulach@1238
    95
            <path path="${depends}"/>
jtulach@1238
    96
            <mapper type="regexp" from=".*[/\\]([^/\\]*)" to="${build.dir}/\1.jar"/>
jtulach@1238
    97
        </pathconvert>
jtulach@1238
    98
        <javac
jtulach@1238
    99
            bootclasspath="${build.dir}/base.jar"
jtulach@1238
   100
            sourcepath=""
jtulach@1238
   101
            destdir="${build.dir}/classes/${module}"
jtulach@1238
   102
            classpath="${module.cp}"
jtulach@1238
   103
            includejavaruntime="false"
jtulach@1238
   104
            includeantruntime="false"
jtulach@1238
   105
        >
jtulach@1237
   106
            <src refid="src.path"/>
jtulach@1237
   107
            <selector refid="${module}"/>
jtulach@1237
   108
        </javac>
jtulach@1238
   109
        <copy todir="${build.dir}/classes/${module}">
jtulach@1238
   110
            <fileset dir="src/share/classes">
jtulach@1238
   111
                <and>
jtulach@1238
   112
                    <selector refid="${module}"/>
jtulach@1238
   113
                    <not>
jtulach@1238
   114
                        <filename name="**/*.java"/>
jtulach@1238
   115
                    </not>
jtulach@1238
   116
                </and>
jtulach@1238
   117
            </fileset>
jtulach@1238
   118
        </copy>
jtulach@1238
   119
jtulach@1238
   120
        <jar 
jtulach@1238
   121
            basedir="${build.dir}/classes/${module}"
jtulach@1238
   122
            destfile="${build.dir}/${module}.jar"
jtulach@1238
   123
            compress="false"
jtulach@1238
   124
        />
jtulach@1237
   125
    </target>
jtulach@1237
   126
jtulach@1237
   127
    <!-- clean everything -->
jtulach@1237
   128
    <target name="clean">
jtulach@1237
   129
        <delete dir="${build.dir}"/>
jtulach@1237
   130
    </target>
jtulach@1237
   131
</project>