build.xml
author Jaroslav Tulach <jtulach@netbeans.org>
Fri, 19 Jun 2009 13:14:51 +0200
changeset 1242 17fa6aaa52cb
child 1243 10e566202519
permissions -rw-r--r--
Can the JDK be compiled by Ant as a whole? Seems so. With this config the compilation yields no 'cannot found' errors
     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     <path id="src.path">
    24         <pathelement location="src/share/classes"/>
    25         <pathelement location="${gensrc}"/>
    26         <pathelement location="${gensrc}/../impsrc"/>
    27         <pathelement location="src/solaris/classes"/>
    28         <pathelement location="../jaxp/src/share/classes/"/>
    29         <pathelement location="../langtools/src/share/classes/"/>
    30         <pathelement location="../jaxws/src/share/classes/"/>
    31         <pathelement location="../corba/src/share/classes/"/>
    32 <!--        <pathelement location="src/windows/classes"/> -->
    33     </path>
    34     <property name="build.dir" location="build/modularize"/>
    35 
    36     <!-- this is the core of the separation - definition
    37       of what classes belong into what compilation group.
    38     -->
    39     <selector id="applet">
    40         <or>
    41             <filename name="java/beans/AppletInitializer*"/>
    42             <filename name="java/applet/**"/>
    43             <filename name="sun/applet/**"/>
    44             <filename name="META-INF/services/sun.beans.AppletProxy"/>
    45         </or>
    46     </selector>
    47     <selector id="beans">
    48         <and>
    49             <or>
    50                 <filename name="java/beans/**"/>
    51                 <filename name="sun/beans/**"/>
    52                 <filename name="com/sun/beans/**"/>
    53             </or>
    54             <none>
    55                 <selector refid="applet"/>
    56                 <selector refid="deprecated7"/>
    57             </none>
    58         </and>
    59     </selector>
    60 
    61     <selector id="deprecated7">
    62         <or>
    63             <filename name="java/beans/Beans*"/>
    64         </or>
    65     </selector>
    66 
    67     <selector id="base">
    68         <!--
    69             <selector refid="applet"/>
    70             <selector refid="beans"/>
    71             <selector refid="client"/>
    72             <selector refid="enterprise"/>
    73             <selector refid="deprecated7"/>
    74             -->
    75             <!-- exclude files that need pre-processing like
    76                 java/nio/ByteBufferAs-X-Buffer.java
    77             -->
    78 
    79         <none>
    80             <filename name="**/*-*"/>
    81             <filename name="java/dyn/**"/>
    82             <filename name="sun/dyn/**"/>
    83 
    84             <filename name="com/sun/script/javascript/**"/>
    85         </none>
    86     </selector>
    87 
    88     <!-- individual compilation tasks -->
    89 
    90     <target name="deprecated7">
    91         <antcall target="-compile-one-module">
    92             <param name="module" value="deprecated7"/>
    93             <param name="depends" value="beans:applet"/>
    94         </antcall>
    95     </target>
    96     <target name="applet">
    97         <antcall target="-compile-one-module">
    98             <param name="module" value="applet"/>
    99             <param name="depends" value="beans"/>
   100         </antcall>
   101     </target>
   102     <target name="beans">
   103         <antcall target="-compile-one-module">
   104             <param name="module" value="beans"/>
   105         </antcall>
   106     </target>
   107 
   108 
   109     <target name="base">
   110         <antcall target="-compile-one-module">
   111             <param name="module" value="base"/>
   112         </antcall>
   113     </target>
   114 
   115     <!-- shared routine to compile one of the modules -->
   116     <target name="-compile-one-module">
   117         <mkdir dir="${build.dir}/classes/${module}"/>
   118         <pathconvert pathsep=":"  property="module.cp">
   119             <path path="${depends}"/>
   120             <mapper type="regexp" from=".*[/\\]([^/\\]*)" to="${build.dir}/\1.jar"/>
   121         </pathconvert>
   122         <jar
   123             basedir="${build.dir}/classes/${module}"
   124             destfile="${build.dir}/empty.jar"
   125             compress="false"
   126         >
   127             <exclude name="**"/>
   128         </jar>
   129         <javac
   130             bootclasspath="${build.dir}/empty.jar"
   131             sourcepath=""
   132             destdir="${build.dir}/classes/${module}"
   133             includejavaruntime="false"
   134             includeantruntime="false"
   135             classpath="${module.cp}:${plugs}/jre/lib/rt-closed.jar"
   136         >
   137             <src refid="src.path"/>
   138             <selector refid="${module}"/>
   139         </javac>
   140         <copy todir="${build.dir}/classes/${module}">
   141             <fileset dir="src/share/classes">
   142                 <and>
   143                     <selector refid="${module}"/>
   144                     <not>
   145                         <filename name="**/*.java"/>
   146                     </not>
   147                 </and>
   148             </fileset>
   149         </copy>
   150 
   151         <jar 
   152             basedir="${build.dir}/classes/${module}"
   153             destfile="${build.dir}/${module}.jar"
   154             compress="false"
   155         />
   156     </target>
   157 
   158     <!-- clean everything -->
   159     <target name="clean">
   160         <delete dir="${build.dir}"/>
   161     </target>
   162 </project>