Can the JDK be compiled by Ant as a whole? Seems so. With this config the compilation yields no 'cannot found' errors
authorJaroslav Tulach <jtulach@netbeans.org>
Fri, 19 Jun 2009 13:14:51 +0200
changeset 124217fa6aaa52cb
parent 1235 f72c0dc047b9
child 1243 10e566202519
Can the JDK be compiled by Ant as a whole? Seems so. With this config the compilation yields no 'cannot found' errors
build.xml
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build.xml	Fri Jun 19 13:14:51 2009 +0200
     1.3 @@ -0,0 +1,162 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<project name="modularize" default="all" basedir=".">
     1.6 +    <description>Scripts to build JDK Java sources in modularized way</description>
     1.7 +
     1.8 +    <target name="all">
     1.9 +        <antcall target="base"/>
    1.10 +        <antcall target="beans"/>
    1.11 +        <antcall target="applet"/>
    1.12 +        <antcall target="deprecated7"/>
    1.13 +    </target>
    1.14 +
    1.15 +    <!-- basic parameters -->
    1.16 +    <property name="plugs" value="../../plugs"/>
    1.17 +    <fail message="You need to provide location of plugs">
    1.18 +        <condition><not><available file="${plugs}/jre/lib/rt-closed.jar"/></not></condition>
    1.19 +    </fail>
    1.20 +    <pathconvert property="gensrc">
    1.21 +        <path><dirset dir="../build"><include name="*/gensrc"/></dirset></path>
    1.22 +    </pathconvert>
    1.23 +    <fail message="You need to provide location of JDK's generated sources via -Dgensrc=...">
    1.24 +        <condition><not><available file="${gensrc}"/></not></condition>
    1.25 +    </fail>
    1.26 +    <path id="src.path">
    1.27 +        <pathelement location="src/share/classes"/>
    1.28 +        <pathelement location="${gensrc}"/>
    1.29 +        <pathelement location="${gensrc}/../impsrc"/>
    1.30 +        <pathelement location="src/solaris/classes"/>
    1.31 +        <pathelement location="../jaxp/src/share/classes/"/>
    1.32 +        <pathelement location="../langtools/src/share/classes/"/>
    1.33 +        <pathelement location="../jaxws/src/share/classes/"/>
    1.34 +        <pathelement location="../corba/src/share/classes/"/>
    1.35 +<!--        <pathelement location="src/windows/classes"/> -->
    1.36 +    </path>
    1.37 +    <property name="build.dir" location="build/modularize"/>
    1.38 +
    1.39 +    <!-- this is the core of the separation - definition
    1.40 +      of what classes belong into what compilation group.
    1.41 +    -->
    1.42 +    <selector id="applet">
    1.43 +        <or>
    1.44 +            <filename name="java/beans/AppletInitializer*"/>
    1.45 +            <filename name="java/applet/**"/>
    1.46 +            <filename name="sun/applet/**"/>
    1.47 +            <filename name="META-INF/services/sun.beans.AppletProxy"/>
    1.48 +        </or>
    1.49 +    </selector>
    1.50 +    <selector id="beans">
    1.51 +        <and>
    1.52 +            <or>
    1.53 +                <filename name="java/beans/**"/>
    1.54 +                <filename name="sun/beans/**"/>
    1.55 +                <filename name="com/sun/beans/**"/>
    1.56 +            </or>
    1.57 +            <none>
    1.58 +                <selector refid="applet"/>
    1.59 +                <selector refid="deprecated7"/>
    1.60 +            </none>
    1.61 +        </and>
    1.62 +    </selector>
    1.63 +
    1.64 +    <selector id="deprecated7">
    1.65 +        <or>
    1.66 +            <filename name="java/beans/Beans*"/>
    1.67 +        </or>
    1.68 +    </selector>
    1.69 +
    1.70 +    <selector id="base">
    1.71 +        <!--
    1.72 +            <selector refid="applet"/>
    1.73 +            <selector refid="beans"/>
    1.74 +            <selector refid="client"/>
    1.75 +            <selector refid="enterprise"/>
    1.76 +            <selector refid="deprecated7"/>
    1.77 +            -->
    1.78 +            <!-- exclude files that need pre-processing like
    1.79 +                java/nio/ByteBufferAs-X-Buffer.java
    1.80 +            -->
    1.81 +
    1.82 +        <none>
    1.83 +            <filename name="**/*-*"/>
    1.84 +            <filename name="java/dyn/**"/>
    1.85 +            <filename name="sun/dyn/**"/>
    1.86 +
    1.87 +            <filename name="com/sun/script/javascript/**"/>
    1.88 +        </none>
    1.89 +    </selector>
    1.90 +
    1.91 +    <!-- individual compilation tasks -->
    1.92 +
    1.93 +    <target name="deprecated7">
    1.94 +        <antcall target="-compile-one-module">
    1.95 +            <param name="module" value="deprecated7"/>
    1.96 +            <param name="depends" value="beans:applet"/>
    1.97 +        </antcall>
    1.98 +    </target>
    1.99 +    <target name="applet">
   1.100 +        <antcall target="-compile-one-module">
   1.101 +            <param name="module" value="applet"/>
   1.102 +            <param name="depends" value="beans"/>
   1.103 +        </antcall>
   1.104 +    </target>
   1.105 +    <target name="beans">
   1.106 +        <antcall target="-compile-one-module">
   1.107 +            <param name="module" value="beans"/>
   1.108 +        </antcall>
   1.109 +    </target>
   1.110 +
   1.111 +
   1.112 +    <target name="base">
   1.113 +        <antcall target="-compile-one-module">
   1.114 +            <param name="module" value="base"/>
   1.115 +        </antcall>
   1.116 +    </target>
   1.117 +
   1.118 +    <!-- shared routine to compile one of the modules -->
   1.119 +    <target name="-compile-one-module">
   1.120 +        <mkdir dir="${build.dir}/classes/${module}"/>
   1.121 +        <pathconvert pathsep=":"  property="module.cp">
   1.122 +            <path path="${depends}"/>
   1.123 +            <mapper type="regexp" from=".*[/\\]([^/\\]*)" to="${build.dir}/\1.jar"/>
   1.124 +        </pathconvert>
   1.125 +        <jar
   1.126 +            basedir="${build.dir}/classes/${module}"
   1.127 +            destfile="${build.dir}/empty.jar"
   1.128 +            compress="false"
   1.129 +        >
   1.130 +            <exclude name="**"/>
   1.131 +        </jar>
   1.132 +        <javac
   1.133 +            bootclasspath="${build.dir}/empty.jar"
   1.134 +            sourcepath=""
   1.135 +            destdir="${build.dir}/classes/${module}"
   1.136 +            includejavaruntime="false"
   1.137 +            includeantruntime="false"
   1.138 +            classpath="${module.cp}:${plugs}/jre/lib/rt-closed.jar"
   1.139 +        >
   1.140 +            <src refid="src.path"/>
   1.141 +            <selector refid="${module}"/>
   1.142 +        </javac>
   1.143 +        <copy todir="${build.dir}/classes/${module}">
   1.144 +            <fileset dir="src/share/classes">
   1.145 +                <and>
   1.146 +                    <selector refid="${module}"/>
   1.147 +                    <not>
   1.148 +                        <filename name="**/*.java"/>
   1.149 +                    </not>
   1.150 +                </and>
   1.151 +            </fileset>
   1.152 +        </copy>
   1.153 +
   1.154 +        <jar 
   1.155 +            basedir="${build.dir}/classes/${module}"
   1.156 +            destfile="${build.dir}/${module}.jar"
   1.157 +            compress="false"
   1.158 +        />
   1.159 +    </target>
   1.160 +
   1.161 +    <!-- clean everything -->
   1.162 +    <target name="clean">
   1.163 +        <delete dir="${build.dir}"/>
   1.164 +    </target>
   1.165 +</project>