build.xml
author Jaroslav Tulach <jtulach@netbeans.org>
Fri, 19 Jun 2009 15:33:12 +0200
changeset 1243 10e566202519
parent 1242 17fa6aaa52cb
child 1244 f2029f449786
permissions -rw-r--r--
all java sources compiles as a whole using ant
     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         <antcall target="deprecated7"/>
    10     </target>
    11 
    12     <!-- basic parameters -->
    13     <property name="plugs" value="../../plugs"/>
    14     <fail message="You need to provide location of plugs">
    15         <condition><not><available file="${plugs}/jre/lib/rt-closed.jar"/></not></condition>
    16     </fail>
    17     <pathconvert property="gensrc">
    18         <path><dirset dir="../build"><include name="*/gensrc"/></dirset></path>
    19     </pathconvert>
    20     <fail message="You need to provide location of JDK's generated sources via -Dgensrc=...">
    21         <condition><not><available file="${gensrc}"/></not></condition>
    22     </fail>
    23 
    24     <target name="merge-sources"
    25         description="Copies sources from all over the JDK tree into one place"
    26     >
    27         <mkdir dir="build/sources"/>
    28         <copy todir="build/sources">
    29             <fileset dir="${gensrc}"/>
    30             <fileset dir="${gensrc}/../impsrc">
    31                 <exclude name="org/relaxng/datatype/**"/>
    32             </fileset>
    33             <fileset dir="../jaxp/src/share/classes/">
    34                 <exclude name="org/relaxng/datatype/**"/>
    35             </fileset>
    36             <fileset dir="../langtools/src/share/classes/">
    37                 <exclude name="org/relaxng/datatype/**"/>
    38             </fileset>
    39             <fileset dir="../jaxws/src/share/classes/">
    40                 <exclude name="org/relaxng/datatype/**"/>
    41             </fileset>
    42             <fileset dir="../corba/src/share/classes/"/>
    43         </copy>
    44     </target>
    45 
    46     <path id="src.path">
    47         <pathelement location="src/share/classes"/>
    48         <pathelement location="build/sources"/>
    49         <pathelement location="src/solaris/classes"/>
    50 <!--        <pathelement location="src/windows/classes"/> -->
    51     </path>
    52     <property name="build.dir" location="build/modularize"/>
    53 
    54     <!-- this is the core of the separation - definition
    55       of what classes belong into what compilation group.
    56     -->
    57     <selector id="applet">
    58         <or>
    59             <filename name="java/beans/AppletInitializer*"/>
    60             <filename name="java/applet/**"/>
    61             <filename name="sun/applet/**"/>
    62             <filename name="META-INF/services/sun.beans.AppletProxy"/>
    63         </or>
    64     </selector>
    65     <selector id="beans">
    66         <and>
    67             <or>
    68                 <filename name="java/beans/**"/>
    69                 <filename name="sun/beans/**"/>
    70                 <filename name="com/sun/beans/**"/>
    71             </or>
    72             <none>
    73                 <selector refid="applet"/>
    74                 <selector refid="deprecated7"/>
    75             </none>
    76         </and>
    77     </selector>
    78 
    79     <selector id="deprecated7">
    80         <or>
    81             <filename name="java/beans/Beans*"/>
    82         </or>
    83     </selector>
    84 
    85     <selector id="base">
    86         <!--
    87             <selector refid="applet"/>
    88             <selector refid="beans"/>
    89             <selector refid="client"/>
    90             <selector refid="enterprise"/>
    91             <selector refid="deprecated7"/>
    92             -->
    93             <!-- exclude files that need pre-processing like
    94                 java/nio/ByteBufferAs-X-Buffer.java
    95             -->
    96 
    97         <none>
    98             <filename name="**/*-*"/>
    99             <filename name="java/dyn/**"/>
   100             <filename name="sun/dyn/**"/>
   101 
   102             <filename name="com/sun/script/javascript/**"/>
   103             <filename name="sun/dc/**"/>
   104             <filename name="sun/nio/fs/Solaris**"/>
   105             <filename name="sun/tracing/**"/>
   106             <filename name="com/sun/tracing/ProviderFactory*"/>
   107         </none>
   108     </selector>
   109 
   110     <!-- individual compilation tasks -->
   111 
   112     <target name="deprecated7">
   113         <antcall target="-compile-one-module">
   114             <param name="module" value="deprecated7"/>
   115             <param name="depends" value="beans:applet"/>
   116         </antcall>
   117     </target>
   118     <target name="applet">
   119         <antcall target="-compile-one-module">
   120             <param name="module" value="applet"/>
   121             <param name="depends" value="beans"/>
   122         </antcall>
   123     </target>
   124     <target name="beans">
   125         <antcall target="-compile-one-module">
   126             <param name="module" value="beans"/>
   127         </antcall>
   128     </target>
   129 
   130 
   131     <target name="base">
   132         <antcall target="-compile-one-module">
   133             <param name="module" value="base"/>
   134         </antcall>
   135     </target>
   136 
   137     <!-- shared routine to compile one of the modules -->
   138     <target name="-compile-one-module">
   139         <mkdir dir="${build.dir}/classes/${module}"/>
   140         <pathconvert pathsep=":"  property="module.cp">
   141             <path path="${depends}"/>
   142             <mapper type="regexp" from=".*[/\\]([^/\\]*)" to="${build.dir}/\1.jar"/>
   143         </pathconvert>
   144         <jar
   145             basedir="${build.dir}/classes/${module}"
   146             destfile="${build.dir}/empty.jar"
   147             compress="false"
   148         >
   149             <exclude name="**"/>
   150         </jar>
   151         <javac
   152             bootclasspath="${build.dir}/empty.jar"
   153             sourcepath=""
   154             destdir="${build.dir}/classes/${module}"
   155             includejavaruntime="false"
   156             includeantruntime="false"
   157             classpath="${module.cp}:${plugs}/jre/lib/rt-closed.jar"
   158         >
   159             <src refid="src.path"/>
   160             <selector refid="${module}"/>
   161         </javac>
   162         <copy todir="${build.dir}/classes/${module}">
   163             <fileset dir="src/share/classes">
   164                 <and>
   165                     <selector refid="${module}"/>
   166                     <not>
   167                         <filename name="**/*.java"/>
   168                     </not>
   169                 </and>
   170             </fileset>
   171         </copy>
   172 
   173         <jar 
   174             basedir="${build.dir}/classes/${module}"
   175             destfile="${build.dir}/${module}.jar"
   176             compress="false"
   177         />
   178     </target>
   179 
   180     <!-- clean everything -->
   181     <target name="clean">
   182         <delete dir="${build.dir}"/>
   183     </target>
   184 </project>