blob: 121cfddef7e413ccc7030e6d6f5e7fafe6a3c132 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. -->
<!-- ======================================================================
Build source and lay out results in the required format
====================================================================== -->
<project name="build-contribution" default="build" basedir=".">
<description>
Build contributed source and lay out results in the required format
</description>
<target name="help">
<echo>
Apache Harmony Classlibrary Build
Usage:
ant build
Compiles the java and native code to produce a jdk in
"target/hdk/jdk".
ant clean
Removes all the files generated by a build.
ant rebuild
Performs a full build - that is 'clean' then 'build'.
ant test
Runs all the tests.
ant doc
Generates the javadoc.
ant snapshot
Produces a archive (tar/zip) of a build.
ant fetch-depends
Fetches dependencies. Note: Some of Harmony's dependencies are
licensed under terms other than the Apache License v2.
ant properties
Display the common properties that are use in the ant build files.
The 'build' and 'test' targets can be configured to only build/test a single
module by setting the 'build.module' property. For example, to run the tests for
the "luni" module:
ant test -Dbuild.module=luni
The 'test' target can further be configured to run a single test by setting
the 'test.case' property. For example, to run a specific test in the "luni"
module:
ant test -Dbuild.module=luni -Dtest.case=org.apache.harmony.luni.tests.java.lang.MathTest
</echo>
</target>
<property file="${user.home}/.harmony-classlib.properties" />
<property name="hy.target" location="target" />
<property name="hy.component" value="classlib" />
<property name="hy.module" value="toplevel" />
<fail message="Property 'common.resources' is not defined">
<condition>
<not><isset property="common.resources" /></not>
</condition>
</fail>
<mkdir dir="${hy.target}/hdk/build/ant" />
<copy todir="${hy.target}/hdk/build/ant" preservelastmodified="true">
<fileset dir="${common.resources}/make" includes="*.xml"/>
</copy>
<!-- import properties for snapshot targets -->
<import file="${hy.target}/hdk/build/ant/properties.xml" />
<init-hdk/>
<property name="build.output" location="${hy.build.top}/java" />
<property name="tests.output" location="${hy.target}/test_report" />
<property name="tests.support.output" location="${hy.build.top}/test" />
<property name="tests.report.dir" value="${tests.output}/html"/>
<property name="depends.files" location="depends/files"/>
<property name="depends.manifests" location="depends/manifests"/>
<import file="${hy.hdk}/build/ant/depends.xml" />
<property file="make/depends.properties" />
<condition property="needs.vme.v3.hack" value="true">
<or>
<equals arg1="${hy.platform}" arg2="windows.x86" />
<equals arg1="${hy.platform}" arg2="linux.x86" />
</or>
</condition>
<propertyset id="toplevel.props">
<propertyref name="hy.target" />
<propertyref name="hy.component" />
<propertyref name="hy.module" />
</propertyset>
<!-- ================================
target : rebuild
builds with a clean first
================================= -->
<target name="rebuild" depends="clean,build"
description="Performs a full build - that is 'clean' then 'build'" />
<target name="build"
description="Compiles the java, natives and tests to produce a jdk/hdk"
depends="-build-java,-build-native,-build-test,-build-modules" />
<target name="clean"
depends="-init-hdk-for-clean,-clean-modules,-clean-check,
-clean-native,-clean-test"
description="Removes all the files generated by a build" />
<target name="-build-java" unless="skip.java.build"
depends="-init-hdk,-layout-java"
description="Compiles the java code only" >
<ensure-javac/>
<mkdir dir="${build.output}" />
<hy.javac destdir="${build.output}"
includeAntRuntime="no">
<src path="modules/accessibility/src/main/java" />
<src path="modules/annotation/src/main/java" />
<src path="modules/applet/src/main/java" />
<src path="modules/archive/src/main/java" />
<src path="modules/auth/src/main/java/${hy.os.family}" />
<src path="modules/auth/src/main/java/common" />
<src path="modules/awt/src/main/java/${hy.os.family}" />
<src path="modules/awt/src/main/java/common" />
<src path="modules/beans/src/main/java" />
<src path="modules/concurrent/src/main/java" />
<src path="modules/crypto/src/main/java" />
<src path="modules/instrument/src/main/java" />
<src path="modules/imageio/src/main/java" />
<src path="modules/jndi/src/main/java" />
<src path="modules/logging/src/main/java" />
<src path="modules/lang-management/src/main/java" />
<src path="modules/luni-kernel/src/main/java" />
<src path="modules/luni/src/main/java" />
<src path="modules/math/src/main/java" />
<src path="modules/misc/src/main/java" />
<src path="modules/nio/src/main/java/common" />
<src path="modules/nio/src/main/java/${hy.os.family}" />
<src path="modules/nio_char/src/main/java" />
<!-- pack200 uses customized build script and
should not be built from top-level build.xml -->
<!--src path="modules/pack200/src/main/java" /-->
<src path="modules/prefs/src/main/java" />
<src path="modules/print/src/main/java/${hy.os.family}" />
<src path="modules/print/src/main/java/common" />
<src path="modules/regex/src/main/java" />
<src path="modules/rmi/src/main/java" />
<src path="modules/security-kernel/src/main/java" />
<src path="modules/security/src/main/java/${hy.os.family}" />
<src path="modules/security/src/main/java/common" />
<src path="modules/sound/src/main/java" />
<src path="modules/sql/src/main/java" />
<src path="modules/suncompat/src/main/java" />
<src path="modules/swing/src/main/java/${hy.os.family}" />
<src path="modules/swing/src/main/java/common" />
<src path="modules/text/src/main/java" />
<src path="modules/x-net/src/main/java/" />
<classpath>
<fileset dir="${hy.jdk}/jre/lib/boot">
<include name="**/*.jar" />
<exclude name="**/*-src.jar" />
</fileset>
</classpath>
<!-- We need to set some BCP to avoid the compiler picking
up the JRE's JARs -->
<bootclasspath>
<fileset dir="${depends.jars}">
<!-- FIXME: picked mx4j arbitrarily, needs to be non-empty set -->
<include name="**/mx4j.jar" />
</fileset>
</bootclasspath>
</hy.javac>
</target>
<target name="-build-modules" depends="-svn-info">
<poll-modules target="-build-no-check" />
</target>
<target name="-clean-modules">
<poll-modules target="clean" />
</target>
<target name="-layout-java" depends="check-depends">
<!-- Create the structure -->
<mkdir dir="${hy.jdk}/jre/bin" />
<mkdir dir="${hy.jdk}/jre/lib/boot" />
<mkdir dir="${hy.jdk}/jre/lib/ext" />
<mkdir dir="${hy.jdk}/jre/lib/security" />
<!-- Copy across the required files -->
<copy file="LICENSE" todir="${hy.hdk}" verbose="yes" />
<copy file="NOTICE" todir="${hy.hdk}" verbose="yes" />
<!-- Copy across the boot dependency jars --><!-- TOFIX clean these? -->
<copy todir="${hy.jdk}/jre/lib/boot">
<fileset dir="${depends.jars}">
<patternset includes="icu4j_4.4.1.1/*.jar" />
</fileset>
<fileset dir="${depends.manifests}"/>
</copy>
<!-- Copy across the extension dependency jars -->
<copy tofile="${hy.jdk}/jre/lib/ext/bcprov.jar" verbose="true"
flatten="yes" overwrite="true">
<fileset file="${bcprov.jar}" />
</copy>
<!-- Copy across the support files -->
<copy todir="${hy.jdk}/jre/lib">
<fileset dir="${depends.files}">
<include name="content-types.properties" />
</fileset>
</copy>
<copy todir="${hy.jdk}/jre/lib/boot">
<fileset dir="${depends.files}">
<include name="bootclasspath.properties" />
</fileset>
</copy>
<fixcrlf srcdir="${hy.jdk}/jre/lib/boot"
includes="bootclasspath.properties" />
<copy todir="${hy.jdk}/jre/lib/security">
<fileset dir="${depends.files}">
<include name="java.policy" />
<include name="java.security" />
</fileset>
</copy>
<copy todir="${hy.jdk}/jre/lib">
<fileset dir="${depends.files}">
<include name="net.properties" />
</fileset>
</copy>
<copy todir="${hy.jdk}/jre/lib">
<fileset dir="${depends.files}">
<include name="rowset.properties" />
</fileset>
</copy>
</target>
<target name="-clean-check" unless="skip.java.build"
depends="-clean-java-catch-all-test,
-clean-java-catch-all,
-clean-java-layout"
description="Checks that the module clean worked correctly" />
<target name="-clean-java-catch-all-test">
<!-- without this test the pathconvert in the catch all clean
target fails -->
<available property="catch.all.required"
file="${build.output}" type="dir" />
</target>
<target name="-clean-java-catch-all" if="catch.all.required">
<fileset id="built.files" dir="${build.output}">
<include name="**/**" />
</fileset>
<pathconvert property="built.files.list"
refid="built.files"
pathsep="${line.separator}" />
<condition property="built.files.exist">
<not>
<equals arg1="${built.files.list}" arg2="" />
</not>
</condition>
<delete includeemptydirs="true" failonerror="false">
<fileset refid="built.files" />
</delete>
<condition property="continue">
<equals arg1="${keep.working}" arg2="true" />
</condition>
<fail if="built.files.exist" unless="continue">
...
Built files still exist after module clean targets have run. This
probably means that one or more patternsets are incomplete. The
remaining files are:
${built.files.list}
</fail>
</target>
<target name="-clean-java-layout">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${hy.jdk}">
<exclude name="jre/bin/default/**" />
<exclude name="jre/bin/**" />
<exclude name="jre/lib/ext/**" />
</fileset>
<fileset dir="${hy.hdk}">
<include name="LICENSE" />
<include name="NOTICE" />
</fileset>
</delete>
</target>
<target name="-build-native" unless="skip.native.build"
depends="-init-hdk,-svn-info,-layout-natives"
description="Compiles the native code only" >
<!-- these must be run in a specific order due to dependencies -->
<ant dir="modules/portlib" target="-build-native"
inheritall="false">
<property name="hy.target" location="${hy.target}"/>
<propertyset refid="module.props" />
</ant>
<ant dir="modules/luni" target="-build-native-core"
inheritall="false">
<property name="hy.target" location="${hy.target}"/>
<propertyset refid="module.props" />
</ant>
<ant dir="modules/archive" target="-build-native"
inheritall="false">
<property name="hy.target" location="${hy.target}"/>
<propertyset refid="module.props" />
</ant>
<ant dir="modules/luni" target="-build-native-secondary"
inheritall="false">
<property name="hy.target" location="${hy.target}"/>
<propertyset refid="module.props" />
</ant>
</target>
<target name="-layout-natives" unless="skip.native.build"
depends="check-depends,-layout.windows,-layout.vme.v3.hack"
description="Construct the correct directory structure for native binaries">
<!-- Create the target directory structure -->
<mkdir dir="${hy.jdk}/jre/bin" />
<mkdir dir="${hy.jdk}/include" />
<mkdir dir="${hy.hdk}/lib"/>
<!-- NLS catalog files -->
<copy todir="${hy.jdk}/jre/bin" overwrite="yes">
<fileset dir="${depends.files}">
<include name="harmony*.properties" />
</fileset>
</copy>
</target>
<target name="-layout.windows" unless="skip.native.build"
if="is.windows">
<!-- workaround until msdll is moved. -->
<copy file="${msvcr.dll}" todir="${hy.jdk}/jre/bin" overwrite="yes" />
<copy file="${msvcp.dll}" todir="${hy.jdk}/jre/bin" overwrite="yes" />
</target>
<target name="-layout.vme.v3.hack" unless="skip.native.build"
if="needs.vme.v3.hack">
<echo>Deploying empty ICU dynamic library stub</echo>
<copy todir="${hy.jdk}/jre/bin" verbose="true">
<fileset dir="${depends.files}">
<include name="hyempty.dll" if="is.windows" />
</fileset>
<globmapper from="*hyempty.dll" to="*ICUInterface34.dll" />
</copy>
<copy todir="${hy.jdk}/jre/bin" verbose="true">
<fileset dir="${depends.files}">
<include name="libhyempty.so" if="is.linux" />
</fileset>
<globmapper from="*libhyempty.so" to="*libICUInterface34.so" />
</copy>
</target>
<target name="-clean-native" unless="skip.native.build"
depends="-init-hdk-for-clean"
description="Removes the compiled native code" >
<delete dir="${hy.hdk}/lib" />
<delete dir="${hy.hdk}/include" />
<delete dir="${hy.hdk}/jdk/include" />
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${hy.jdk}">
<include name="**/bin/java${exe.suffix}" />
<include name="**/bin/javaw${exe.suffix}" />
<include name="**/bin/*${shlib.suffix}*" />
<include name="**/bin/*.pdb" />
<include name="**/bin/harmony*.properties" />
</fileset>
</delete>
</target>
<target name="test"
depends="-test-init-hdk,clean-test-output"
description="Runs all tests">
<mkdir dir="${tests.output}" />
<ant antfile="${hy.hdk}/build/test/build.xml"
inheritall="false" target="test">
<property name="tests.output" value="${tests.output}"/>
</ant>
</target>
<target name="-build-test" unless="skip.test.build"
depends="-test-init-hdk,-support-jar"
description="Compile and archive all tests" />
<target name="-clean-test" unless="skip.test.build"
depends="-init-hdk-for-clean"
description="Removes the generated tests" >
<delete dir="${tests.support.output}" />
<delete dir="${hy.hdk}/build/test" />
</target>
<target name="clean-test-output">
<delete dir="${tests.output}" />
</target>
<target name="findbugs" depends="check-depends"
description="Runs FindBugs on all modules">
<echo>
========================================
Finding bugs in all class libraries...
========================================
</echo>
<poll-modules target="findbugs" />
</target>
<!-- =================================
target: doc
================================= -->
<target name="doc"
description="Generates the javadoc">
<echo>
========================================
Generating HTML using Doxygen...
========================================
</echo>
<ant antfile="doc/build.xml" inheritall="false" />
</target>
<target name="clean-doc" if="${really.clean.doc}">
<!-- We really shouldn't do this, since svn diff complains
with svn: Working copy 'doc/kernel_doc' is missing or not
locked if we run it. We shouldn't really clean things
that are in the repository. -->
<ant antfile="doc/build.xml" inheritall="false" target="clean" />
</target>
<!-- =================================
target: -properties
================================= -->
<target name="-properties" depends="-svn-info">
<property name="deploy.file.prefix"
value="harmony-classlib-r${svn.revision}" />
<property name="deploy.tar"
value="${deploy.file.prefix}-${hy.os}-${hy.arch}-snapshot.tar.gz" />
<property name="deploy.zip"
value="${deploy.file.prefix}-${hy.os}-${hy.arch}-snapshot.zip" />
</target>
<!-- =================================
target: snapshot
================================= -->
<target name="snapshot" depends="-snapshot-tar,-snapshot-zip"
description="Produce a classlib snapshot tar/zip" />
<!-- =================================
target: snapshot-tar
================================= -->
<target name="-snapshot-tar" depends="build, -properties" if="is.unix">
<echo>
========================================
Generating snapshot tar
========================================
</echo>
<tar destfile="${deploy.tar}" compression="gzip">
<tarfileset dir="${basedir}" prefix="Harmony">
<include name="LICENSE" />
<include name="NOTICE" />
</tarfileset>
<tarfileset dir="${hy.hdk}" prefix="Harmony">
<include name="build/**" />
<include name="include/**" />
<include name="jdk/**" />
<exclude name="jdk/jre/bin/default/**" />
<exclude name="jdk/jre/bin/java" />
<include name="lib/**" />
</tarfileset>
<tarfileset dir="${hy.hdk}" prefix="Harmony" mode="755">
<include name="jdk/jre/bin/java" />
</tarfileset>
<tarfileset dir="${basedir}/make/resources"
includes="README-snapshot.txt"
fullpath="Harmony/README"/>
</tar>
<chksum file="${deploy.tar}" />
<chksum file="${deploy.tar}" type="sha" />
</target>
<!-- =================================
target: snapshot-zip
================================= -->
<target name="-snapshot-zip" depends="build,-properties" if="is.windows">
<echo>
========================================
Generating snapshot zip
========================================
</echo>
<zip destfile="${deploy.zip}">
<zipfileset dir="${basedir}" prefix="Harmony">
<include name="LICENSE" />
<include name="NOTICE" />
</zipfileset>
<zipfileset dir="${hy.hdk}" prefix="Harmony">
<include name="build/**" />
<include name="include/**" />
<include name="jdk/**" />
<exclude name="jdk/jre/bin/default/**" />
<exclude name="jdk/jre/bin/java" />
<include name="lib/**" />
</zipfileset>
<zipfileset dir="${basedir}/make/resources"
includes="README-snapshot.txt"
fullpath="Harmony/README.txt"/>
</zip>
<chksum file="${deploy.zip}" />
<chksum file="${deploy.zip}" type="sha" />
</target>
<target name="check-depends" depends="-init-hdk,-check-depends"
description="Report on whether the dependencies are met">
<poll-modules target="check-depends" />
</target>
<target name="-check-depends" description="Check top-level dependencies">
<ant antfile="make/depends.xml" inheritall="false" target="check">
<propertyset refid="toplevel.props" />
</ant>
</target>
<target name="fetch-depends" depends="-init-hdk"
description="Fetches dependencies. Note: Some of Harmony's dependencies are licensed under terms other than the Apache License v2.">
<ant antfile="make/depends.xml" inheritall="false" target="download">
<propertyset refid="toplevel.props" />
</ant>
<poll-modules target="fetch-depends" />
</target>
<target name="properties" depends="echo"
description="Display the properties that are use in the ant build files"
/>
<!-- test support -->
<target name="-support-jar" unless="skip.test.build"
depends="-compile-support">
<mkdir dir="${hy.hdk}/build/test" />
<hy.jar.bin destfile="${hy.hdk}/build/test/support.jar"
manifest="support/META-INF/MANIFEST.MF">
<fileset dir="${tests.support.output}" />
</hy.jar.bin>
<copy todir="${hy.hdk}/build/test">
<fileset dir="${jetty.dir}">
<include name="*.jar" />
</fileset>
</copy>
</target>
<target name="-compile-support" unless="skip.test.build"
depends="-copy-test-resources,-check-depends"
description="Compile the unit test source">
<ensure-javac/>
<mkdir dir="${tests.support.output}" />
<hy.javac destdir="${tests.support.output}">
<src path="support/src/test/java" />
<classpath location="${junit.jar}" />
<classpath location="${tests.support.output}" />
<classpath>
<fileset dir="${jetty.dir}">
<include name="*.jar" />
</fileset>
</classpath>
<bootclasspath location="${build.output}" />
<bootclasspath>
<fileset dir="${hy.hdk}/jdk/jre/lib/boot">
<include name="**/*.jar" />
</fileset>
</bootclasspath>
</hy.javac>
</target>
<target name="-copy-test-resources" unless="skip.test.build"
description="Copy non-Java files from test support tree to the support output tree">
<mkdir dir="${tests.support.output}" />
<copy todir="${tests.support.output}" includeemptydirs="false">
<fileset dir="support/src/test/java">
<exclude name="**/*.java" />
</fileset>
<fileset file="support/src/test/resources/hyts_Foo.c"/>
</copy>
<copy file="support/src/test/resources/config/testing.policy"
todir="${hy.hdk}/build/test" outputencoding="UTF-8" />
</target>
<target name="-test-init-hdk" unless="skip.test.build"
depends="-init-hdk">
<copy file="make/test.properties"
tofile="${hy.hdk}/build/test/test.properties"/>
<copy file="make/run-test.xml"
tofile="${hy.hdk}/build/test/build.xml"/>
</target>
<!-- hdk initialisation -->
<target name="-init-hdk">
<init-hdk />
</target>
<target name="-init-hdk-for-clean">
<!-- This is currently the same as "-init-hdk" but has
a different name since otherwise it would only
get called once - before the clean - during a rebuild
and not called a second time - before the build.
-->
<init-hdk />
</target>
<macrodef name="chksum">
<attribute name="file" />
<attribute name="type" default="md5" />
<sequential>
<checksum property="@{file}.@{type}" file="@{file}"
algorithm="@{type}" />
<echo file="@{file}.@{type}"
message="${@{file}.@{type}} @{file}${line.separator}" />
</sequential>
</macrodef>
</project>