5053N/A<!--
5053N/A ! CDDL HEADER START
5053N/A !
5053N/A ! The contents of this file are subject to the terms of the
5053N/A ! Common Development and Distribution License, Version 1.0 only
5053N/A ! (the "License"). You may not use this file except in compliance
5053N/A ! with the License.
5053N/A !
6983N/A ! You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
6983N/A ! or http://forgerock.org/license/CDDLv1.0.html.
5053N/A ! See the License for the specific language governing permissions
5053N/A ! and limitations under the License.
5053N/A !
5053N/A ! When distributing Covered Code, include this CDDL HEADER in each
6983N/A ! file and include the License file at legal-notices/CDDLv1_0.txt.
6983N/A ! If applicable, add the following below this CDDL HEADER, with the
6983N/A ! fields enclosed by brackets "[]" replaced with your own identifying
6983N/A ! information:
5053N/A ! Portions Copyright [yyyy] [name of copyright owner]
5053N/A !
5053N/A ! CDDL HEADER END
5053N/A !
5053N/A !
5053N/A ! Copyright 2010 Sun Microsystems, Inc.
5938N/A ! Portions Copyright 2010-2012 ForgeRock AS.
5053N/A ! -->
5053N/A
5053N/A<project name="extension" basedir="." default="package">
5232N/A <description>
5053N/A This Ant build file contains common targets for extensions. It
5053N/A should not be invoked directly.
5232N/A </description>
5053N/A
5053N/A <!-- OpenDS base directory -->
5232N/A <dirname property="extension.basedir" file="${ant.file.extension}" />
5232N/A <property name="base.dir" location="${extension.basedir}/.." />
5938N/A
5271N/A <property file="${base.dir}/PRODUCT" />
5271N/A
5271N/A <!-- Construct the version number string -->
5271N/A <taskdef name="getversionnumber"
5271N/A classname="org.opends.build.tools.CreateVersionString">
5271N/A <classpath>
5271N/A <fileset dir="${base.dir}/build/build-tools">
5271N/A <include name="*.jar" />
5271N/A </fileset>
5271N/A </classpath>
5271N/A </taskdef>
5271N/A
5271N/A <getversionnumber property="VERSION_NUMBER_STRING" />
5271N/A
5232N/A <property name="opends.install.dir"
5271N/A location="${base.dir}/build/package/${SHORT_NAME}-${VERSION_NUMBER_STRING}" />
5053N/A
5053N/A <!-- Source paths relative to extension -->
5232N/A <property name="src.dir" location="src" />
5232N/A <property name="src.gen.dir" location="src-generated" />
5232N/A <property name="lib.dir" location="lib" />
5232N/A <property name="config.dir" location="config" />
5232N/A <property name="schema.dir" location="schema" />
5232N/A
5232N/A <!-- CONFIGURE: The path of Xalan-Java distribution. -->
5232N/A <property name="xalan.directory" location="${base.dir}/ext/xalan-j" />
5053N/A
5053N/A <!-- Build paths relative to extension -->
5232N/A <property name="build.dir" location="build" />
5232N/A <property name="classes.dir" location="${build.dir}/classes" />
5232N/A <property name="javadoc.dir" location="${build.dir}/javadoc" />
5232N/A <property name="package.dir" location="${build.dir}/package" />
5232N/A <property name="message.dir" location="${build.dir}/message" />
5053N/A
5053N/A <!-- Files based on extension name -->
5232N/A <property name="jar.file" value="${extension.name}.jar" />
5232N/A <property name="properties.file" value="${extension.name}.properties" />
5053N/A
5053N/A <!-- Paths relative to OpenDS source tree -->
5232N/A <property name="resource.dir" location="${base.dir}/resource" />
5232N/A <property name="admin.dir" location="${resource.dir}/admin" />
5053N/A
5053N/A <!-- Build class path -->
5232N/A <path id="build.classpath">
5232N/A <fileset dir="${lib.dir}">
5232N/A <include name="*.jar" />
5232N/A </fileset>
5232N/A <pathelement path="${base.dir}/build/classes" />
5232N/A </path>
5053N/A
5053N/A <!-- Condition variable used for deciding if messages need generating -->
5232N/A <available property="hasmessages" file="${properties.file}" type="file">
5232N/A <filepath>
5232N/A <dirset dir="${src.dir}" />
5232N/A </filepath>
5232N/A </available>
5053N/A
5053N/A <!-- Clean up any files generated during the build process. -->
5232N/A <target name="clean"
5053N/A description="Clean up any files generated during the build process.">
5232N/A <delete includeemptydirs="true">
5232N/A <fileset dir="${src.gen.dir}" includes="**/*" />
5232N/A </delete>
5232N/A <delete includeemptydirs="true">
5232N/A <fileset dir="${build.dir}" includes="**/*" />
5232N/A </delete>
5232N/A </target>
5232N/A
5232N/A <!-- Perform verification for Xalan dependency -->
5232N/A <target name="ensurexalan" description="Verify that the Xalan-Java jar files are accessibles.">
5232N/A <fail message="Please use -Dxalan.directory to reference the directory that contains Xalan-Java">
5232N/A <condition>
5232N/A <not>
5232N/A <available property="xalan.directory.exists" file="${xalan.directory}" />
5232N/A </not>
5232N/A <!-- >
5232N/A <then>
5232N/A <echo message="Please use -Dxalan.directory to point to a directory " />
5232N/A <echo message="that contains an unzipped delivery of Xalan-Java." />
5232N/A <echo message="You can download Xalan-Java from the Apache website :" />
5232N/A <echo message=" http://xml.apache.org/xalan-j/" />
5232N/A <echo message="" />
5232N/A < -->
5232N/A </condition>
5232N/A </fail>
5232N/A
5232N/A <!-- Xalan-J Class Path : refer to it explicitly from each XSLT task. -->
5232N/A <path id="xalan.class.path">
5232N/A <fileset dir="${xalan.directory}">
5232N/A <include name="*.jar" />
5232N/A </fileset>
5232N/A </path>
5232N/A
5232N/A <!-- Verify that all required Xalan jars are present -->
5232N/A <property name="xalan.jar.files" value="serializer.jar,xalan.jar,xercesImpl.jar,xml-apis.jar" />
5232N/A <fail message="Missing at least one Xalan-Java jar files in directory ${xalan.directory} (expecting : ${xalan.jar.files}).">
5232N/A <condition>
5232N/A <not>
5232N/A <resourcecount count="4">
5232N/A <fileset dir="${xalan.directory}" includes="${xalan.jar.files}" />
5232N/A </resourcecount>
5232N/A </not>
5232N/A </condition>
5232N/A </fail>
5232N/A
5232N/A </target>
5053N/A
5053N/A <!-- Compile the Directory Server extension source files. -->
5232N/A <target name="compile"
5053N/A depends="init,compileadmin,generate-messages"
5053N/A description="Compile the Directory Server extension source files.">
5232N/A <mkdir dir="${classes.dir}" />
5271N/A <javac srcdir="${src.gen.dir}:${src.dir}"
5053N/A destdir="${classes.dir}"
5053N/A optimize="true"
5053N/A excludes="**/package-info.java"
5053N/A debug="on"
5053N/A debuglevel="lines,source"
5271N/A source="1.6"
5271N/A target="1.6"
5053N/A deprecation="true"
5053N/A fork="true"
5053N/A memoryInitialSize="${MEM}"
5053N/A memoryMaximumSize="${MEM}">
5232N/A <compilerarg value="-Xlint:all" />
5232N/A <classpath refid="build.classpath" />
5232N/A </javac>
5232N/A </target>
5053N/A
5053N/A <!-- Generate JavaDoc documentation from the source files. -->
5232N/A <target name="javadoc"
5053N/A depends="init,compile"
5053N/A description="Generate JavaDoc documentation.">
5232N/A <mkdir dir="${javadoc.dir}" />
5232N/A <javadoc destdir="${javadoc.dir}"
5271N/A source="1.6"
5053N/A additionalparam="-quiet"
5053N/A linksource="yes"
5053N/A windowtitle="${extension.description} API Documentation"
5053N/A maxmemory="${MEM}">
5232N/A <classpath refid="build.classpath" />
5232N/A <packageset dir="${src.dir}" />
5232N/A <packageset dir="${src.gen.dir}" />
5232N/A </javadoc>
5232N/A </target>
5053N/A
5053N/A <!-- Package the Directory Server extension for distribution. -->
5232N/A <target name="package"
5053N/A depends="clean,compile"
5053N/A description="Package the Directory Server extension for distribution.">
5232N/A <mkdir dir="${package.dir}" />
5232N/A <jar jarfile="${package.dir}/${jar.file}"
5053N/A basedir="${classes.dir}"
5053N/A compress="true"
5053N/A index="true" />
5232N/A </target>
5053N/A
5053N/A <!-- Install the Directory Server extension in an existing OpenDS installation. -->
5232N/A <target name="install"
5053N/A depends="package"
5053N/A description="Install the Directory Server extension in an existing OpenDS installation.">
5053N/A
5232N/A <echo message="Use the following Ant option to change the install location:" />
5232N/A <echo message="" />
5232N/A <echo message=" -Dopends.install.dir=path" />
5232N/A <echo message=" The path of an OpenDS installation where the extension will be installed." />
5232N/A <echo message=" Used by the install target [default: ${opends.install.dir}]." />
5232N/A <echo message="" />
5053N/A
5232N/A <mkdir dir="${opends.install.dir}/lib" />
5232N/A <copy todir="${opends.install.dir}/lib">
5232N/A <fileset file="${lib.dir}/*.jar" />
5232N/A </copy>
5232N/A <mkdir dir="${opends.install.dir}/lib/extensions" />
5232N/A <copy todir="${opends.install.dir}/lib/extensions">
5232N/A <fileset file="${package.dir}/*.jar" />
5232N/A </copy>
5232N/A <copy todir="${opends.install.dir}/config">
5232N/A <fileset file="${config.dir}/*.ldif" />
5232N/A </copy>
5232N/A <copy todir="${opends.install.dir}/config/schema">
5232N/A <fileset file="${schema.dir}/*.ldif" />
5232N/A </copy>
5232N/A </target>
5053N/A
5053N/A <!-- Perform common initialization common to several targets. -->
5232N/A <target name="init">
5232N/A <tstamp>
5232N/A <format property="timestamp" pattern="yyyyMMddHHmmss" />
5232N/A </tstamp>
5232N/A <condition property="DEBUG_BUILD" value="false">
5232N/A <not>
5232N/A <isset property="DEBUG_BUILD" />
5232N/A </not>
5232N/A </condition>
5232N/A <condition property="MEM" value="128M">
5232N/A <not>
5232N/A <isset property="MEM" />
5232N/A </not>
5232N/A </condition>
5232N/A </target>
5053N/A
5938N/A <!-- Compile the Directory Server extension configuration definition files. -->
5938N/A <target name="compileadmin" depends="init,ensurexalan,validateadmin">
5938N/A <!-- The XSLT task creates a lot of noise.
5938N/A I can't find any other way to shut it up. -->
5938N/A
5938N/A <condition property="antcmd" value="ant.bat">
5938N/A <os family="windows" />
5938N/A </condition>
5938N/A
5938N/A <condition property="antcmd" value="ant">
5938N/A <not>
5938N/A <isset property="antcmd" />
5938N/A </not>
5938N/A </condition>
5053N/A
5938N/A <exec executable="${ant.home}/bin/${antcmd}" failonerror="true">
5938N/A <arg value="-buildfile" />
5938N/A <arg value="${ant.file}" />
5938N/A <arg value="-Dbuild.dir=${build.dir}" />
5938N/A <arg value="-quiet" />
5938N/A <arg value="compileadminsubtask" />
5938N/A <env key="ANT_OPTS" value="-Xmx${MEM}" />
5938N/A <!-- Set classpath to workaround Apple JDK Xalan conflict -->
5938N/A <env key="CLASSPATH" value="${xalan.directory}/xalan.jar" />
5938N/A </exec>
5938N/A </target>
5938N/A
5938N/A <target name="compileadminsubtask">
5938N/A <!-- Xalan-J Class Path : refer to it explicitly from each XSLT task. -->
5938N/A <path id="xalan.class.path">
5938N/A <fileset dir="${xalan.directory}">
5938N/A <include name="*.jar" />
5938N/A </fileset>
5938N/A </path>
5938N/A
5232N/A <!-- Copy XML definitions for this extension and core server into the same location -->
5232N/A <tempfile property="admin.temp.dir" destDir="${classes.dir}" />
5232N/A <mkdir dir="${admin.temp.dir}" />
5232N/A
5232N/A <copy todir="${admin.temp.dir}">
5232N/A <fileset dir="${src.dir}" includes="**/*.xml" />
5232N/A <fileset dir="${base.dir}/src/admin/defn" includes="**/*.xml" />
5232N/A </copy>
5053N/A
5053N/A <!-- Compile the Directory Server extension configuration meta classes. -->
5232N/A <xslt basedir="${admin.temp.dir}"
5053N/A destdir="${src.gen.dir}"
5053N/A style="${admin.dir}/metaMO.xsl">
5232N/A <include name="**/*Configuration.xml" />
5232N/A <exclude name="org/opends/server/admin/std/*.xml" />
5232N/A <regexpmapper handledirsep="true"
5053N/A from="^(.*)/([^/]+)Configuration\.xml$$"
5053N/A to="\1/meta/\2CfgDefn.java" />
5232N/A <param name="base-dir" expression="${admin.temp.dir}" />
5232N/A <classpath refid="xalan.class.path" />
5232N/A </xslt>
5053N/A
5232N/A <xslt basedir="${admin.temp.dir}"
5053N/A destdir="${src.gen.dir}"
5053N/A style="${admin.dir}/package-info.xsl">
5232N/A <include name="**/Package.xml" />
5232N/A <exclude name="org/opends/server/admin/std/*.xml" />
5232N/A <regexpmapper handledirsep="true"
5053N/A from="^(.*)/([^/]+)\.xml$$"
5053N/A to="\1/meta/package-info.java" />
5232N/A <param name="type" expression="meta" />
5232N/A <classpath refid="xalan.class.path" />
5232N/A </xslt>
5053N/A
5053N/A <!-- Compile the Directory Server extension configuration client classes. -->
5232N/A <xslt basedir="${admin.temp.dir}"
5053N/A destdir="${src.gen.dir}"
5053N/A style="${admin.dir}/clientMO.xsl">
5232N/A <include name="**/*Configuration.xml" />
5232N/A <exclude name="org/opends/server/admin/std/*.xml" />
5232N/A <regexpmapper handledirsep="true"
5053N/A from="^(.*)/([^/]+)Configuration\.xml$$"
5053N/A to="\1/client/\2CfgClient.java" />
5232N/A <param name="base-dir" expression="${admin.temp.dir}" />
5232N/A <classpath refid="xalan.class.path" />
5232N/A </xslt>
5053N/A
5232N/A <xslt basedir="${admin.temp.dir}"
5053N/A destdir="${src.gen.dir}"
5053N/A style="${admin.dir}/package-info.xsl">
5232N/A <include name="**/Package.xml" />
5232N/A <exclude name="org/opends/server/admin/std/*.xml" />
5232N/A <regexpmapper handledirsep="true"
5053N/A from="^(.*)/([^/]+)\.xml$$"
5053N/A to="\1/client/package-info.java" />
5232N/A <param name="type" expression="client" />
5232N/A <classpath refid="xalan.class.path" />
5232N/A </xslt>
5053N/A
5053N/A <!-- Compile the Directory Server extension configuration server classes. -->
5232N/A <xslt basedir="${admin.temp.dir}"
5053N/A destdir="${src.gen.dir}"
5053N/A style="${admin.dir}/serverMO.xsl">
5232N/A <include name="**/*Configuration.xml" />
5232N/A <exclude name="org/opends/server/admin/std/*.xml" />
5232N/A <regexpmapper handledirsep="true"
5053N/A from="^(.*)/([^/]+)Configuration\.xml$$"
5053N/A to="\1/server/\2Cfg.java" />
5232N/A <param name="base-dir" expression="${admin.temp.dir}" />
5232N/A <classpath refid="xalan.class.path" />
5232N/A </xslt>
5053N/A
5232N/A <xslt basedir="${admin.temp.dir}"
5053N/A destdir="${src.gen.dir}"
5053N/A style="${admin.dir}/package-info.xsl">
5232N/A <include name="**/Package.xml" />
5232N/A <exclude name="org/opends/server/admin/std/*.xml" />
5232N/A <regexpmapper handledirsep="true"
5053N/A from="^(.*)/([^/]+)\.xml$$"
5053N/A to="\1/server/package-info.java" />
5232N/A <param name="type" expression="server" />
5232N/A </xslt>
5053N/A
5053N/A <!-- Compile the Directory Server extension configuration ldap profile property files. -->
5232N/A <xslt basedir="${admin.temp.dir}"
5053N/A destdir="${classes.dir}/admin/profiles/ldap"
5053N/A style="${admin.dir}/ldapMOProfile.xsl">
5232N/A <include name="**/*Configuration.xml" />
5232N/A <exclude name="org/opends/server/admin/std/*.xml" />
5232N/A <regexpmapper handledirsep="true"
5053N/A from="^(.*)/([^/]+)Configuration\.xml$$"
5053N/A to="\1/meta/\2CfgDefn.properties" />
5232N/A <param name="base-dir" expression="${admin.temp.dir}" />
5232N/A <classpath refid="xalan.class.path" />
5232N/A </xslt>
5053N/A
5053N/A <!-- Compile the Directory Server extension configuration cli profile property files. -->
5232N/A <xslt basedir="${admin.temp.dir}"
5053N/A destdir="${classes.dir}/admin/profiles/cli"
5053N/A style="${admin.dir}/cliMOProfile.xsl">
5232N/A <include name="**/*Configuration.xml" />
5232N/A <exclude name="org/opends/server/admin/std/*.xml" />
5232N/A <regexpmapper handledirsep="true"
5053N/A from="^(.*)/([^/]+)Configuration\.xml$$"
5053N/A to="\1/meta/\2CfgDefn.properties" />
5232N/A <param name="base-dir" expression="${admin.temp.dir}" />
5232N/A <classpath refid="xalan.class.path" />
5232N/A </xslt>
5053N/A
5053N/A <!-- Compile the Directory Server extension configuration I18N message files. -->
5232N/A <xslt basedir="${admin.temp.dir}"
5053N/A destdir="${classes.dir}/admin/messages"
5053N/A style="${admin.dir}/messagesMO.xsl">
5232N/A <include name="**/*Configuration.xml" />
5232N/A <exclude name="org/opends/server/admin/std/*.xml" />
5232N/A <regexpmapper handledirsep="true"
5053N/A from="^(.*)/([^/]+)Configuration\.xml$$"
5053N/A to="\1/meta/\2CfgDefn.properties" />
5232N/A <param name="base-dir" expression="${admin.temp.dir}" />
5232N/A <classpath refid="xalan.class.path" />
5232N/A </xslt>
5053N/A
5053N/A <!-- Compile the Directory Server extension configuration manifest file. -->
5232N/A <xslt basedir="${admin.temp.dir}"
5053N/A destdir="${admin.temp.dir}"
5053N/A extension=".manifest"
5053N/A style="${admin.dir}/manifestMO.xsl">
5232N/A <include name="**/*Configuration.xml" />
5232N/A <exclude name="org/opends/server/admin/std/*.xml" />
5232N/A <classpath refid="xalan.class.path" />
5232N/A </xslt>
5232N/A <concat destfile="${classes.dir}/admin/extension.manifest">
5232N/A <fileset dir="${admin.temp.dir}" includes="**/*.manifest" />
5232N/A </concat>
5053N/A
5053N/A <!-- Clean up -->
5232N/A <delete dir="${admin.temp.dir}" />
5232N/A </target>
5053N/A
5053N/A <!-- Validate the Directory Server extension configuration definitions. -->
5232N/A <target name="validateadmin">
5232N/A <schemavalidate>
5232N/A <fileset dir="${src.dir}" includes="**/*.xml" />
5232N/A <schema namespace="http://www.opends.org/admin"
5053N/A file="${admin.dir}/admin.xsd" />
5232N/A <schema namespace="http://www.opends.org/admin-ldap"
5053N/A file="${admin.dir}/admin-ldap.xsd" />
5232N/A <schema namespace="http://www.opends.org/admin-cli"
5053N/A file="${admin.dir}/admin-cli.xsd" />
5232N/A </schemavalidate>
5232N/A </target>
5053N/A
5053N/A <!-- Generate messages from messages.properties file
5053N/A located in the message directory and declared in a package
5053N/A -->
5232N/A <target name="generate-messages" if="hasmessages">
5232N/A <typedef name="genmsg"
5053N/A classname="org.opends.build.tools.GenerateMessageFile">
5232N/A <classpath>
5232N/A <fileset dir="${base.dir}/build/build-tools">
5232N/A <include name="*.jar" />
5232N/A </fileset>
5232N/A </classpath>
5232N/A </typedef>
5053N/A
5232N/A <path id="messages.src.path">
5232N/A <fileset dir="${src.dir}">
5232N/A <include name="**/${properties.file}" />
5232N/A </fileset>
5232N/A </path>
5232N/A <property name="messages.src.file" refid="messages.src.path" />
5053N/A
5232N/A <pathconvert property="messages.dst.file" refid="messages.src.path">
5232N/A <map from="${src.dir}" to="${src.gen.dir}" />
5232N/A </pathconvert>
5232N/A <dirname property="messages.dst.dir" file="${messages.dst.file}" />
5053N/A
5053N/A
5053N/A <!-- Needed by genmsg task -->
5232N/A <property name="msg.dir" location="${src.dir}" />
5232N/A <property name="msg.javagen.dir" location="${src.gen.dir}" />
5053N/A
5232N/A <genmsg sourceProps="${messages.src.file}" />
5232N/A <copy file="${messages.src.file}" todir="${classes.dir}/messages" />
5232N/A </target>
5053N/A</project>