build.xml revision 1194
<!--
! CDDL HEADER START
!
! The contents of this file are subject to the terms of the
! Common Development and Distribution License, Version 1.0 only
! (the "License"). You may not use this file except in compliance
! with the License.
!
! You can obtain a copy of the license at
! See the License for the specific language governing permissions
! and limitations under the License.
!
! When distributing Covered Code, include this CDDL HEADER in each
! file and include the License file at
! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
! add the following below this CDDL HEADER, with the fields enclosed
! by brackets "[]" replaced with your own identifying information:
! Portions Copyright [yyyy] [name of copyright owner]
!
! CDDL HEADER END
!
!
! Portions Copyright 2006-2007 Sun Microsystems, Inc.
! -->
<project name="Directory Server" basedir="." default="package">
<description>
This is the build script for the OpenDS Directory Server. See the BUILDING
file in this directory for build instructions.
</description>
<!-- General server-wide properties -->
<!-- Properties for build tools -->
<!-- Properties for use in unit testing. -->
<property name="unittest.testng.src.dir"
location="${unittest.testng.dir}/src/server"/>
<property name="unittest.classes.dir"
location="${build.dir}/unit-tests/classes" />
<property name="unittest.report.dir"
location="${build.dir}/unit-tests/report"/>
<property name="unittest.resource.dir"
location="${build.dir}/unit-tests/resource"/>
<!-- Properties for use in functional/integration testing. -->
<property name="functest.testng.dir"
location="tests/integration-tests-testng" />
<property name="functest.testng.src.dir"
location="${functest.testng.dir}/src"/>
<!-- Properties for use with the DSML component. -->
<!-- Properties for use with the Quick Setup. -->
<property name="quicksetup.classes.dir"
location="${build.dir}/quicksetup/classes" />
<!-- Properties for use with the Status Panel. -->
<property name="statuspanel.classes.dir"
location="${build.dir}/statuspanel/classes" />
<!-- Properties for coverage diff reports -->
<property name="cvgdiff.report.dir"
location="${cvgdiff.dir}/report" />
<!-- Properties for code coverage testing. -->
<property name="coverage.report.dir"
location="${coverage.dir}/reports/unit" />
<property name="coverage.instr.dir"
location="${coverage.dir}/instrumentedcode" />
<property name="coverage.data.dir"
location="${coverage.dir}/gathereddata" />
<!-- Properties for the EMMA code coverage tool. -->
<!-- Properties for the AspectJ tools -->
<!-- Properties for the TestNG unit testing tool. -->
<!-- Properties for the ANT build tool. -->
<!-- Properties for the checkstyle tool. -->
<!-- Properties for the SVNKit tool. -->
<!-- Properties for Directory Server version information. -->
<property name="dynconstants.file"
<property name="dynconstants.stubfile"
location="${resource.dir}/DynamicConstants.java.stubs" />
<property file="PRODUCT" />
<!-- Properties for administration framework code generation. -->
<!-- Create a package bundle containing the DSML library. -->
<target name="dsml" depends="predsml,package"
description="Build a Directory Server package bundle with DSML.">
</target>
<!-- The build target that should be used before committing code. -->
<target name="precommit" depends="checkstyle,clean,copyrightdates,eolstyle,dsml,javadoc,testwithcoverage"
description="Perform all processing needed before committing code.">
</target>
<!-- The build target that should be used for nightly builds. -->
<target name="nightly"
depends="enableweave,checkstyle,dsml,javadoc,coverage,testall"
description="Perform all processing needed for nightly builds.">
</target>
<!-- The build target that should be used for weekly builds. -->
<target name="weekly" depends="nightly"
description="Perform all processing needed for weekly builds.">
</target>
<!-- The build target that should be used to build everything. -->
<target name="all"
depends="enableweave,checkstyle,clean,copyrightdates,eolstyle,dsml,javadoc,testallwithcoverage"
description="Build using all defined targets.">
</target>
<!-- Remove all dynamically-generated build files. -->
<target name="clean" depends="cleanadmin"
description="Clean up any files generated during the build process">
<delete dir="${build.dir}" />
<delete file="${dynconstants.file}" />
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</target>
<!-- Perform common initialization common to several targets after cleaning out the previous build environment. -->
<target name="cleaninit" depends="clean,init">
</target>
<!-- Perform common initialization common to several targets. -->
<target name="init">
<path id="run.classpath">
<pathelement location="${classes.dir}" />
</path>
<tstamp>
<format property="timestamp" pattern="yyyyMMddHHmmss" />
</tstamp>
<condition property="DEBUG_BUILD" value="false">
<not>
<isset property="DEBUG_BUILD" />
</not>
</condition>
<condition property="WEAVE_ENABLED" value="false">
<not>
<isset property="WEAVE_ENABLED" />
</not>
</condition>
<condition property="MEM" value="128M">
<not>
<isset property="MEM" />
</not>
</condition>
<!--
! For some reason, some Apple VMs put quotes around the value of the
! java.vm.vendor property, which wreaks havoc with DynamicConstants. This
! pair of conditions attempts to work around that by detecting the quote
! and surrounding the value with backslashes.
! -->
<condition property="JVM_VENDOR" value="Apple Computer">
casesensitive="false" />
</condition>
<not>
<isset property="JVM_VENDOR" />
</not>
</condition>
</target>
<!-- Build the DynamicConstants.java file and any of its dependencies. -->
<target name="dynamicconstants" depends="init,buildtools">
<!-- Get the revision number of the current Subversion workspace -->
<taskdef name="getsvnrevision"
classname="org.opends.build.tools.GetSubversionRevision">
<classpath>
<fileset dir="${build.dir}/build-tools">
<include name="*.jar" />
</fileset>
<fileset dir="${svnkit.dir}">
<include name="*.jar" />
</fileset>
</classpath>
</taskdef>
<getsvnrevision property="REVISION_NUMBER" />
<!-- Generate the DynamicConstants.java file.
Be warned that the .stubs file references the following properties
PRODUCT_NAME, SHORT_NAME, MAJOR_VERSION, MINOR_VERSION, POINT_VERSION,
VERSION_QUALIFIER, FIX_IDS, timestamp, user.name, java.version,
java.vendor, java.vm.version, JVM_VENDOR, DEBUG_BUILD, REVISION_NUMBER,
WEAVE_ENABLED
If you change the name of any of those properties in this build.xml
you'll need to relfect the same change in the .stubs file
-->
<copy file="${dynconstants.stubfile}"
tofile="${dynconstants.file}"
overwrite="true" >
<filterchain>
<expandproperties/>
</filterchain>
</copy>
</target>
<!-- Check modified files to see if any copyright updates are needed. -->
<target name="copyrightdates" depends="buildtools"
description="Ensure updated files have the correct copyright year" >
<taskdef name="checkcopyrightdates"
classname="org.opends.build.tools.CheckCopyrightDates">
<classpath>
<fileset dir="${build.dir}/build-tools">
<include name="*.jar" />
</fileset>
<fileset dir="${svnkit.dir}">
<include name="*.jar" />
</fileset>
</classpath>
</taskdef>
<checkcopyrightdates>
<fileset dir="${basedir}" includes="**/*.xml" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.xsd" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.xsl" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.html" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.sh" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.bat" excludes="build/**/* " />
<fileset dir="${basedir}" includes="**/*.ldif" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.txt" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.c" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.h" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.mc" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/Makefile" excludes="build/**/*" />
</checkcopyrightdates>
</target>
<!-- Check added files to see if any svn:eol-style updates are needed. -->
<target name="eolstyle" depends="buildtools"
description="Ensure added files have the correct svn:eol-style" >
<taskdef name="checkeolstyle"
classname="org.opends.build.tools.CheckEOLStyle">
<classpath>
<fileset dir="${build.dir}/build-tools">
<include name="*.jar" />
</fileset>
<fileset dir="${svnkit.dir}">
<include name="*.jar" />
</fileset>
</classpath>
</taskdef>
<checkeolstyle>
<fileset dir="${basedir}" includes="**/*.xml" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.xsd" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.xsl" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.html" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.sh" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.bat" excludes="build/**/* " />
<fileset dir="${basedir}" includes="**/*.ldif" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.txt" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.c" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.h" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/*.mc" excludes="build/**/*" />
<fileset dir="${basedir}" includes="**/Makefile" excludes="build/**/*" />
</checkeolstyle>
</target>
<!-- Ensure that the source code meets basic style requirements. -->
<target name="checkstyle" description="Perform basic source style checks">
<mkdir dir="${checkstyle.cache.dir}" />
<taskdef resource="checkstyletask.properties"
classpath="${checkstyle.dir}/checkstyle-all-4.1.jar" />
<checkstyle config="${checkstyle.dir}/opends-checkstyle.xml"
failOnViolation="true">
<formatter type="plain" />
</checkstyle>
<checkstyle config="${checkstyle.dir}/opends-checkstyle.xml"
failOnViolation="true">
<formatter type="plain" />
</checkstyle>
<checkstyle config="${checkstyle.dir}/opends-checkstyle.xml"
failOnViolation="true">
<formatter type="plain" />
</checkstyle>
<checkstyle config="${checkstyle.dir}/opends-doctarget-checkstyle.xml"
failOnViolation="true">
includes="**/*.java" />
includes="**/*.java" />
<formatter type="plain" />
</checkstyle>
<checkstyle config="${checkstyle.dir}/opends-unittest-checkstyle.xml"
failOnViolation="true">
<formatter type="plain" />
</checkstyle>
<checkstyle config="${checkstyle.dir}/opends-functest-checkstyle.xml"
failOnViolation="true">
<formatter type="plain" />
</checkstyle>
</target>
<!-- Compile the Directory Server source files. -->
<target name="cleancompile"
depends="cleaninit,compilequicksetup,weave,compilestatuspanel"
description="Recompile the Directory Server source files.">
</target>
<!-- Compile the Directory Server source files. -->
<target name="compile"
depends="init,dynamicconstants,compileadmin"
description="Compile the Directory Server source files.">
<mkdir dir="${classes.dir}" />
excludes="**/package-info.java"
deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}">
<compilerarg value="-Xlint:all" />
<classpath>
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</classpath>
</javac>
</target>
<target name="prepweave">
<equals arg1="${WEAVE_ENABLED}" arg2="true" />
</condition>
</target>
<echo message=" Weaving the source code with automatic AspectJ debug logging."/>
<echo message=" Build with -DWEAVE_ENABLED=false to turn this off."/>
<classpath>
<pathelement location="${aj.lib.dir}/aspectjtools.jar" />
</classpath>
</taskdef>
deprecation="true" fork="true" maxmem="${MEM}">
<classpath>
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</classpath>
</iajc>
</target>
<!-- Compile the Quick Setup source files. -->
<target name="compilequicksetup" depends="buildtools,weave"
description="Compile the Quick Setup source files.">
<mkdir dir="${quicksetup.classes.dir}" />
target="1.5" deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}">
<include name="**/org/opends/server/util/SetupUtils.java"/>
<include name="**/org/opends/server/util/CertificateManager.java"/>
<include name="**/org/opends/server/util/DynamicConstants.java"/>
<include name="**/org/opends/server/types/OperatingSystem.java"/>
<compilerarg value="-Xlint:all" />
</javac>
target="1.5" deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}">
<compilerarg value="-Xlint:all" />
<classpath>
<fileset dir="${build.dir}/build-tools">
<include name="build-tools.jar" />
</fileset>
<pathelement path="${classes.dir}"/>
</classpath>
</javac>
<copy todir="${quicksetup.classes.dir}">
<fileset dir="${quicksetup.src.dir}"
includes="**/*.properties, **/*.gif, **/*.png" />
</copy>
</target>
<!-- Compile the Status Panel source files. -->
<target name="compilestatuspanel" depends="compilequicksetup"
description="Compile the Status Panel source files.">
<mkdir dir="${statuspanel.classes.dir}" />
target="1.5" deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}">
<compilerarg value="-Xlint:all" />
<classpath>
<pathelement path="${classes.dir}"/>
<pathelement path="${quicksetup.classes.dir}"/>
</classpath>
</javac>
<copy todir="${statuspanel.classes.dir}">
<fileset dir="${statuspanel.src.dir}"
includes="**/*.properties, **/*.gif, **/*.png" />
</copy>
</target>
<!--
! Rebuild the Directory Server without destroying any existing configuration
! or data. It will only overwrite the libraries, classes, and scripts, and
! it will not re-package. It will also not do a complete initialization, so
! DynamicConstants.java won't be regenerated.
! -->
<target name="rebuild"
description="Rebuild the server without destroying config or data.">
<!-- Set the amount of memory to use for the build -->
<condition property="MEM" value="128M">
<not>
<isset property="MEM" />
</not>
</condition>
<!-- Set properties needed to find the packaged files -->
<property name="pkgversion"
value="${MAJOR_VERSION}.${MINOR_VERSION}${VERSION_QUALIFIER}" />
<property name="pdir"
location="${package.dir}/OpenDS-${pkgversion}" />
<!-- Clean up a minimal set of files/directories for the rebuild. -->
<delete dir="${classes.dir}" />
<delete file="${package.dir}/lib/OpenDS.jar" />
<delete file="${pdir}.zip" />
<delete dir="${quicksetup.classes.dir}" />
<delete file="${package.dir}/lib/quicksetup.jar" />
<delete file="${package.dir}/lib/statuspanel.jar" />
<!-- Regenerate configuration files if necessary -->
<antcall target="compileadmin" />
<!-- Recreate the classes directory and recompile into it. -->
<mkdir dir="${classes.dir}" />
deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}">
<compilerarg value="-Xlint:all" />
<classpath>
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</classpath>
</javac>
<!-- Generate the OpenDS.jar file -->
<jar jarfile="${pdir}/lib/OpenDS.jar"
<!-- Recreate the quicksetup classes directory and recompile into it. -->
<mkdir dir="${quicksetup.classes.dir}" />
target="1.5" deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}">
<include name="**/org/opends/server/util/SetupUtils.java"/>
<include name="**/org/opends/server/util/CertificateManager.java"/>
<include name="**/org/opends/server/util/DynamicConstants.java"/>
<include name="**/org/opends/server/types/OperatingSystem.java"/>
<compilerarg value="-Xlint:all" />
</javac>
deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}">
<compilerarg value="-Xlint:all" />
<classpath>
<fileset dir="${build.dir}/build-tools">
<include name="build-tools.jar" />
</fileset>
<fileset dir="${pdir}/lib">
<include name="OpenDS.jar" />
</fileset>
</classpath>
</javac>
<copy todir="${quicksetup.classes.dir}">
<fileset dir="${quicksetup.src.dir}"
includes="**/*.properties, **/*.gif, **/*.png"/>
</copy>
<!-- Generate the quicksetup.jar file -->
<jar jarfile="${pdir}/lib/quicksetup.jar"
<!-- Recreate the statuspanel classes directory and recompile into it. -->
<mkdir dir="${statuspanel.classes.dir}" />
deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}">
<compilerarg value="-Xlint:all" />
<classpath>
<fileset dir="${pdir}/lib">
<include name="OpenDS.jar" />
</fileset>
</classpath>
</javac>
<copy todir="${statuspanel.classes.dir}">
<fileset dir="${statuspanel.src.dir}"
includes="**/*.properties, **/*.gif, **/*.png"/>
</copy>
<!-- Generate the statuspanel.jar file -->
<jar jarfile="${pdir}/lib/statuspanel.jar"
<!-- Regenerate example plugin. -->
<antcall target="example-plugin" />
</target>
<!-- Populate the Directory Server package, but don't zip it up. -->
<target name="prepackage" depends="cleancompile"
description="Prepare the Directory Server package structure.">
<property name="pkgversion"
value="${MAJOR_VERSION}.${MINOR_VERSION}${VERSION_QUALIFIER}" />
<property name="pdir"
location="${package.dir}/OpenDS-${pkgversion}" />
<mkdir dir="${pdir}" />
<mkdir dir="${pdir}/bak" />
<mkdir dir="${pdir}/bat" />
<mkdir dir="${pdir}/bin" />
<mkdir dir="${pdir}/classes" />
<mkdir dir="${pdir}/config" />
<mkdir dir="${pdir}/db" />
<mkdir dir="${pdir}/changelogDb" />
<mkdir dir="${pdir}/ldif" />
<mkdir dir="${pdir}/legal-notices" />
<mkdir dir="${pdir}/lib" />
<mkdir dir="${pdir}/lib/extensions" />
<mkdir dir="${pdir}/locks" />
<mkdir dir="${pdir}/logs" />
<jar jarfile="${pdir}/lib/OpenDS.jar"
<jar jarfile="${pdir}/lib/quicksetup.jar"
<jar jarfile="${pdir}/lib/statuspanel.jar"
<copy todir="${pdir}/lib">
<fileset file="${lib.dir}/*.jar" />
</copy>
<copy todir="${pdir}/lib">
<fileset file="${lib.dir}/*.exe" />
</copy>
<antcall target="example-plugin" />
<fixcrlf srcDir="${scripts.dir}" destDir="${pdir}/bin" excludes="*.bat,_client-script.sh,_server-script.sh" eol="lf" />
<fixcrlf srcDir="${scripts.dir}" destDir="${pdir}/lib" includes="_client-script.sh,_server-script.sh" eol="lf" />
<fixcrlf srcDir="${scripts.dir}" destDir="${pdir}/bat" excludes="_client-script.bat,_server-script.bat,setcp.bat" includes="*.bat" eol="crlf" />
<fixcrlf srcDir="${scripts.dir}" destDir="${pdir}/lib" includes="_client-script.bat,_server-script.bat,setcp.bat" eol="crlf" />
<copy todir="${pdir}/config">
<fileset file="${config.dir}/*" />
</copy>
<copy file="${pdir}/config/config.ldif"
tofile="${pdir}/config/upgrade/config.ldif.${REVISION_NUMBER}" />
<taskdef name="concatschema"
classname="org.opends.build.tools.ConcatSchema">
<classpath>
<fileset dir="${build.dir}/build-tools">
<include name="*.jar" />
</fileset>
</classpath>
</taskdef>
<concatschema schemaDirectory="${resource.dir}/schema"
toFile="${pdir}/config/upgrade/schema.ldif.${REVISION_NUMBER}" />
<fileset dir="${resource.dir}/schema" />
</copy>
<fileset dir="${resource.dir}/messages" />
</copy>
<fileset dir="${resource.dir}/MakeLDIF" />
</copy>
<copy todir="${pdir}/legal-notices">
<fileset dir="${resource.dir}/legal-notices" />
</copy>
<copy todir="${pdir}">
<fileset file="${resource.dir}/README" />
</copy>
eol="lf" />
eol="crlf" />
<chmod file="${pdir}/setup" perm="755" />
<chmod file="${pdir}/uninstall" perm="755" />
<chmod perm="755">
<fileset dir="${pdir}/bin">
</fileset>
</chmod>
</target>
<!-- Package the Directory Server for distribution. -->
<target name="package" depends="prepackage"
description="Package the Directory Server for distribution.">
<zip destfile="${package.dir}/OpenDS-${pkgversion}.zip">
excludes="OpenDS-${pkgversion}/bin/*,OpenDS-${pkgversion}/lib/_client-script.sh,OpenDS-${pkgversion}/lib/_server-script.sh,OpenDS-${pkgversion}/setup,OpenDS-${pkgversion}/uninstall"
filemode="644" dirmode="755" />
<zipfileset dir="${package.dir}"
includes="OpenDS-${pkgversion}/lib/_client-script.sh,OpenDS-${pkgversion}/lib/_server-script.sh"
filemode="755" dirmode="755" />
excludes="OpenDS-${pkgversion}/bin/README_WINDOWS.txt"
filemode="755" dirmode="755" />
filemode="644" dirmode="755" />
<zipfileset dir="${package.dir}" includes="OpenDS-${pkgversion}/setup,OpenDS-${pkgversion}/uninstall"
filemode="755" dirmode="755" />
</zip>
</target>
<!-- Prepare the Directory Server DSML library. -->
<target name="predsml" depends="prepackage"
description="Prepare the Directory Server DSML library.">
<classpath>
<fileset dir="${dsml.lib.dir}">
<include name="**/*.jar" />
</fileset>
</classpath>
</taskdef>
<mkdir dir="${dsml.gen.dir}/org/opends/dsml/protocol" />
removeOldOutput="yes" package="org.opends.dsml.protocol">
<produces dir="${dsml.gen.dir}/org/opends/dsml/protocol"
includes="* impl/*" />
</xjc>
<mkdir dir="${dsml.classes.dir}" />
target="1.5" deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}">
<compilerarg value="-Xlint:all" />
<classpath>
<fileset dir="${dsml.lib.dir}">
<include name="*.jar" />
</fileset>
</classpath>
</javac>
target="1.5" deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}">
<compilerarg value="-Xlint:all" />
<classpath>
<fileset dir="${dsml.lib.dir}">
<include name="*.jar" />
</fileset>
<dirset dir="${classes.dir}" />
</classpath>
</javac>
<war destfile="${classes.dir}/OpenDS-${pkgversion}-DSML.war"
<fileset file="${dsml.dir}/webapp/server.properties" />
excludes="web.xml, **/*.jar, **/*.properties" />
<classes dir="${dsml.classes.dir}" />
<lib dir="${dsml.lib.dir}">
<exclude name="j2ee.jar" />
</lib>
<lib dir="${pdir}/lib">
<exclude name="activation.jar" />
<exclude name="je.jar" />
</lib>
</war>
<copy todir="${package.dir}">
<fileset file="${classes.dir}/*.war" />
</copy>
</target>
<!-- Generate JavaDoc documentation from the source files -->
<target name="javadoc" depends="dsml,compileadmin"
description="Generate JavaDoc documentation.">
<mkdir dir="${javadoc.dir}" />
linksource="yes" windowtitle="${PRODUCT_NAME} API Documentation"
maxmemory="${MEM}">
<classpath>
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${dsml.lib.dir}">
<include name="*.jar" />
</fileset>
<dirset dir="${classes.dir}" />
<dirset dir="${dsml.classes.dir}" />
</classpath>
<packageset dir="${src.dir}" />
<packageset dir="${admin.src.dir}" />
<packageset dir="${dsml.src.dir}" />
</javadoc>
</target>
<!-- Internal target to prepare to generate a code coverage report. -->
<target name="coverage">
<mkdir dir="${coverage.dir}" />
<mkdir dir="${coverage.data.dir}" />
<mkdir dir="${coverage.instr.dir}" />
<mkdir dir="${coverage.report.dir}" />
<path id="run.classpath">
<pathelement location="${classes.dir}" />
</path>
</target>
<!-- Prepare to execute the Directory Server TestNG unit tests. -->
<target name="testinit" depends="buildtools, weave"
description="Prepare to execute the Directory Server TestNG unit tests.">
<!-- If we are to perform coverage tests, then set that up. -->
<path id="emma.lib">
<pathelement location="${emma.dir}/emma_ant.jar" />
</path>
<emma enabled="${coverage.enabled}">
metadatafile="${coverage.data.dir}/metadata.emma" merge="true" />
</emma>
<!-- Compile the test cases -->
<mkdir dir="${unittest.classes.dir}" />
target="1.5" deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}">
<compilerarg value="-Xlint:all" />
<classpath>
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${testng.lib.dir}">
<include name="*.jar" />
</fileset>
<path refid="run.classpath" />
</classpath>
</javac>
<!-- Prep the TestNG XML file -->
<not>
<or>
<isset property="test.groups" />
<isset property="test.packages" />
<isset property="test.classes" />
<isset property="test.methods" />
</or>
</not>
</condition>
<not>
<or>
<isset property="test.packages" />
<isset property="test.classes" />
<isset property="test.methods" />
</or>
</not>
</condition>
<not>
<or>
<isset property="test.classes" />
<isset property="test.methods" />
</or>
</not>
</condition>
<not>
<or>
<isset property="test.methods" />
</or>
</not>
</condition>
<mkdir dir="${unittest.resource.dir}" />
classpath="${build.dir}/build-tools/build-tools.jar" />
<preptestng file="${testng.dir}/testng.xml"
tofile="${unittest.resource.dir}/testng.xml"
grouplist="${test.groups}"
packagelist="${test.packages}"
classList="${test.classes}"
methodList="${test.methods}" />
<antcall target="testinit.checkFailedTestsOnly"/>
</target>
<!-- If we were asked to run only the tests that failed,
then we overwrite the testng.xml that we just generated
with testng-failed.xml, which TestNG generated. -->
<!-- Ensure that some of the tests failed last time. -->
<available property="testng-failed.xml.exists"
file="${unittest.report.dir}/testng-failed.xml"/>
<fail message="No unit tests failed in the previous run."
unless="testng-failed.xml.exists"/>
<!-- We replace the 'Failed suite [OpenDS]' with 'OpenDS' so we
don't end up with 'Failed suite [Failed suite [OpenDS]]]' etc. -->
<replace file="${unittest.report.dir}/testng-failed.xml"
token="Failed suite [OpenDS]"
value="OpenDS"/>
<replace file="${unittest.report.dir}/testng-failed.xml"
token="default(failed)"
value="default"/>
<copy file="${unittest.report.dir}/testng-failed.xml"
tofile="${unittest.resource.dir}/testng.xml"
overwrite="true"/>
<echo message="Will run the failed unit tests only"/>
</target>
<!-- Generate coverage diff report -->
<target name="coveragediff">
<not>
<isset property="test.diff.srcpath" />
</not>
</condition>
<not>
<isset property="test.diff.disable" />
</not>
</condition>
<not>
<isset property="test.diff.verbose" />
</not>
</condition>
<isset property="test.diff.disable" />
</condition>
<mkdir dir="${cvgdiff.report.dir}" />
<classpath>
<fileset dir="${build.dir}/build-tools">
<include name="*.jar" />
</fileset>
<fileset dir="${emma.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${svnkit.dir}">
<include name="*.jar" />
</fileset>
</classpath>
</taskdef>
<coveragediff emmadatapath="${coverage.data.dir}"
outputpath="${cvgdiff.report.dir}"
diffpath="${test.diff.srcpath}"
enabled="${test.diff.enabled}"
verbose="${test.diff.verbose}" />
</target>
<!-- Execute the Directory Server TestNG unit tests in text mode. -->
<target name="enableTestNGAssertions">
<property name="TESTASSERT" value="true"/>
</target>
<!-- Execute Directory Server TestNG unit tests specified from CLI -->
<target name="testcustom">
<echo message="This target is deprecated. Please use the test target as it now supports the test.* properties." />
</target>
<!-- Execute all of the Directory Server TestNG unit tests in text mode. -->
<target name="testall"
depends="enableweave,enableTestNGAssertions,prepdefaultalltest,testinit,runtests"
description="Run all of the TestNG tests (including 'slow' ones) with assertions enabled. See 'testwithcoverage' for properties you can set.">
</target>
<!-- Execute the Directory Server TestNG unit tests in text mode. -->
<target name="test"
depends="enableweave,testinit,runtests"
description="Execute the Directory Server TestNG unit tests in text mode. Set '-Dorg.opends.test.suppressOutput=false' to see the output from the unit tests. Set '-Dtest.failures=true' to run only the tests that failed previously.">
</target>
<!-- Execute the Directory Server TestNG unit tests in text mode with a coverage report. -->
<target name="testwithcoverage"
depends="coverage,test,coveragediff"
description="Execute the Directory Server TestNG unit tests in text mode with a coverage report. Use -Dtest.packages, -Dtest.classes, or -Dtest.methods to control which unit tests are run. Use -Dtest.diff.srcpath to control which src files show up in the coverage diff. See the 'test' package for other properties you can set.">
</target>
<!-- Execute the Directory Server TestNG unit tests in text mode with a coverage report and slow tests. -->
<target name="testallwithcoverage"
depends="coverage,testall,coveragediff"
description="The same as 'testwithcoverage' except 'testall' is run instead of 'test'.">
</target>
<!-- Execute the Directory Server TestNG unit tests specified from CLI in text mode with a coverage report. -->
<target name="testcustomwithcoverage">
<echo message="This target is deprecated. Please use the testwithcoverage target as it now supports the test.* properties." />
</target>
<echo message="About to run the unit tests. Ant options to control the tests:"/>
<echo message=""/>
<echo message=" -Dorg.opends.test.suppressOutput=false"/>
<echo message=" writes the unit test output to the screen"/>
<echo message=""/>
<echo message=" -Dorg.opends.test.pauseOnFailure=true"/>
<echo message=" pauses the test suite whenever a failure occurs allowing you to inspect"/>
<echo message=" the server more closely in the failure state"/>
<echo message=""/>
<echo message=" -Dtest.failed=true"/>
<echo message=" runs only the tests that failed last time"/>
<echo message=""/>
<echo message=" -DWEAVE_ENABLED=false" />
<echo message=" builds the server without the debug logging facility." />
<echo message=" No debug logging messages will be included on test failures." />
<echo message=""/>
<echo message=" -Dorg.opends.test.debug.target=org.opends.server.core:level=verbose,category=data_access"/>
<echo message=" for example only include debug messages in the core"/>
<echo message=" package that are related to data access and at the" />
<echo message=" verbose level or higher. The syntax of this target" />
<echo message=" definition is the same as the org.opends.server.debug.target.x" />
<echo message=" property when starting OpenDS. " />
<echo message=" Default debug target:"/>
<echo message=" org.opends.server:level=verbose,category=caught|data|database_access|message|protocol" />
<echo message=""/>
<echo message=" -Dtest.packages=org.opends.server.api"/>
<echo message=" for example runs only the tests in the api package"/>
<echo message=" For multiple packages, separate them with a ',' and "/>
<echo message=" quote the entire value. Debug logging is disabled."/>
<echo message=""/>
<echo message=" for example only runs the TestDN class"/>
<echo message=" For multiple classes, separate them with a ',' and "/>
<echo message=" quote the entire value. Debug logging is disabled."/>
<echo message=""/>
<echo message=" -Dtest.methods=org.opends.server.types.TestDN.testGetRDN"/>
<echo message=" for example only runs the testGetRDN method"/>
<echo message=" For multiple methods, separate them with a ',' and "/>
<echo message=" quote the entire value. Debug logging is disabled."/>
<echo message=""/>
<echo message=" for example includes only the classes in"/>
<echo message=" To list multiple directories or files, separate them with"/>
<echo message=" a space as you would an argument list to 'svn diff' and quote"/>
<echo message=" the whole value."/>
<echo message=""/>
</target>
<!-- Internal target to execute the Directory Server TestNG unit tests in text mode after everything has been initialized. -->
<target name="runtests">
<antcall target="testhelp"/>
<mkdir dir="${unittest.report.dir}" />
<taskdef resource="testngtasks">
<classpath>
<fileset dir="${testng.lib.dir}">
<include name="*.jar" />
</fileset>
</classpath>
</taskdef>
<!-- This sets TESTASSERT to false if and only if it's not already set. -->
<condition property="TESTASSERT" value="false">
<not>
<isset property="TESTASSERT" />
</not>
</condition>
<!-- This sets org.opends.test.suppressOutput if and only if it's not
already set. -->
<not>
<isset property="org.opends.test.suppressOutput" />
</not>
</condition>
<!-- This sets org.opends.test.pauseOnFailure if and only if it's not
already set. -->
<not>
<isset property="org.opends.test.pauseOnFailure" />
</not>
</condition>
<!-- This sets org.opends.test.debug.target if and only if its's not
alreadly set. -->
<condition property="org.opends.test.debug.target"
value="org.opends.server:level=info,category=caught|data|database_access|message|protocol">
<not>
<isset property="org.opends.test.debug.target" />
</not>
</condition>
<!-- Cleanout the old reports. Otherwise, the old testng-failed.xml
will hang around even if all of the tests pass. -->
<delete>
</delete>
<!-- Our testng listener will remove this file if all of the
tests passed. This allows us to generate the coverage
report even if the tests failed and still fail the build. -->
<touch file="${unittest.report.dir}/.tests-failed-marker"/>
<testng outputdir="${unittest.report.dir}"
haltonfailure="false"
enableAssert="${TESTASSERT}"
listeners="org.opends.server.TestListener org.testng.reporters.FailedReporter"
useDefaultListeners="false"
suiteRunnerClass="org.opends.server.SuiteRunner">
<classpath>
<pathelement location="${coverage.instr.dir}" />
<pathelement location="${classes.dir}" />
<pathelement location="${unittest.classes.dir}" />
<path refid="run.classpath" />
<path refid="emma.lib" />
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${testng.lib.dir}">
<include name="*.jar" />
</fileset>
</classpath>
<jvmarg value="-Demma.coverage.out.file=${coverage.data.dir}/unit.emma" />
<jvmarg value="-Demma.coverage.out.merge=false" />
<jvmarg value="-Dorg.opends.server.BuildRoot=${basedir}" />
<jvmarg value="-Dorg.opends.server.RunningUnitTests=true" />
<jvmarg value="-Dorg.opends.test.suppressOutput=${org.opends.test.suppressOutput}" />
<jvmarg value="-Dorg.opends.test.pauseOnFailure=${org.opends.test.pauseOnFailure}" />
<jvmarg value="-Dorg.opends.test.debug.target=${org.opends.test.debug.target}" />
<jvmarg value="-Xms${MEM}" />
<jvmarg value="-Xmx${MEM}" />
</testng>
<!-- Our testng listener will create this file if any of the
tests failed. This allows us to generate the coverage
report even if the tests failed. -->
<available property="testng.tests.failed"
file="${unittest.report.dir}/.tests-failed-marker"/>
<!-- Delete all of the report suite sub-directories since we only
have a single suite. -->
<delete dir="${unittest.report.dir}/OpenDS"/>
<emma enabled="${coverage.enabled}" >
<report sourcepath="${src.dir}" >
<fileset dir="${coverage.data.dir}" >
<include name="unit.emma" />
<include name="metadata.emma" />
</fileset>
<txt outfile="${coverage.report.dir}/coverage.txt" />
<html outfile="${coverage.report.dir}/index.html" />
<xml outfile="${coverage.report.dir}/coverage.xml" />
</report>
</emma>
<!-- We delay failing until after the coverage report is generated. -->
</target>
<target name="prepdefaultalltest">
<not>
<or>
<isset property="test.groups" />
<isset property="test.packages" />
<isset property="test.classes" />
<isset property="test.methods" />
</or>
</not>
</condition>
</target>
<target name="enableweave">
<condition property="WEAVE_ENABLED" value="true">
<not>
<or>
<isset property="WEAVE_ENABLED" />
<isset property="test.groups" />
<isset property="test.packages" />
<isset property="test.classes" />
<isset property="test.methods" />
</or>
</not>
</condition>
</target>
<target name="testreport"
depends="test"
description="Takes testng results and convert them into JUnit compatible xml">
<junitreport todir="${unittest.report.dir}">
<fileset dir="${unittest.report.dir}">
<include name="*.xml"/>
</fileset>
</junitreport>
</target>
<target name="integration-tests"
description="Builds the integration tests">
</target>
<target name="buildtools" depends="init"
description="Builds the build tools">
<!-- Set the amount of memory to use for the build -->
<condition property="MEM" value="128M">
<not>
<isset property="MEM" />
</not>
</condition>
<mkdir dir="${buildtools.classes.dir}" />
target="1.5" deprecation="true" fork="true" memoryInitialSize="${MEM}"
memoryMaximumSize="${MEM}">
<compilerarg value="-Xlint:all" />
<classpath>
<fileset dir="${ant.lib.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${emma.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${svnkit.dir}">
<include name="*.jar" />
</fileset>
<path refid="run.classpath" />
</classpath>
</javac>
<jar jarfile="${build.dir}/build-tools/build-tools.jar"
</target>
<!-- Code generation for core administration components. -->
<target name="compileadmin" depends="validateadmin" description="Code generation for configuration Object.">
<!-- The XSLT task creates a lot of noise.
I can't find any other way to shut it up. -->
<os family="windows" />
</condition>
<condition property="antcmd" value="ant">
<not>
<isset property="antcmd" />
</not>
</condition>
<exec executable="${ant.home}/bin/${antcmd}">
<arg value="-buildfile" />
<arg value="${ant.file}" />
<arg value="-quiet" />
<arg value="compileadminsubtask" />
</exec>
</target>
<target name="compileadminsubtask">
<!-- Generate introspection API for core administration components. -->
<xslt basedir="${admin.defn.dir}" destdir="${admin.src.dir}" includes="**/*Configuration.xml" style="${admin.rules.dir}/metaMO.xsl">
<regexpmapper handledirsep="true" from="^(.*)/([^/]+)Configuration\.xml$$" to="\1/meta/\2CfgDefn.java" />
</xslt>
<xslt basedir="${admin.defn.dir}" destdir="${admin.src.dir}" includes="**/Package.xml" style="${admin.rules.dir}/package-info.xsl">
<param name="type" expression="meta" />
</xslt>
<!-- Generate client API for core administration components. -->
<xslt basedir="${admin.defn.dir}" destdir="${admin.src.dir}" includes="**/*Configuration.xml" style="${admin.rules.dir}/clientMO.xsl">
<regexpmapper handledirsep="true" from="^(.*)/([^/]+)Configuration\.xml$$" to="\1/client/\2CfgClient.java" />
</xslt>
<xslt basedir="${admin.defn.dir}" destdir="${admin.src.dir}" includes="**/Package.xml" style="${admin.rules.dir}/package-info.xsl">
<param name="type" expression="client" />
</xslt>
<!-- Generate server API for core administration components. -->
<xslt basedir="${admin.defn.dir}" destdir="${admin.src.dir}" includes="**/*Configuration.xml" style="${admin.rules.dir}/serverMO.xsl">
<regexpmapper handledirsep="true" from="^(.*)/([^/]+)Configuration\.xml$$" to="\1/server/\2Cfg.java" />
</xslt>
<xslt basedir="${admin.defn.dir}" destdir="${admin.src.dir}" includes="**/Package.xml" style="${admin.rules.dir}/package-info.xsl">
<param name="type" expression="server" />
</xslt>
<!-- Generate LDAP profile for core administration components. -->
<mkdir dir="${classes.dir}" />
<xslt basedir="${admin.defn.dir}" destdir="${classes.dir}/admin/profiles/ldap" includes="**/*Configuration.xml" style="${admin.rules.dir}/ldapMOProfile.xsl">
<regexpmapper handledirsep="true" from="^(.*)/([^/]+)Configuration\.xml$$" to="\1/meta/\2CfgDefn.properties" />
</xslt>
<!-- Generate I18N messages for core administration components. -->
<xslt basedir="${admin.defn.dir}" destdir="${classes.dir}/admin/messages" includes="**/*Configuration.xml" style="${admin.rules.dir}/messagesMO.xsl">
<regexpmapper handledirsep="true" from="^(.*)/([^/]+)Configuration\.xml$$" to="\1/meta/\2CfgDefn.properties" />
</xslt>
<!-- Generate manifest file for core administration components. -->
<mkdir dir="${admin.temp.dir}" />
<xslt basedir="${admin.defn.dir}" destdir="${admin.temp.dir}" extension=".manifest" includes="**/*Configuration.xml" style="${admin.rules.dir}/manifestMO.xsl"/>
<concat destfile="${classes.dir}/admin/core.manifest">
</concat>
<delete dir="${admin.temp.dir}" />
</target>
<!-- Remove all dynamically-generated build files. -->
<target name="cleanadmin" description="Clean up any generated source files for admin">
<delete includeemptydirs="true">
</delete>
</target>
<!-- Validate core administration component XML definition files. -->
<target name="validateadmin" description="Validate core administration component XML definition files.">
<schemavalidate>
</schemavalidate>
</target>
<!-- Generate example plugin package. -->
<target name="example-plugin" if="pdir">
<!-- Create folder hierarchy in temporary directory. -->
<mkdir dir="${plugin.temp.dir}/example-plugin" />
<mkdir dir="${plugin.temp.dir}/example-plugin/src" />
<mkdir dir="${plugin.temp.dir}/example-plugin/src-generated" />
<mkdir dir="${plugin.temp.dir}/example-plugin/lib" />
<mkdir dir="${plugin.temp.dir}/example-plugin/ext" />
<mkdir dir="${plugin.temp.dir}/example-plugin/resource" />
<mkdir dir="${plugin.temp.dir}/example-plugin/resource/admin" />
<mkdir dir="${plugin.temp.dir}/example-plugin/resource/config" />
<mkdir dir="${plugin.temp.dir}/example-plugin/resource/schema" />
<copy todir="${plugin.temp.dir}/example-plugin/src">
</copy>
<copy todir="${plugin.temp.dir}/example-plugin/resource/admin">
</copy>
<copy todir="${plugin.temp.dir}/example-plugin" file="${admin.rules.dir}/example-plugin/build.xml" />
<copy todir="${plugin.temp.dir}/example-plugin/resource/schema" file="${admin.rules.dir}/example-plugin/99-example-plugin.ldif" />
<copy todir="${plugin.temp.dir}/example-plugin/resource/config" file="${admin.rules.dir}/example-plugin/example-plugin.ldif" />
<copy todir="${plugin.temp.dir}/example-plugin/src/com/example/opends">
</copy>
<!-- Package up the plugin in the OpenDS package folder. -->
<zip destfile="${pdir}/example-plugin.zip">
</zip>
<delete dir="${plugin.temp.dir}" />
</target>
</project>