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.
     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="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/beans/AppletInitializer*"/>
    24             <filename name="java/applet/**"/>
    25             <filename name="sun/applet/**"/>
    26             <filename name="META-INF/services/sun.beans.AppletProxy"/>
    27         </or>
    28     </selector>
    29     <selector id="beans">
    30         <and>
    31             <or>
    32                 <filename name="java/beans/**"/>
    33                 <filename name="sun/beans/**"/>
    34                 <filename name="com/sun/beans/**"/>
    35             </or>
    36             <none>
    37                 <selector refid="applet"/>
    38             </none>
    39         </and>
    40     </selector>
    41 
    42     <selector id="corba">
    43         <or>
    44             <filename name="org/omg/**"/>
    45             <filename name="com/sun/corba/**"/>
    46         </or>
    47     </selector>
    48     
    49     <selector id="base">
    50         <none>
    51             <selector refid="applet"/>
    52             <selector refid="beans"/>
    53             <selector refid="corba"/>
    54         </none>
    55     </selector>
    56 
    57     <!-- individual compilation tasks -->
    58 
    59     <target name="applet">
    60         <antcall target="-compile-one-module">
    61             <param name="module" value="applet"/>
    62             <param name="depends" value="beans"/>
    63         </antcall>
    64     </target>
    65     <target name="beans">
    66         <antcall target="-compile-one-module">
    67             <param name="module" value="beans"/>
    68         </antcall>
    69     </target>
    70     
    71 
    72     <!-- as I am currently unable to build JDK myself, I'll start
    73       the modularization by extracting the base module from an existing
    74       classes
    75     -->
    76     <target name="base">
    77         <property name="rt.jar" location="${java.home}/lib/rt.jar"/>
    78         <fail message="Cannot find rt.jar, specify with -Drt.jar=...">
    79             <condition><not><available file="${rt.jar}"/></not></condition>
    80         </fail>
    81 
    82         <mkdir dir="${build.dir}/rt"/>
    83         <unzip src="${rt.jar}" dest="${build.dir}/rt"/>
    84         <jar file="${build.dir}/base.jar" compress="false">
    85             <fileset dir="${build.dir}/rt">
    86                 <selector refid="base"/>
    87             </fileset>
    88         </jar>
    89     </target>
    90 
    91     <!-- shared routine to compile one of the modules -->
    92     <target name="-compile-one-module">
    93         <mkdir dir="${build.dir}/classes/${module}"/>
    94         <pathconvert pathsep="," property="module.cp">
    95             <path path="${depends}"/>
    96             <mapper type="regexp" from=".*[/\\]([^/\\]*)" to="${build.dir}/\1.jar"/>
    97         </pathconvert>
    98         <javac
    99             bootclasspath="${build.dir}/base.jar"
   100             sourcepath=""
   101             destdir="${build.dir}/classes/${module}"
   102             classpath="${module.cp}"
   103             includejavaruntime="false"
   104             includeantruntime="false"
   105         >
   106             <src refid="src.path"/>
   107             <selector refid="${module}"/>
   108         </javac>
   109         <copy todir="${build.dir}/classes/${module}">
   110             <fileset dir="src/share/classes">
   111                 <and>
   112                     <selector refid="${module}"/>
   113                     <not>
   114                         <filename name="**/*.java"/>
   115                     </not>
   116                 </and>
   117             </fileset>
   118         </copy>
   119 
   120         <jar 
   121             basedir="${build.dir}/classes/${module}"
   122             destfile="${build.dir}/${module}.jar"
   123             compress="false"
   124         />
   125     </target>
   126 
   127     <!-- clean everything -->
   128     <target name="clean">
   129         <delete dir="${build.dir}"/>
   130     </target>
   131 </project>