mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Chris Ridd
20.36.2014 ddee5c4661c18ad221d412f7bb7777deed0cff99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
<!--
 ! 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
 ! or http://forgerock.org/license/CDDLv1.0.html.
 ! 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 2010 Sun Microsystems, Inc.
 !      Portions Copyright 2010-2012 ForgeRock AS.
 ! -->
 
<project name="extension" basedir="." default="package">
  <description>
      This Ant build file contains common targets for extensions. It
      should not be invoked directly.
  </description>
 
    <!-- OpenDS base directory -->
  <dirname property="extension.basedir" file="${ant.file.extension}" />
  <property name="base.dir" location="${extension.basedir}/.." />
 
  <property file="${base.dir}/PRODUCT" />
 
  <!-- Construct the version number string -->
  <taskdef name="getversionnumber"
           classname="org.opends.build.tools.CreateVersionString">
    <classpath>
      <fileset dir="${base.dir}/build/build-tools">
        <include name="*.jar" />
      </fileset>
    </classpath>
  </taskdef>
 
  <getversionnumber property="VERSION_NUMBER_STRING" />
 
  <property name="opends.install.dir"
    location="${base.dir}/build/package/${SHORT_NAME}-${VERSION_NUMBER_STRING}" />
 
    <!-- Source paths relative to extension -->
  <property name="src.dir" location="src" />
  <property name="src.gen.dir" location="src-generated" />
  <property name="lib.dir" location="lib" />
  <property name="config.dir" location="config" />
  <property name="schema.dir" location="schema" />
 
    <!-- CONFIGURE: The path of Xalan-Java distribution. -->
  <property name="xalan.directory" location="${base.dir}/ext/xalan-j" />
 
    <!-- Build paths relative to extension -->
  <property name="build.dir" location="build" />
  <property name="classes.dir" location="${build.dir}/classes" />
  <property name="javadoc.dir" location="${build.dir}/javadoc" />
  <property name="package.dir" location="${build.dir}/package" />
  <property name="message.dir" location="${build.dir}/message" />
 
    <!-- Files based on extension name -->
  <property name="jar.file" value="${extension.name}.jar" />
  <property name="properties.file" value="${extension.name}.properties" />
 
    <!-- Paths relative to OpenDS source tree -->
  <property name="resource.dir" location="${base.dir}/resource" />
  <property name="admin.dir" location="${resource.dir}/admin" />
 
    <!-- Build class path -->
  <path id="build.classpath">
    <fileset dir="${lib.dir}">
      <include name="*.jar" />
    </fileset>
    <pathelement path="${base.dir}/build/classes" />
  </path>
 
    <!-- Condition variable used for deciding if messages need generating -->
  <available property="hasmessages" file="${properties.file}" type="file">
    <filepath>
      <dirset dir="${src.dir}" />
    </filepath>
  </available>
 
    <!-- Clean up any files generated during the build process. -->
  <target name="clean"
            description="Clean up any files generated during the build process.">
    <delete includeemptydirs="true">
      <fileset dir="${src.gen.dir}" includes="**/*" />
    </delete>
    <delete includeemptydirs="true">
      <fileset dir="${build.dir}" includes="**/*" />
    </delete>
  </target>
 
  <!-- Perform verification for Xalan dependency -->
  <target name="ensurexalan" description="Verify that the Xalan-Java jar files are accessibles.">
    <fail message="Please use -Dxalan.directory to reference the directory that contains Xalan-Java">
      <condition>
        <not>
          <available property="xalan.directory.exists" file="${xalan.directory}" />
        </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="" />
      < -->
      </condition>
    </fail>
 
    <!-- 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 -->
    <property name="xalan.jar.files" value="serializer.jar,xalan.jar,xercesImpl.jar,xml-apis.jar" />
    <fail message="Missing at least one Xalan-Java jar files in directory ${xalan.directory} (expecting : ${xalan.jar.files}).">
      <condition>
        <not>
          <resourcecount count="4">
            <fileset dir="${xalan.directory}" includes="${xalan.jar.files}" />
          </resourcecount>
        </not>
      </condition>
    </fail>
 
  </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.gen.dir}:${src.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 refid="build.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="${extension.description} API Documentation"
                 maxmemory="${MEM}">
      <classpath refid="build.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}" />
    <jar jarfile="${package.dir}/${jar.file}"
             basedir="${classes.dir}"
             compress="true"
             index="true" />
  </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.">
 
    <echo message="Use the following Ant option to change the install location:" />
    <echo message="" />
    <echo message="  -Dopends.install.dir=path" />
    <echo message="      The path of an OpenDS installation where the extension will be installed." />
    <echo message="      Used by the install target [default: ${opends.install.dir}]." />
    <echo message="" />
 
    <mkdir dir="${opends.install.dir}/lib" />
    <copy todir="${opends.install.dir}/lib">
      <fileset file="${lib.dir}/*.jar" />
    </copy>
    <mkdir dir="${opends.install.dir}/lib/extensions" />
    <copy todir="${opends.install.dir}/lib/extensions">
      <fileset file="${package.dir}/*.jar" />
    </copy>
    <copy todir="${opends.install.dir}/config">
      <fileset file="${config.dir}/*.ldif" />
    </copy>
    <copy todir="${opends.install.dir}/config/schema">
      <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>
 
  <!-- Compile the Directory Server extension configuration definition files. -->
  <target name="compileadmin" depends="init,ensurexalan,validateadmin">
    <!-- The XSLT task creates a lot of noise.
         I can't find any other way to shut it up. -->
 
    <condition property="antcmd" value="ant.bat">
      <os family="windows" />
    </condition>
 
    <condition property="antcmd" value="ant">
      <not>
        <isset property="antcmd" />
      </not>
    </condition>
 
    <exec executable="${ant.home}/bin/${antcmd}" failonerror="true">
      <arg value="-buildfile" />
      <arg value="${ant.file}" />
      <arg value="-Dbuild.dir=${build.dir}" />
      <arg value="-quiet" />
      <arg value="compileadminsubtask" />
      <env key="ANT_OPTS" value="-Xmx${MEM}" />
      <!-- Set classpath to workaround Apple JDK Xalan conflict -->
      <env key="CLASSPATH" value="${xalan.directory}/xalan.jar" />
    </exec>
  </target>
 
  <target name="compileadminsubtask">
    <!-- 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>
 
    <!-- Copy XML definitions for this extension and core server into the same location -->
    <tempfile property="admin.temp.dir" destDir="${classes.dir}" />
    <mkdir dir="${admin.temp.dir}" />
 
    <copy todir="${admin.temp.dir}">
      <fileset dir="${src.dir}" includes="**/*.xml" />
      <fileset dir="${base.dir}/src/admin/defn" includes="**/*.xml" />
    </copy>
 
        <!-- Compile the Directory Server extension configuration meta classes. -->
    <xslt basedir="${admin.temp.dir}"
              destdir="${src.gen.dir}"
              style="${admin.dir}/metaMO.xsl">
      <include name="**/*Configuration.xml" />
      <exclude name="org/opends/server/admin/std/*.xml" />
      <regexpmapper handledirsep="true"
                          from="^(.*)/([^/]+)Configuration\.xml$$"
                          to="\1/meta/\2CfgDefn.java" />
      <param name="base-dir" expression="${admin.temp.dir}" />
      <classpath refid="xalan.class.path" />
    </xslt>
 
    <xslt basedir="${admin.temp.dir}"
              destdir="${src.gen.dir}"
              style="${admin.dir}/package-info.xsl">
      <include name="**/Package.xml" />
      <exclude name="org/opends/server/admin/std/*.xml" />
      <regexpmapper handledirsep="true"
                          from="^(.*)/([^/]+)\.xml$$"
                          to="\1/meta/package-info.java" />
      <param name="type" expression="meta" />
      <classpath refid="xalan.class.path" />
    </xslt>
 
        <!-- Compile the Directory Server extension configuration client classes. -->
    <xslt basedir="${admin.temp.dir}"
              destdir="${src.gen.dir}"
              style="${admin.dir}/clientMO.xsl">
      <include name="**/*Configuration.xml" />
      <exclude name="org/opends/server/admin/std/*.xml" />
      <regexpmapper handledirsep="true"
                          from="^(.*)/([^/]+)Configuration\.xml$$"
                          to="\1/client/\2CfgClient.java" />
      <param name="base-dir" expression="${admin.temp.dir}" />
      <classpath refid="xalan.class.path" />
    </xslt>
 
    <xslt basedir="${admin.temp.dir}"
              destdir="${src.gen.dir}"
              style="${admin.dir}/package-info.xsl">
      <include name="**/Package.xml" />
      <exclude name="org/opends/server/admin/std/*.xml" />
      <regexpmapper handledirsep="true"
                          from="^(.*)/([^/]+)\.xml$$"
                          to="\1/client/package-info.java" />
      <param name="type" expression="client" />
      <classpath refid="xalan.class.path" />
    </xslt>
 
        <!-- Compile the Directory Server extension configuration server classes. -->
    <xslt basedir="${admin.temp.dir}"
              destdir="${src.gen.dir}"
              style="${admin.dir}/serverMO.xsl">
      <include name="**/*Configuration.xml" />
      <exclude name="org/opends/server/admin/std/*.xml" />
      <regexpmapper handledirsep="true"
                          from="^(.*)/([^/]+)Configuration\.xml$$"
                          to="\1/server/\2Cfg.java" />
      <param name="base-dir" expression="${admin.temp.dir}" />
      <classpath refid="xalan.class.path" />
    </xslt>
 
    <xslt basedir="${admin.temp.dir}"
              destdir="${src.gen.dir}"
              style="${admin.dir}/package-info.xsl">
      <include name="**/Package.xml" />
      <exclude name="org/opends/server/admin/std/*.xml" />
      <regexpmapper handledirsep="true"
                          from="^(.*)/([^/]+)\.xml$$"
                          to="\1/server/package-info.java" />
      <param name="type" expression="server" />
    </xslt>
 
        <!-- Compile the Directory Server extension configuration ldap profile property files. -->
    <xslt basedir="${admin.temp.dir}"
              destdir="${classes.dir}/admin/profiles/ldap"
              style="${admin.dir}/ldapMOProfile.xsl">
      <include name="**/*Configuration.xml" />
      <exclude name="org/opends/server/admin/std/*.xml" />
      <regexpmapper handledirsep="true"
                          from="^(.*)/([^/]+)Configuration\.xml$$"
                          to="\1/meta/\2CfgDefn.properties" />
      <param name="base-dir" expression="${admin.temp.dir}" />
      <classpath refid="xalan.class.path" />
    </xslt>
 
        <!-- Compile the Directory Server extension configuration cli profile property files. -->
    <xslt basedir="${admin.temp.dir}"
              destdir="${classes.dir}/admin/profiles/cli"
              style="${admin.dir}/cliMOProfile.xsl">
      <include name="**/*Configuration.xml" />
      <exclude name="org/opends/server/admin/std/*.xml" />
      <regexpmapper handledirsep="true"
                          from="^(.*)/([^/]+)Configuration\.xml$$"
                          to="\1/meta/\2CfgDefn.properties" />
      <param name="base-dir" expression="${admin.temp.dir}" />
      <classpath refid="xalan.class.path" />
    </xslt>
 
        <!-- Compile the Directory Server extension configuration I18N message files. -->
    <xslt basedir="${admin.temp.dir}"
              destdir="${classes.dir}/admin/messages"
              style="${admin.dir}/messagesMO.xsl">
      <include name="**/*Configuration.xml" />
      <exclude name="org/opends/server/admin/std/*.xml" />
      <regexpmapper handledirsep="true"
                          from="^(.*)/([^/]+)Configuration\.xml$$"
                          to="\1/meta/\2CfgDefn.properties" />
      <param name="base-dir" expression="${admin.temp.dir}" />
      <classpath refid="xalan.class.path" />
    </xslt>
 
        <!-- Compile the Directory Server extension configuration manifest file. -->
    <xslt basedir="${admin.temp.dir}"
              destdir="${admin.temp.dir}"
              extension=".manifest"
              style="${admin.dir}/manifestMO.xsl">
      <include name="**/*Configuration.xml" />
      <exclude name="org/opends/server/admin/std/*.xml" />
      <classpath refid="xalan.class.path" />
    </xslt>
    <concat destfile="${classes.dir}/admin/extension.manifest">
      <fileset dir="${admin.temp.dir}" includes="**/*.manifest" />
    </concat>
 
        <!-- Clean up -->
    <delete dir="${admin.temp.dir}" />
  </target>
 
    <!-- Validate the Directory Server extension configuration definitions. -->
  <target name="validateadmin">
    <schemavalidate>
      <fileset dir="${src.dir}" includes="**/*.xml" />
      <schema namespace="http://www.opends.org/admin"
                    file="${admin.dir}/admin.xsd" />
      <schema namespace="http://www.opends.org/admin-ldap"
                    file="${admin.dir}/admin-ldap.xsd" />
      <schema namespace="http://www.opends.org/admin-cli"
                    file="${admin.dir}/admin-cli.xsd" />
    </schemavalidate>
  </target>
 
    <!-- Generate messages from messages.properties file
         located in the message directory and declared in a package
     -->
  <target name="generate-messages" if="hasmessages">
    <typedef name="genmsg"
                 classname="org.opends.build.tools.GenerateMessageFile">
      <classpath>
        <fileset dir="${base.dir}/build/build-tools">
          <include name="*.jar" />
        </fileset>
      </classpath>
    </typedef>
 
    <path id="messages.src.path">
      <fileset dir="${src.dir}">
        <include name="**/${properties.file}" />
      </fileset>
    </path>
    <property name="messages.src.file" refid="messages.src.path" />
 
    <pathconvert property="messages.dst.file" refid="messages.src.path">
      <map from="${src.dir}" to="${src.gen.dir}" />
    </pathconvert>
    <dirname property="messages.dst.dir" file="${messages.dst.file}" />
 
 
        <!-- Needed by genmsg task -->
    <property name="msg.dir" location="${src.dir}" />
    <property name="msg.javagen.dir" location="${src.gen.dir}" />
 
    <genmsg sourceProps="${messages.src.file}" />
    <copy file="${messages.src.file}" todir="${classes.dir}/messages" />
  </target>
</project>