build.xml
author Jaroslav Tulach <jtulach@netbeans.org>
Tue, 16 Jun 2009 15:37:17 +0200
changeset 1237 3021779e58a1
child 1238 57914fd9382f
permissions -rw-r--r--
Initial build script that allows us to play with modularizing JDK
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <project name="modularize" default="all" basedir=".">
     3     <description>Scripts to build JDK Java sources in modularized way</description>
     4 
     5     <target name="all">
     6         <antcall target="extract-base"/>
     7         <antcall target="beans"/>
     8         <antcall target="applet"/>
     9     </target>
    10     <!-- basic parameters -->
    11     <path id="src.path">
    12         <pathelement location="src/share/classes"/>
    13         <pathelement location="src/windows/classes"/>
    14         <pathelement location="src/solaris/classes"/>
    15     </path>
    16     <property name="build.dir" location="build/modularize"/>
    17 
    18     <!-- this is the core of the separation - definition
    19       of what classes belong into what compilation group.
    20     -->
    21     <selector id="applet">
    22         <or>
    23             <filename name="java/applet/**"/>
    24             <filename name="sun/applet/**"/>
    25         </or>
    26     </selector>
    27     <selector id="beans">
    28         <or>
    29             <filename name="java/beans/**"/>
    30             <filename name="sun/beans/**"/>
    31             <filename name="com/sun/beans/**"/>
    32         </or>
    33     </selector>
    34 
    35     <selector id="corba">
    36         <or>
    37             <filename name="org/omg/**"/>
    38             <filename name="com/sun/corba/**"/>
    39         </or>
    40     </selector>
    41     
    42     <selector id="base">
    43         <none>
    44             <selector refid="applet"/>
    45             <selector refid="beans"/>
    46             <selector refid="corba"/>
    47         </none>
    48     </selector>
    49 
    50     <!-- individual compilation tasks -->
    51 
    52     <target name="applet">
    53         <antcall target="-compile-one-module">
    54             <param name="module" value="applet"/>
    55         </antcall>
    56     </target>
    57     <target name="beans">
    58         <antcall target="-compile-one-module">
    59             <param name="module" value="beans"/>
    60         </antcall>
    61     </target>
    62     
    63 
    64     <!-- as I am currently unable to build JDK myself, I'll start
    65       the modularization by extracting the base module from an existing
    66       classes
    67     -->
    68     <target name="extract-base">
    69         <property name="rt.jar" location="${java.home}/lib/rt.jar"/>
    70         <fail message="Cannot find rt.jar, specify with -Drt.jar=...">
    71             <condition><not><available file="${rt.jar}"/></not></condition>
    72         </fail>
    73 
    74         <mkdir dir="${build.dir}/rt"/>
    75         <unzip src="${rt.jar}" dest="${build.dir}/rt"/>
    76         <jar file="${build.dir}/base.jar">
    77             <fileset dir="${build.dir}/rt">
    78                 <selector refid="base"/>
    79             </fileset>
    80         </jar>
    81     </target>
    82 
    83     <!-- shared routine to compile one of the modules -->
    84     <target name="-compile-one-module">
    85         <mkdir dir="${build.dir}/classes/${module}"/>
    86         <javac bootclasspath="${build.dir}/base.jar" sourcepath="" destdir="${build.dir}/classes/${module}">
    87             <src refid="src.path"/>
    88             <selector refid="${module}"/>
    89         </javac>
    90         <jar basedir="${build.dir}/classes/${module}" destfile="${build.dir}/${module}.jar"/>
    91     </target>
    92 
    93     <!-- clean everything -->
    94     <target name="clean">
    95         <delete dir="${build.dir}"/>
    96     </target>
    97 </project>