<!--
! 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 legal-notices/CDDLv1_0.txt
! 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 legal-notices/CDDLv1_0.txt.
! 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
!
!
! Copyright 2008-2010 Sun Microsystems, Inc.
! -->
<project name="Directory Server Extension" basedir="." default="package">
<description>
This is the build script for an OpenDS Directory Server extension.
</description>
<!-- Import extra tasks from ant-contrib (for, if-then-else, ...) -->
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<!-- CONFIGURE: The name of the extension's Jar file. -->
<!-- CONFIGURE: The description of this extension - used in the Javadoc title. -->
<!-- CONFIGURE: The path of the OpenDS installation. -->
<!-- CONFIGURE: The path of Xalan-Java distribution. -->
<!-- General properties - should not need changing. -->
<!-- alias variable as needed by the ant task that generates messages -->
<!-- Location of OpenDS components - should not need changing. -->
<!-- Display help information. -->
<target name="help">
<echo message="Ant options to control the build:" />
<echo message="" />
<echo message=" -Dopends.install.dir=path" />
<echo message=" The path of the OpenDS installation [default: ${opends.install.dir}]." />
<echo message="" />
<echo message=" -Dpkg.name=name" />
<echo message=" The name of the extension's Jar file [default: ${pkg.name}]." />
<echo message="" />
<echo message=" -Dpkg.description=description" />
<echo message=" The description of this extension - used in the Javadoc title [default: ${pkg.description}]." />
<echo message="" />
<echo message=" -Dxalan.directory=path" />
<echo message=" The path of a Xalan-Java distribution [default: ${xalan.directory}]." />
<echo message="" />
</target>
<!-- Clean up any files generated during the build process. -->
<target name="clean" description="Clean up any files generated during the build process.">
<delete dir="${build.dir}" />
<delete includeemptydirs="true">
</delete>
</target>
<!-- Compile the Directory Server extension source files. -->
<target name="compile" depends="init,compileadmin,generate-messages" description="Compile the Directory Server extension source files.">
<mkdir dir="${classes.dir}" />
<javac srcdir="${src.dir}:${src.gen.dir}" destdir="${classes.dir}" optimize="true" excludes="**/package-info.java" debug="on" debuglevel="lines,source" source="1.6" target="1.6" deprecation="true" fork="true" memoryInitialSize="${MEM}" memoryMaximumSize="${MEM}">
<compilerarg value="-Xlint:all" />
<classpath>
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${opends.lib.dir}">
<include name="*.jar" />
</fileset>
</classpath>
</javac>
</target>
<!-- Generate JavaDoc documentation from the source files. -->
<target name="javadoc" depends="init,compile" description="Generate JavaDoc documentation.">
<mkdir dir="${javadoc.dir}" />
<javadoc destdir="${javadoc.dir}" source="1.6" additionalparam="-quiet" linksource="yes" windowtitle="${pkg.description} API Documentation" maxmemory="${MEM}">
<classpath>
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${opends.lib.dir}">
<include name="*.jar" />
</fileset>
<dirset dir="${classes.dir}" />
</classpath>
<packageset dir="${src.dir}" />
<packageset dir="${src.gen.dir}" />
</javadoc>
</target>
<!-- Package the Directory Server extension for distribution. -->
<target name="package" depends="clean,compile" description="Package the Directory Server extension for distribution.">
<mkdir dir="${package.dir}" />
</target>
<!-- Install the Directory Server extension in an existing OpenDS installation. -->
<target name="install" depends="package" description="Install the Directory Server extension in an existing OpenDS installation.">
<mkdir dir="${opends.lib.dir}" />
<copy todir="${opends.lib.dir}">
<fileset file="${lib.dir}/*.jar" />
</copy>
<mkdir dir="${opends.extensions.dir}" />
<copy todir="${opends.extensions.dir}">
<fileset file="${package.dir}/*.jar" />
</copy>
<copy todir="${opends.config.dir}">
<fileset file="${config.dir}/*.ldif" />
</copy>
<copy todir="${opends.schema.dir}">
<fileset file="${schema.dir}/*.ldif" />
</copy>
</target>
<!-- Perform common initialization common to several targets. -->
<target name="init">
<tstamp>
<format property="timestamp" pattern="yyyyMMddHHmmss" />
</tstamp>
<condition property="DEBUG_BUILD" value="false">
<not>
<isset property="DEBUG_BUILD" />
</not>
</condition>
<condition property="MEM" value="128M">
<not>
<isset property="MEM" />
</not>
</condition>
</target>
<!-- Perform verification for Xalan dependency -->
<target name="ensurexalan" description="Verify that the Xalan-Java jar files are accessibles.">
<if>
<not>
</not>
<then>
<echo message="Please use -Dxalan.directory to point to a directory " />
<echo message="that contains an unzipped delivery of Xalan-Java." />
<echo message="You can download Xalan-Java from the Apache website :" />
<echo message=" http://xml.apache.org/xalan-j/" />
<echo message="" />
<fail />
</then>
</if>
<!-- Xalan-J Class Path : refer to it explicitly from each XSLT task. -->
<path id="xalan.class.path">
<fileset dir="${xalan.directory}">
<include name="*.jar" />
</fileset>
</path>
<!-- Verify that all required Xalan jars are present -->
<fail message="Missing at least one Xalan-Java jar files in directory ${xalan.directory} (expecting : ${xalan.jar.files}).">
<condition>
<not>
<resourcecount count="4">
</resourcecount>
</not>
</condition>
</fail>
</target>
<!-- Compile the Directory Server extension configuration definition files. -->
<target name="compileadmin" depends="ensurexalan,validateadmin" description="Compile the Directory Server extension configuration definition files.">
<echo message="classpath = ${xalan.class.path}" />
<!-- Compile the Directory Server extension configuration meta classes. -->
<include name="**/*Configuration.xml" />
<regexpmapper handledirsep="true" from="^(.*)/([^/]+)Configuration\.xml$$" to="\1/meta/\2CfgDefn.java" />
<classpath refid="xalan.class.path" />
</xslt>
<include name="**/Package.xml" />
<param name="type" expression="meta" />
<classpath refid="xalan.class.path" />
</xslt>
<!-- Compile the Directory Server extension configuration client classes. -->
<include name="**/*Configuration.xml" />
<regexpmapper handledirsep="true" from="^(.*)/([^/]+)Configuration\.xml$$" to="\1/client/\2CfgClient.java" />
<classpath refid="xalan.class.path" />
</xslt>
<include name="**/Package.xml" />
<param name="type" expression="client" />
<classpath refid="xalan.class.path" />
</xslt>
<!-- Compile the Directory Server extension configuration server classes. -->
<include name="**/*Configuration.xml" />
<regexpmapper handledirsep="true" from="^(.*)/([^/]+)Configuration\.xml$$" to="\1/server/\2Cfg.java" />
<classpath refid="xalan.class.path" />
</xslt>
<include name="**/Package.xml" />
<param name="type" expression="server" />
<classpath refid="xalan.class.path" />
</xslt>
<!-- Compile the Directory Server extension configuration ldap profile property files. -->
<xslt basedir="${src.dir}" destdir="${classes.dir}/admin/profiles/ldap" style="${admin.dir}/ldapMOProfile.xsl">
<include name="**/*Configuration.xml" />
<regexpmapper handledirsep="true" from="^(.*)/([^/]+)Configuration\.xml$$" to="\1/meta/\2CfgDefn.properties" />
<classpath refid="xalan.class.path" />
</xslt>
<!-- Compile the Directory Server extension configuration cli profile property files. -->
<xslt basedir="${src.dir}" destdir="${classes.dir}/admin/profiles/cli" style="${admin.dir}/cliMOProfile.xsl">
<include name="**/*Configuration.xml" />
<regexpmapper handledirsep="true" from="^(.*)/([^/]+)Configuration\.xml$$" to="\1/meta/\2CfgDefn.properties" />
<classpath refid="xalan.class.path" />
</xslt>
<!-- Compile the Directory Server extension configuration I18N message files. -->
<xslt basedir="${src.dir}" destdir="${classes.dir}/admin/messages" style="${admin.dir}/messagesMO.xsl">
<include name="**/*Configuration.xml" />
<regexpmapper handledirsep="true" from="^(.*)/([^/]+)Configuration\.xml$$" to="\1/meta/\2CfgDefn.properties" />
<classpath refid="xalan.class.path" />
</xslt>
<!-- Compile the Directory Server extension configuration manifest file. -->
<mkdir dir="${admin.temp.dir}" />
<xslt basedir="${src.dir}" destdir="${admin.temp.dir}" extension=".manifest" style="${admin.dir}/manifestMO.xsl">
<include name="**/*Configuration.xml" />
<classpath refid="xalan.class.path" />
</xslt>
<concat destfile="${classes.dir}/admin/extension.manifest">
</concat>
<delete dir="${admin.temp.dir}" />
</target>
<!-- Validate the Directory Server extension configuration definitions. -->
<target name="validateadmin" description="Validate the Directory Server extension configuration definitions.">
<schemavalidate>
</schemavalidate>
</target>
<!-- Generate messages from all .properties files located in the message directory and declared in a package-->
<target name="generate-messages" description="Generate messages for extension.">
<if>
<then>
<!-- list of files properties -->
<path id="messages.properties">
<!-- Note: a package is required and properties file at the root of the
! message directory will be ignored
! -->
</path>
<!-- includes lib/*.jar into classpath (actually build-tools.jar) -->
<path id="msg.classpath">
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<typedef name="genmsg"
classname="org.opends.build.tools.GenerateMessageFile"
classpathref="msg.classpath">
</typedef>
<!-- set property if the list is not empty -->
<if>
<then>
<!-- Generate the message catalogs for all messages located
! in the messages directory
! -->
<mkdir dir="${classes.dir}/messages" />
<sequential>
<genmsg sourceProps="@{file}" />
</sequential>
</for>
</then>
<else>
<echo message="No messages found: ${message.dir} is empty" />
</else>
</if>
</then>
<else>
<echo message="No messages found: ${msg.dir} is missing" />
</else>
</if>
</target>
</project>