Project

General

Profile

1
<?xml version="1.0"?>
2
<!--
3
  *   '$RCSfile$'
4
  *     Authors: Matt Jones, Chad Berkley, Jivka Bojilova
5
  *   Copyright: 2000 Regents of the University of California and the
6
  *              National Center for Ecological Analysis and Synthesis
7
  * For Details: http://www.nceas.ucsb.edu/
8
  *
9
  *    '$Author: jones $'
10
  *    '$Date: 2005-12-05 14:50:08 -0800 (Mon, 05 Dec 2005) $'
11
  *    '$Revision: 2817 $'
12
  *
13
  * Build file for the Ant cross-platform build system for metacat
14
  * See http://jakarta.apache.org for details on Ant
15
  *
16
  * usage: ant [compile|jar|install|jdoc]
17
  *
18
  * This program is free software; you can redistribute it and/or modify
19
  * it under the terms of the GNU General Public License as published by
20
  * the Free Software Foundation; either version 2 of the License, or
21
  * (at your option) any later version.
22
  *
23
  * This program is distributed in the hope that it will be useful,
24
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
  * GNU General Public License for more details.
27
  *
28
  * You should have received a copy of the GNU General Public License
29
  * along with this program; if not, write to the Free Software
30
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
31
-->
32
<project name="metacat" default="jar" basedir=".">
33
  <property environment="env"/>
34
  <property file="build.properties"/>  <!-- USER SPECIFIC PROPS -->
35

    
36
  <!-- Determine which tomcat we are using and tomcat-specific settings -->
37
  <condition property="jsdk" value="${tomcat}/lib/common/servlet.jar">
38
    <equals arg1="${tomcatversion}" arg2="tomcat3" />
39
  </condition>
40
  <condition property="jsdk" value="${tomcat}/common/lib/servlet.jar">
41
    <equals arg1="${tomcatversion}" arg2="tomcat4" />
42
  </condition>
43
  <condition property="jsdk" value="${tomcat}/common/lib/servlet-api.jar">
44
    <equals arg1="${tomcatversion}" arg2="tomcat5" />
45
  </condition>
46

    
47
  <target name="check-db">
48
    <condition property="use-oracle">
49
      <equals arg1="${database}" arg2="oracle" />
50
    </condition>
51
    <condition property="use-postgresql">
52
      <equals arg1="${database}" arg2="postgresql" />
53
    </condition>
54
    <condition property="use-sqlserver">
55
      <equals arg1="${database}" arg2="sqlserver" />
56
    </condition>
57
  </target>
58

    
59
  <target name="oracle" if="use-oracle">
60
     <!-- Customize these properties if you are using oracle -->
61
     <echo message="Using oracle..."/>
62
     <property name="dbDriver" value="oracle.jdbc.driver.OracleDriver"/>
63
     <property name="dbAdapter" value="edu.ucsb.nceas.dbadapter.OracleAdapter"/>
64
     <property name="jdbc-jar-name" value="classes111.zip" />
65
     <property name="jdbc" value="${jdbc_base}/${jdbc-jar-name}" />
66
     <!-- Property to indicate is not MSSQL installation-->
67
     <property name="other" value="yes"/>
68
     <property name="install-sql"
69
               value="xmltables.sql" />
70
     <property name="upgrade-1.2-sql"
71
               value="upgrade-db-to-1.2.sql" />
72
     <property name="upgrade-1.3-sql"
73
               value="upgrade-db-to-1.3.sql" />
74
     <property name="upgrade-1.4-sql"
75
               value="upgrade-db-to-1.4.sql" />
76
     <property name="upgrade-1.5-sql"
77
               value="upgrade-db-to-1.5.sql" />
78
     <property name="upgrade-1.6-sql"
79
               value="upgrade-db-to-1.6.sql" />
80
   </target>
81

    
82
   <target name="postgresql" if="use-postgresql">
83
     <!-- Customize these properties if you are using postgres -->
84
     <echo message="Using PostgreSQL..."/>
85
     <property name="dbDriver" value="org.postgresql.Driver"/>
86
     <property name="dbAdapter"
87
               value="edu.ucsb.nceas.dbadapter.PostgresqlAdapter"/>
88
     <property name="jdbc-jar-name" value="postgresql-8.0-312.jdbc3.jar" />
89
     <property name="jdbc" value="lib/${jdbc-jar-name}" />
90
     <!-- Property to indicate is not MSSQL installation-->
91
     <property name="other" value="yes"/>
92
     <property name="install-sql"
93
               value="xmltables-postgres.sql" />
94
     <property name="upgrade-1.2-sql"
95
               value="upgrade-db-to-1.2-postgres.sql" />
96
     <property name="upgrade-1.3-sql"
97
               value="upgrade-db-to-1.3-postgres.sql" />
98
     <property name="upgrade-1.4-sql"
99
               value="upgrade-db-to-1.4-postgres.sql" />
100
     <property name="upgrade-1.5-sql"
101
               value="upgrade-db-to-1.5-postgres.sql" />
102
     <property name="upgrade-1.6-sql"
103
               value="upgrade-db-to-1.6-postgres.sql" />
104
    </target>
105

    
106
   <target name="sqlserver" if="use-sqlserver">
107
     <!-- Customize these properties if you are using SQL server -->
108
     <echo message="Using SQL Server..."/>
109
     <property name="dbDriver" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
110
     <property name="dbAdapter"
111
               value="edu.ucsb.nceas.dbadapter.SqlserverAdapter"/>
112
     <property name="jdbc" value="${jdbc_base}/msbase.jar" />
113
     <property name="jdbc-add1" value="${jdbc_base}/msutil.jar" />
114
     <property name="jdbc-add2" value="${jdbc_base}/mssqlserver.jar" />
115
     <!-- Property to indicate is a MSSQL installation-->
116
     <property name="MSSQL" value="yes"/>
117
     <property name="install-sql"
118
               value="xmltables-sqlserver.sql" />
119
   </target>
120

    
121
   <target name="config" depends="check-db,oracle,postgresql,sqlserver">
122
      <!-- usr for client testing, generally you don't need change-->
123
      <property name="mcuser" value="uid=jones,o=NCEAS,dc=ecoinformatics,dc=org"/>
124
      <property name="mcpassword" value=""/>
125
      <property name="mcanotheruser" value="uid=jtao,o=LTER,dc=ecoinformatics,dc=org"/>
126
      <property name="mcanotherpassword" value=""/>
127

    
128
      <property name="debug" value="on" />
129
      <property name="debuglevel" value="55" />
130

    
131
      <property name="morphosourcedir" value="../morpho" />
132
      <property name="defaultcontenttype" value="application/octet-stream" />
133
      <property name="utilitiesdir" value="../utilities" />
134

    
135
      <echo>*********** tomcatversion = ${tomcatversion}</echo>
136
      <echo>*********** set jsdk to ${jsdk}</echo>
137
  </target>
138

    
139
   <target name="init" depends="config">
140
      <path id="compile.classpath">
141
        <pathelement location="${jsdk}"/>
142
        <pathelement location="lib" />
143
        <fileset dir="lib">
144
          <include name="*.jar"/>
145
        </fileset>
146
       <fileset dir="lib/lsid_lib">
147
         <include name="*.jar"/>
148
       </fileset>
149
       <fileset dir="${jdbc_base}">
150
         <include name="${jdbc-jar-name}"/>
151
          <include name="msbase.jar"/>
152
          <include name="msutil.jar"/>
153
          <include name="mssqlserver.jar"/>
154
        </fileset>
155
       </path>
156
      
157
      <!-- It is less likely you'll need to make any changes from here down,
158
           but customization is possible -->
159
      <property name="installdir"          value="${deploy.dir}/${metacat.context}" />
160
      <property name="temp-dir"            value="/tmp/${metacat.context}" />
161
      <property name="name"                value="metacat"/>
162
      <property name="Name"                value="MetaCat"/>
163
      <property name="debugprefix"         value="${Name}:"/>
164
      <property name="release"             value="1.6.0"/>
165
      <property name="replication-path"    value="/${metacat.context}/servlet/replication"/>
166
      <property name="harvester-registration-login-path" value="/${metacat.context}/harvesterRegistrationLogin"/>
167
      <property name="harvester-registration-path"       value="/${metacat.context}/harvesterRegistration"/>
168
      <property name="servlet-path"        value="/${metacat.context}/metacat"/>
169
      <property name="html-path"           value="/${metacat.context}"/>
170
      <property name="systemidserver"      value="http://${httpserver}"/>
171
      <property name="style-common-relpath"
172
                                           value="/style/common"/>
173
      <property name="style-common-cvsrelpath"
174
                                           value="lib${style-common-relpath}"/>
175
      <property name="style-common-fullpath"
176
                                           value="/${installdir}${style-common-relpath}"/>
177
      <property name="templates.dir"       value="${style-common-fullpath}/templates"/>
178
      <property name="style-common-path"
179
                                           value="/${metacat.context}${style-common-relpath}"/>
180
      <property name="style-skins-relpath" value="/style/skins"/>
181
      <property name="style-skins-path"    value="/${metacat.context}${style-skins-relpath}"/>
182
      <property name="replication-log"     value="/tmp/metacatreplication.log"/>
183
      <property name="replicationerrorlog" value="/tmp/metacatreplication.err"/>
184
      <property name="config-dir"          value="${deploy.dir}/${style-skins-path}" />
185
      <property name="util-module"         value="utilities" />
186
      <property name="eml-module"          value="eml" />
187
      <property name="eml-version"         value="2.0.0beta6" />
188
      <property name="eml-tag"             value="EML_2_0_0_BETA_6_FOR_METACAT" />
189
      <property name="eml2_0_0-tag"        value="RELEASE_EML_2_0_0_UPDATE_1" />
190
      <property name="eml2_0_1-tag"        value="RELEASE_EML_2_0_1_UPDATE_1" />
191
      <property name="eml2_0_0namespace"   value="eml://ecoinformatics.org/eml-2.0.0" />
192
      <property name="eml2_0_1namespace"   value="eml://ecoinformatics.org/eml-2.0.1" />
193
      <property name="eml2_1_0namespace"   value="eml://ecoinformatics.org/eml-2.1.0" />
194
      <property name="stmmlnamespace"      value="http://www.xml-cml.org/schema/stmml" />
195
      <property name="eml-css"             value="eml_xsl.css"/>
196
      <property name="eml-module.default.css"
197
                                           value="default.css"/>
198

    
199
      <!-- Config for registry variables -->
200
      <property name="scope"               value="obfs"/>
201
      <property name="responseForm"        value="genericResponse.tmpl"/>
202
      <property name="entryForm"           value="entryForm.tmpl"/>
203
      <property name="guide"               value="genericGuide.tmpl"/>
204
      <property name="loginForm"           value="loginForm.tmpl"/>
205
      <property name="confirmData"         value="confirmData.tmpl"/>
206
      <property name="deleteData"          value="deleteData.tmpl"/>
207
      <property name="genericHeader"       value="genericHeader.tmpl"/>
208
      <property name="genericFooter"       value="genericFooter.tmpl"/>
209
      <property name="adminname"           value="KNB Support"/>
210
      <property name="recipient"           value="knb-software\@nceas.ucsb.edu"/>
211

    
212
      <property name="defaultStage"        value="initregister"/>
213
      <property name="defaultHeader"       value="genericHeader.tmpl"/>
214
      <property name="defaultFooter"       value="genericFooter.tmpl"/>
215
      <property name="defaultChangePass"   value="ldapChangePass.tmpl"/>
216
      <property name="defaultResetPass"    value="ldapResetPass.tmpl"/>
217
      <property name="changePassSuccess"   value="ldapChangePassSuccess.tmpl"/>
218
      <property name="resetPassSuccess"    value="ldapResetPassSuccess.tmpl"/>
219
      <property name="registerFailed"      value="ldapRegisterFailed.tmpl"/>
220
      <property name="registerLter"        value="ldapRegisterLter.tmpl"/>
221
      <property name="registerMatch"       value="ldapRegisterMatch.tmpl"/>
222
      <property name="registerSuccess"     value="ldapRegisterSuccess.tmpl"/>
223
      <property name="register"            value="ldapRegister.tmpl"/>
224
      <property name="searchResults"       value="searchResults.tmpl"/>
225

    
226
      <filter token="scope"                value="${scope}"/>
227
      <filter token="responseForm"         value="${responseForm}"/>
228
      <filter token="entryForm"            value="${entryForm}"/>
229
      <filter token="guide"                value="${guide}"/>
230
      <filter token="loginForm"            value="${loginForm}"/>
231
      <filter token="confirmData"          value="${confirmData}"/>
232
      <filter token="deleteData"           value="${deleteData}"/>
233
      <filter token="genericHeader"        value="${genericHeader}"/>
234
      <filter token="genericFooter"        value="${genericFooter}"/>
235
      <filter token="adminname"            value="${adminname}"/>
236
      <filter token="recipient"            value="${recipient}"/>
237

    
238
      <filter token="ldapurl"              value="ldap.ecoinformatics.org"/>
239
      <filter token="ldapSearchBase"       value="dc=ecoinformatics,dc=org"/>
240
      <filter token="ldap_user"            value="cn=Manager,dc=ecoinformatics,dc=org"/>
241
      <filter token="ldap_password"        value="ldap_password"/>
242
      <filter token="mailhost"             value="smtp.ecoinformatics.org"/>
243
      <filter token="sender"               value="knb-software\@nceas.ucsb.edu"/>
244
      <filter token="cgiurl"               value="http://${server}/cgi-bin/ldapweb.cgi"/>
245

    
246
      <filter token="docrooturl" value="./" />
247
      <filter token="database" value="${database}" />
248
      <filter token="jdbc-connect" value="${jdbc-connect}"/>
249
      <filter token="dbDriver" value="${dbDriver}"/>
250
      <filter token="dbAdapter" value="${dbAdapter}"/>
251
      <filter token="install-dir" value="${installdir}"/>
252
      <filter token="temp-dir" value="${temp-dir}"/>
253
      <filter token="server" value="${server}"/>
254
      <filter token="systemidserver" value="${systemidserver}"/>
255
      <filter token="cgi-prefix" value="${cgi-prefix}"/>
256
      <filter token="ldapUrl" value="${ldapUrl}"/>
257
      <filter token="replication-log" value="${replication-log}"/>
258
      <filter token="replicationerrorlog" value="${replicationerrorlog}"/>
259
      <filter token="release" value="${release}"/>
260
      <filter token="servlet-path" value="${servlet-path}"/>
261
      <filter token="html-path" value="${html-path}"/>
262
      <filter token="user" value="${user}"/>
263
      <filter token="password" value="${password}"/>
264
      <filter token="mcuser" value="${mcuser}"/>
265
      <filter token="mcpassword" value="${mcpassword}"/>
266
      <filter token="mcanotheruser" value="${mcanotheruser}"/>
267
      <filter token="mcanotherpassword" value="${mcanotherpassword}"/>
268
      <filter token="knb-site-url" value="${knb-site-url}"/>
269
      <filter token="eml-css" value="${eml-css}"/>
270
      <filter token="style-skins-relpath" value="${style-skins-relpath}"/>
271
      <filter token="style-skins-path" value="${style-skins-path}"/>
272
      <filter token="style-common-relpath" value="${style-common-relpath}"/>
273
      <filter token="style-common-fullpath" value="${style-common-fullpath}"/>
274
      <filter token="style-common-path" value="${style-common-path}"/>
275
      <filter token="templates.dir" value="${templates.dir}"/>
276

    
277
      <!-- The "style-path" filter is used by the eml xsl stylesheets!!  -->
278
      <filter token="style-path" value="${style-skins-path}"/>
279
      <filter token="replication-path" value="${replication-path}"/>
280
      <filter token="harvester-registration-login-path" value="${harvester-registration-login-path}"/>
281
      <filter token="harvester-registration-path" value="${harvester-registration-path}"/>
282
      <filter token="config-dir" value="${config-dir}"/>
283
      <filter token="default-style" value="${default-style}"/>
284
      <filter token="eml-version" value="${eml-version}"/>
285
      <filter token="eml2_0_0namespace" value="${eml2_0_0namespace}"/>
286
      <filter token="eml2_0_1namespace" value="${eml2_0_1namespace}"/>
287
      <filter token="eml2_1_0namespace" value="${eml2_1_0namespace}"/>
288
      <filter token="stmmlnamespace" value="${stmmlnamespace}"/>
289
      <filter token="context" value="${metacat.context}"/>
290
      <filter token="forcereplicationwaitingtime" value="${forcereplicationwaitingtime}" />
291
      <filter token="debuglevel" value="${debuglevel}" />
292
      <filter token="datafilepath" value="${datafilepath}" />
293
      <filter token="inlinedatafilepath" value="${inlinedatafilepath}" />
294
      <filter token="defaultcontenttype" value="${defaultcontenttype}" />
295
      <filter token="debugprefix" value="${debugprefix}"/>
296
      <filter token="administrators" value="${administrators}"/>
297
      <filter token="moderators" value="${moderators}"/>
298
      <filter token="allowedSubmitters" value="${allowedSubmitters}"/>
299
      <filter token="deniedSubmitters" value="${deniedSubmitters}"/>
300

    
301
      <filter token="defaultStage" value="${defaultStage}"/>
302
      <filter token="defaultHeader" value="${defaultHeader}"/>
303
      <filter token="defaultFooter" value="${defaultFooter}"/>
304
      <filter token="defaultChangePass" value="${defaultChangePass}"/>
305
      <filter token="defaultResetPass" value="${defaultResetPass}"/>
306
      <filter token="changePassSuccess" value="${changePassSuccess}"/>
307
      <filter token="resetPassSuccess" value="${resetPassSuccess}"/>
308
      <filter token="registerFailed" value="${registerFailed}"/>
309
      <filter token="registerLter" value="${registerLter}"/>
310
      <filter token="registerMatch" value="${registerMatch}"/>
311
      <filter token="registerSuccess" value="${registerSuccess}"/>
312
      <filter token="register" value="${register}"/>
313
      <filter token="searchResults" value="${searchResults}"/>
314
       
315
   	  <filter token="timedreplication" value="${timedreplication}" />
316
   	  <filter token="firsttimedreplication" value="${firsttimedreplication}" />
317
   	  <filter token="timedreplicationinterval" value="${timedreplicationinterval}" />
318
      
319
   	  <property name="srcdir" value="./src" />
320
   	  <property name="lib.dir" value="./lib" />
321
      <property name="testdir" value="./test" />
322
      <property name="testtorun" value="BuildIndexTest" />
323
      <property name="junittestsdir" value="./test/edu/ucsb/nceas/metacattest" />
324
      <property name="junitnettestsdir" value="./test/edu/ucsb/nceas/metacatnettest" />
325
      <property name="build.dir" value="./build"/>
326
      <property name="build.src" value="${build.dir}/src"/>
327
      <property name="build.dest" value="${build.dir}/classes"/>
328
      <property name="build.docs" value="${build.dir}/docs"/>
329
      <property name="build.samples" value="${build.dir}/samples"/>
330
      <property name="build.tests" value="${build.dir}/tests"/>
331
      <property name="build.tmp" value="${build.dir}/tmp"/>
332
      <property name="build.metacattest" value="${build.tests}/metacattest"/>
333
      <property name="build.metacatnettest" value="${build.tests}/metacatnettest"/>
334
      <property name="build.data" value="${build.dir}/data"/>
335
      <property name="build.javadocs" value="${build.dir}/docs/api"/>
336
      <property name="build.war" value="${build.dir}/war"/>
337

    
338
      <property name="dist.dir" value="dist"/>
339
      <property name="ver.dir" value="${dist.dir}/${name}-${release}"/>
340
      <property name="ver.src" value="${ver.dir}/src"/>
341
      <property name="util.dir" value="${dist.dir}/${util-module}"/>
342
	  <!-- directories for creating a Harvest List Editor distribution -->
343
      <property name="dist.dir.hle" value="disthle"/>
344
      <property name="ver.dir.hle" value="${dist.dir.hle}/harvest-list-editor-${release}"/>
345

    
346
      <property name="package.home" value="edu/ucsb/nceas/metacat" />
347
      <condition property="utilities.required">
348
        <or>
349
          <not><available file="lib/httpclient.jar"/></not>
350
          <not><available file="lib/utilities.jar"/></not>
351
        </or>
352
      </condition>
353
      <condition property="eml.required">
354
        <or>
355
          <not><available file="lib/schema/eml-2.0.1/eml.xsd"/></not>
356
          <not><available file="lib/schema/eml-2.0.0/eml.xsd"/></not>
357
          <not><available file="lib/dtd/eml-dataset-2.0.0beta6.dtd"/></not>
358
        </or>
359
      </condition>
360

    
361
   </target>
362

    
363
   <target name="prepare" depends="init">
364
      <mkdir dir="${build.dir}"/>
365
      <mkdir dir="${build.src}"/>
366
      <mkdir dir="${build.dest}"/>
367
      <mkdir dir="${build.javadocs}"/>
368
      <mkdir dir="${build.tmp}"/>
369

    
370
      <copy todir="${build.src}" filtering="yes">
371
        <fileset dir="${srcdir}">
372
          <include name="edu/**"/>
373
          <include name="com/**"/>
374
          <include name="**/*.sql"/>
375
          <exclude name="**/CVS*"/>
376
          <exclude name="**/.#*"/>
377
        </fileset>
378
      </copy>
379
      <available file="lib/style/common/emlb6toeml2" type="dir"
380
                 property="styles.not.needed"/>
381
   </target>
382

    
383
   <target name="compile" depends="prepare,utilities"
384
    description="Compiles java code to build dir, and copies metacat props files there">
385

    
386
       <javac srcdir="${build.src}"
387
              destdir="${build.dest}"
388
              debug="${debug}"
389
              excludes="**/*.sql **/stringclient/** **/client/*.java **/harvesterClient/*.java">
390
        <classpath>
391
          <path refid="compile.classpath"/>
392
        </classpath>
393
      </javac>
394
   </target>
395

    
396
   <target name="jar" depends="compile,geteml"
397
    description="Compiles and jars metacat java code to metacat.jar in build dir">
398

    
399
       <delete file="${build.dir}/${name}.jar" />
400
       <jar jarfile="${build.dir}/${name}.jar" basedir="${build.dest}"
401
            excludes="**/protocols/ **/harvesterClient/" />
402
   </target>
403

    
404
   <target name="protocol" depends="compile"
405
    description="Compiles and jars protocol java code to protocol.jar in build dir">
406
       <delete file="${build.dir}/protocol.jar" />
407
       <jar jarfile="${build.dir}/protocol.jar" basedir="${build.dest}"
408
            includes="**/protocols/" />
409
   </target>
410

    
411
   <target name="utilities" depends="config" if="utilities.required">
412
     <ant dir="${utilitiesdir}" target="clean" inheritAll="false" />
413
     <ant dir="${utilitiesdir}" target="jar" inheritAll="false" />
414
     <copy file="${utilitiesdir}/lib/httpclient.jar" todir="lib" />
415
     <copy file="${utilitiesdir}/build/utilities.jar" todir="lib" />
416
   </target>
417

    
418
   <target name="getutilities" depends="prepare"
419
   description="Checks utility out of cvs and copies it to your metacat cvs sandbox">
420
     <echo>Enter CVS password: </echo>
421
     <cvs cvsRoot="${cvsroot}"
422
          package="${util-module}"
423
          dest="${build.tmp}" />
424
   </target>
425

    
426
   <target name="client" depends="utilities, prepare"
427
    description="Compiles metacat-client java code to build dir">
428
       <javac srcdir="${build.src}"
429
              destdir="${build.dest}"
430
              includes="edu/ucsb/nceas/metacat/client/*">
431
          <classpath>
432
            <path refid="compile.classpath"/>
433
          </classpath>
434
        </javac>
435
   </target>
436

    
437
   <target name="clientjar" depends="client"
438
    description="Compiles and jars metacat-client java code to metacat-client.jar in build dir">
439
       <delete file="${build.dir}/${name}-client.jar" />
440
       <jar jarfile="${build.dir}/${name}-client.jar" basedir="${build.dest}"
441
            includes="**/metacat/client/" />
442
   </target>
443

    
444
    <target name="advancedsearchjar" depends="compile"
445
            description="Compiles and jars advanced search Java code to advancedsearch.jar in build dir">
446
        <delete file="${build.dir}/advancedsearch.jar" />
447
        <jar jarfile="${build.dir}/advancedsearch.jar" basedir="${build.dest}"
448
             includes="**/metacat/advancedsearch/" />
449
    </target>
450

    
451
   <target name="harvester" depends="client"
452
           description="Compiles harvester java code to build dir">
453
       <javac srcdir="${build.src}"
454
              destdir="${build.dest}"
455
              includes="edu/ucsb/nceas/metacat/harvesterClient/*">
456
          <classpath>
457
            <path refid="compile.classpath"/>
458
          </classpath>
459
        </javac>
460
   </target>
461

    
462
   <target name="harvesterjar" depends="harvester"
463
           description="Compiles and jars harvester java code to harvester.jar in build dir">
464
       <delete file="${build.dir}/harvester.jar" />
465
       <jar jarfile="${build.dir}/harvester.jar" basedir="${build.dest}"
466
            includes="**/metacat/harvesterClient/" />
467
   </target>
468

    
469
   <target name="harvestListEditorDist" depends="harvesterjar"
470
           description="Prepares a distribution of the Harvest List Editor tool">
471
       <mkdir dir="${dist.dir.hle}"/>
472
       <delete dir="${ver.dir.hle}" />
473
       <mkdir dir="${ver.dir.hle}"/>
474
       <copy todir="${ver.dir.hle}" file="${build.dir}/harvester.jar"/>
475
       <copy todir="${ver.dir.hle}" file="lib/xercesImpl.jar"/>
476
       <copy todir="${ver.dir.hle}" file="lib/harvester/harvestList.xsd"/>
477
       <copy todir="${ver.dir.hle}" file="lib/harvester/harvestListEditor.bat"/>
478
       <copy todir="${ver.dir.hle}" file="lib/harvester/harvestListEditor.sh"/>
479
       <delete file="./harvest-list-editor-${release}.zip"/>
480
       <zip zipfile="./harvest-list-editor-${release}.zip" basedir="${ver.dir.hle}" />
481
       <delete file="./harvest-list-editor-${release}.tar.gz" />
482
       <tar tarfile="./harvest-list-editor-${release}.tar" basedir="${ver.dir.hle}" />
483
       <gzip zipfile="./harvest-list-editor-${release}.tar.gz"
484
             src="./harvest-list-editor-${release}.tar"/>
485
       <delete file="./harvest-list-editor-${release}.tar" />
486
   </target>
487

    
488
   <target  name="geteml" depends="getemlpre2,geteml2+" if="eml.required"
489
            description="Calls getemlpre2 and geteml2+ targets" />
490

    
491
   <target name="getemlpre2" depends="prepare" if="eml.required"
492
   description="Checks EML-beta6 out of cvs and copies dtds and xsl to your metacat cvs sandbox">
493
     <echo>Enter CVS password: </echo>
494
     <cvs cvsRoot="${cvsroot}"
495
          package="${eml-module}"
496
          tag="${eml-tag}"
497
          dest="${build.tmp}/eml_${eml-tag}" />
498
     <mkdir dir="lib/dtd" />
499
     <copy todir="lib/dtd" filtering="yes">
500
       <fileset dir="${build.tmp}/eml_${eml-tag}/${eml-module}">
501
         <include name="*.dtd"/>
502
       </fileset>
503
       <mapper type="glob" from="eml-*.dtd" to="eml-*-${eml-version}.dtd" />
504
     </copy>
505

    
506
     <copy todir="${style-common-cvsrelpath}" filtering="yes">
507
       <fileset dir="${build.tmp}/eml_${eml-tag}/${eml-module}/style">
508
       <include name="**/*.xsl"/>
509
     </fileset>
510
     </copy>
511
   </target>
512

    
513
   <target name="geteml2+" depends="prepare" if="eml.required"
514
   description="Checks eml-2 out of cvs and copies schema and xsl to your metacat cvs sandbox">
515
     <echo>Enter CVS password: </echo>
516
     <cvs cvsRoot="${cvsroot}"
517
          package="${eml-module}"
518
          tag="${eml2_0_0-tag}"
519
          dest="${build.tmp}/eml_${eml2_0_0-tag}" />
520
     <mkdir dir="lib/schema/eml-2.0.0" />
521
     <copy todir="lib/schema/eml-2.0.0" filtering="yes">
522
       <fileset dir="${build.tmp}/eml_${eml2_0_0-tag}/${eml-module}">
523
         <include name="*.xsd"/>
524
       </fileset>
525

    
526
       <!-- shouldn't we have a mapper here like this??
527
       <mapper type="glob" from="eml-*.xsd" to="eml-*-${eml-version}.xsd" />
528

    
529
       Jing's code didn't nave one - does it need to be added?
530
       NOTE that eml-version is set to beta 6, so this would need changing -->
531

    
532
     </copy>
533
     <antcall target="copyxsl">
534
        <param name="cvs.tagname" value="${eml2_0_0-tag}" />
535
        <param name="dirname" value="eml-2.0.0" />
536
     </antcall>
537

    
538
     <echo>Enter CVS password: </echo>
539
     <cvs cvsRoot="${cvsroot}"
540
          package="${eml-module}"
541
          tag="${eml2_0_1-tag}"
542
          dest="${build.tmp}/eml_${eml2_0_1-tag}" />
543
     <mkdir dir="lib/schema/eml-2.0.1" />
544
     <copy todir="lib/schema/eml-2.0.1" filtering="yes">
545
       <fileset dir="${build.tmp}/eml_${eml2_0_1-tag}/${eml-module}">
546
         <include name="*.xsd"/>
547
       </fileset>
548
     </copy>
549
     <antcall target="copyxsl">
550
        <param name="cvs.tagname" value="${eml2_0_1-tag}" />
551
        <param name="dirname" value="eml-2.0.1" />
552
     </antcall>
553
   </target>
554

    
555
   <target  name="copyxsl"
556
   description="Copies xsl stylesheets from checkout in build/tmp to your metacat cvs sandbox">
557

    
558
     <delete file="${style-common-cvsrelpath}/${eml-css}"/>
559

    
560
     <copy todir="${style-common-cvsrelpath}/${dirname}" filtering="yes">
561
       <fileset dir="${build.tmp}/eml_${cvs.tagname}/${eml-module}/style/eml">
562
       <include name="**/*.xsl"/>
563
     </fileset>
564
     </copy>
565

    
566

    
567
     <!-- now copy default css from eml module and put it in style-common-path
568
          dir with a new name, so other skin-specific css can import it if reqd -->
569
     <copy file="${build.tmp}/eml_${cvs.tagname}/${eml-module}/${eml-module.default.css}"
570
           tofile="${style-common-cvsrelpath}/${eml-css}" />
571

    
572
   </target>
573

    
574

    
575

    
576
   <target name="register-schemas" depends="prepare"
577
   description="Registers the Schemas with a new Metacat instance">
578
     <echo/>
579
     <echo>Registering the Schemas with the new Metacat instance...</echo>
580
     <sql driver="${dbDriver}"
581
          url="${jdbc-connect}"
582
          userid="${user}"
583
          password="${password}"
584
          src="${build.src}/loaddtdschema.sql">
585
       <classpath>
586
         <path refid="compile.classpath"/>
587
       </classpath>
588
     </sql>
589
   </target>
590

    
591
   <target name="installdb" depends="prepare"
592
            description="Installs the database tables">
593
     <echo/>
594
     <echo>Installing the database tables...</echo>
595
     <echo>In case of failure, run the sql script manually. Look at Metacat install instructions for more details</echo>
596
     <echo/>
597
     <sql driver="${dbDriver}"
598
          url="${jdbc-connect}"
599
          userid="${user}"
600
          password="${password}"
601
          src="${build.src}/${install-sql}">
602
       <classpath>
603
         <path refid="compile.classpath"/>
604
       </classpath>
605
     </sql>
606
   </target>
607

    
608
   <target name="dropdb" depends="prepare"
609
            description="WARNING: Drops the database tables">
610
     <echo/>
611
     <echo>Dropping the database tables...</echo>
612
     <echo>In case of failure, run the sql script manually. Look at Metacat install instructions for more details</echo>
613
     <echo/>
614
     <sql driver="${dbDriver}"
615
          url="${jdbc-connect}"
616
          userid="${user}"
617
          password="${password}"
618
          src="${build.src}/drop-postgres.sql">
619
       <classpath>
620
         <path refid="compile.classpath"/>
621
       </classpath>
622
     </sql>
623
   </target>
624

    
625
   <target name="upgrade12" depends="prepare"
626
            description="Updates the database tables to upgrade to version 1.2">
627
     <echo/>
628
     <echo>Updating the database tables to upgrade to version 1.2...</echo>
629
     <sql driver="${dbDriver}"
630
          url="${jdbc-connect}"
631
          userid="${user}"
632
          password="${password}"
633
          src="${build.src}/${upgrade-1.2-sql}">
634
       <classpath>
635
         <path refid="compile.classpath"/>
636
       </classpath>
637
     </sql>
638
   </target>
639

    
640
   <target name="upgrade13" depends="prepare"
641
            description="Updates the database tables to upgrade to version 1.3">
642
     <echo/>
643
     <echo>Updating the database tables to upgrade to version 1.3...</echo>
644
     <sql driver="${dbDriver}"
645
          url="${jdbc-connect}"
646
          userid="${user}"
647
          password="${password}"
648
          src="${build.src}/${upgrade-1.3-sql}">
649
       <classpath>
650
         <path refid="compile.classpath"/>
651
       </classpath>
652
     </sql>
653
   </target>
654

    
655
   <target name="upgrade14" depends="prepare"
656
            description="Updates the database tables to upgrade to version 1.4">
657
     <echo/>
658
     <echo>Updating the database tables to upgrade to version 1.4...</echo>
659
     <sql driver="${dbDriver}"
660
          url="${jdbc-connect}"
661
          userid="${user}"
662
          password="${password}"
663
          src="${build.src}/${upgrade-1.4-sql}">
664
       <classpath>
665
         <path refid="compile.classpath"/>
666
       </classpath>
667
     </sql>
668
   </target>
669

    
670
   <target name="upgrade15" depends="sqlupgrade15"
671
           description="Updates the database tables to upgrade to version 1.5">
672
     <echo/>
673
     <echo>Updating the database tables to upgrade to version 1.5...</echo>
674
     <copy file="${srcdir}/upgrade_db_to_1_5.java"
675
           todir="${build.tmp}" filtering="yes"/>
676

    
677
     <javac srcdir="${build.tmp}"
678
            destdir="${build.tmp}"
679
            debug="${debug}"
680
            includes="upgrade_db_to_1_5.java">
681
       <classpath>
682
         <path refid="compile.classpath"/>
683
       </classpath>
684
     </javac>
685

    
686
     <java classname="upgrade_db_to_1_5">
687
       <classpath>
688
         <path refid="compile.classpath"/>
689
         <fileset dir="${build.tmp}"/>
690
       </classpath>
691
     </java>
692

    
693
   </target>
694

    
695
   <target name="upgrade16" depends="prepare"
696
            description="Updates the database tables from version 1.5 to version 1.6">
697
     <echo/>
698
     <echo>Updating the database tables to upgrade to version 1.6...</echo>
699
     <sql driver="${dbDriver}"
700
          url="${jdbc-connect}"
701
          userid="${user}"
702
          password="${password}"
703
          src="${build.src}/${upgrade-1.6-sql}">
704
       <classpath>
705
         <path refid="compile.classpath"/>
706
       </classpath>
707
     </sql>
708
   </target>
709

    
710

    
711
   <target name="sqlupgrade15" depends="prepare">
712
      <echo>Updating the database tables to upgrade to version 1.5 by sql command</echo>
713
      <sql driver="${dbDriver}"
714
          classpath="${jdbc}:${jdbc-add1}:${jdbc-add2}"
715
          url="${jdbc-connect}"
716
          userid="${user}"
717
          password="${password}"
718
          src="${build.src}/${upgrade-1.5-sql}" />
719
      <sql driver="${dbDriver}"
720
          classpath="${jdbc}:${jdbc-add1}:${jdbc-add2}"
721
          url="${jdbc-connect}"
722
          userid="${user}"
723
          password="${password}"
724
          rdbms="oracle"
725
          delimiter="/">
726
        <transaction>
727
           CREATE TRIGGER xml_returnfield_before_insert
728
           BEFORE INSERT ON xml_returnfield FOR EACH ROW
729
           BEGIN
730
              SELECT xml_returnfield_id_seq.nextval
731
                 INTO :new.returnfield_id
732
                 FROM dual;
733
           END;
734
           /
735
        </transaction>
736
        <transaction>
737
           CREATE TRIGGER xml_queryresult_before_insert
738
           BEFORE INSERT ON xml_queryresult FOR EACH ROW
739
           BEGIN
740
              SELECT xml_queryresult_id_seq.nextval
741
              INTO :new.queryresult_id
742
              FROM dual;
743
           END;
744
           /
745
        </transaction>
746
      </sql>
747
   </target>
748

    
749
   <target name="install" depends="war" description="* Full Install *">
750
       <mkdir dir="${datafilepath}" />
751
       <mkdir dir="${inlinedatafilepath}" />
752
       <chmod dir="${datafilepath}" perm="ug+w" />
753
       <mkdir dir="${temp-dir}"/>
754
       <chmod dir="${temp-dir}" perm="ug+w" />
755
       <copy file="${dist.dir}/${metacat.context}.war" todir="${deploy.dir}"/>
756
   </target>
757

    
758
   <target name="upgrade" depends="install"
759
          description="* Upgrade an existing metacat installation with a new version *">
760
       <unwar src="${deploy.dir}/${metacat.context}.war" dest="${deploy.dir}/${metacat.context}" />
761
   </target>
762

    
763
   <target name="install-registry" depends="init,getConversionXSL"
764
            description="Install Registry">
765

    
766
      <copy file="${srcdir}/perl/register-dataset.cgi"
767
            todir="${inst.cgi.dir}" filtering="yes"/>
768
      <chmod file="${inst.cgi.dir}/register-dataset.cgi" perm="ugo+x" />
769

    
770
      <mkdir dir="${temp-dir}" />
771
      <copy todir="${temp-dir}" filtering="yes">
772
       <fileset dir="lib/style/common/emlb6toeml2">
773
         <include name="*.xsl"/>
774
         <include name="*.xml"/>
775
       </fileset>
776
      </copy>
777

    
778
      <echo message="Install Registry completed." />
779
   </target>
780

    
781
   <target name="install-ldap" depends="init">
782
      <copy file="${srcdir}/perl/ldapweb.cgi"
783
            todir="${inst.cgi.dir}" filtering="yes"/>
784
      <chmod file="${inst.cgi.dir}/ldapweb.cgi" perm="ugo+x" />
785
      <copy file="lib/ldapweb.cfg"
786
            todir="${inst.cgi.dir}" filtering="yes"/>
787
      <chmod file="${inst.cgi.dir}/ldapweb.cfg" perm="ugo+x" />
788
      <mkdir dir="${templates.dir}" />
789
      <copy todir="${templates.dir}" filtering="yes">
790
        <fileset dir="lib/style/common/templates">
791
            <include name="${defaultChangePass}"/>
792
            <include name="${defaultResetPass}"/>
793
            <include name="${changePassSuccess}"/>
794
            <include name="${resetPassSuccess}"/>
795
            <include name="${registerFailed}"/>
796
            <include name="${registerLter}"/>
797
            <include name="${registerMatch}"/>
798
            <include name="${registerSuccess}"/>
799
            <include name="${register}"/>
800
            <include name="${searchResults}"/>
801
        </fileset>
802
      </copy>
803
      <echo message="ldapweb install complete." />
804
   </target>
805

    
806

    
807
   <target name="install-skin" depends="init"
808
            description="Install a Skin">
809

    
810
      <input message="Please enter name of the skin"
811
             addproperty="skin-name"/>
812

    
813
      <mkdir dir="${installdir}/style/skins/${skin-name}" />
814
      <copy todir="${installdir}/style/skins/${skin-name}" filtering="yes">
815
       <fileset dir="lib/style/skins/${skin-name}">
816
           <exclude name="*.png"/>
817
           <exclude name="*.gif"/>
818
           <exclude name="*.jpg"/>
819
           <exclude name="**/CVS*"/>
820
           <exclude name="**/.#*"/>
821
       </fileset>
822
      </copy>
823
     <copy todir="${installdir}/style/skins/${skin-name}" filtering="no">
824
       <fileset dir="lib/style/skins/${skin-name}">
825
           <include name="*.png"/>
826
           <include name="*.gif"/>
827
           <include name="*.jpg"/>
828
           <exclude name="**/CVS*"/>
829
           <exclude name="**/.#*"/>
830
       </fileset>
831
      </copy>
832
      <!--
833
      <mkdir dir="${installdir}/style/skins/${skin-name}/images" />
834
     <copy todir="${installdir}/style/skins/${skin-name}/images" filtering="no">
835
       <fileset dir="lib/style/skins/${skin-name}/images">
836
           <include name="*.png"/>
837
           <include name="*.gif"/>
838
           <include name="*.jpg"/>
839
       </fileset>
840
      </copy>
841
      -->
842

    
843
      <echo message="Install Skin completed." />
844
   </target>
845

    
846
   <target name="war" depends="warPrepare,warMSSQL"
847
            description="Create a web archive (WAR) for servlet deployment">
848
       <mkdir dir="${dist.dir}" />
849
       <war destfile="${dist.dir}/${metacat.context}.war"
850
            webxml="${build.war}/web.xml">
851
         <fileset dir="${war.context}"/>
852
         <lib dir="${war.lib}"/>
853
         <webinf dir="${war.webinf}"/>
854
       </war>
855
   </target>
856

    
857
   <target name="warPrepare" depends="jar,clientjar,harvesterjar"
858
            description="Prepare files for creating a web archive (WAR)">
859

    
860
       <property name="war.lib" value="${build.war}/lib" />
861
       <property name="war.webinf" value="${build.war}/WEB-INF" />
862
       <property name="war.context" value="${build.war}/${metacat.context}" />
863
       <mkdir dir="${war.lib}" />
864
       <mkdir dir="${war.webinf}" />
865
       <mkdir dir="${war.context}" />
866
       
867
       <copy file="${jdbc}" tofile="${war.lib}/jdbc.jar" />
868
       <copy file="${build.dir}/${name}.jar" todir="${war.lib}" />
869
       <copy file="${build.dir}/${name}-client.jar" todir="${war.lib}" />
870
       <copy file="${build.dir}/harvester.jar" todir="${war.lib}" />
871
       <copy todir="${war.lib}" filtering="no">
872
         <fileset dir="lib">
873
            <not>
874
               <filename name="${jdbc-jar-name}"/>
875
            </not>
876
            <include name="*.jar"/>
877
         </fileset>
878
         <fileset dir="lib/xalan">
879
           <include name="*.jar"/>
880
         </fileset>
881
       </copy>
882
       <copy file="lib/web.xml.${tomcatversion}"
883
             tofile="${build.war}/web.xml" />
884
       <copy file="lib/metacat.properties" todir="${war.webinf}"
885
             filtering="yes" />
886
       <copy file="lib/log4j.properties" todir="${war.webinf}"
887
             filtering="yes" />
888
       <copy todir="${war.context}" filtering="no">
889
         <fileset dir="lib">
890
           <include name="**/*.jpg"/>
891
           <include name="**/*.png"/>
892
           <include name="**/*.gif"/>
893
         </fileset>
894
       </copy>
895
       <copy todir="${war.context}" filtering="yes">
896
         <fileset dir="lib">
897
           <exclude name="*.jar"/>
898
           <exclude name="*.properties"/>
899
           <exclude name="web.xml"/>
900
           <exclude name="**/*.jpg"/>
901
           <exclude name="**/*.png"/>
902
           <exclude name="**/*.gif"/>
903
           <exclude name="lsid_lib/**"/>
904
           <exclude name="lsid_conf/**"/>
905
         </fileset>
906
       </copy>
907
       <copy todir="${war.context}" filtering="no">
908
         <fileset dir="lib">
909
           <include name="**/*.jpg"/>
910
           <include name="**/*.png"/>
911
           <include name="**/*.gif"/>
912
         </fileset>
913
       </copy>
914
   </target>
915

    
916
   <target name="warMSSQL" if="MSSQL" depends="warPrepare">
917
      <copy file="${jdbc-add1}" tofile="${war.lib}/msutil.jar" />
918
       <copy file="${jdbc-add2}" tofile="${war.lib}/mssqlserver.jar" />
919
   </target>
920

    
921
   <target name="getConversionXSL" depends="prepare"
922
            unless="styles.not.needed"
923
            description="Gets the conversion stylesheets for eml2 beta 6 to eml 2.0.0">
924

    
925
     <echo>Enter CVS password: </echo>
926
     <cvs cvsRoot="${cvsroot}"
927
          package="${eml-module}"
928
          tag="${eml2_0_1-tag}"
929
          dest="${build.tmp}/eml_${eml2_0_1-tag}" />
930

    
931
     <mkdir dir="lib/style/common/emlb6toeml2" />
932
      <copy todir="lib/style/common/emlb6toeml2" filtering="yes">
933
       <fileset dir="${build.tmp}/eml_${eml2_0_1-tag}/${eml-module}/lib/beta6toeml2/xsl">
934
         <include name="*.xsl"/>
935
         <include name="*.xml"/>
936
       </fileset>
937
      </copy>
938
   </target>
939

    
940
   <target name="testprep" depends="jar,clientjar,harvesterjar">
941
      <mkdir dir="${build.tests}"/>
942
      <copy todir="${build.tests}" filtering="yes">
943
        <fileset dir="${testdir}">
944
          <include name="edu/**"/>
945
        </fileset>
946
      </copy>
947
      <!-- copy and compile the tests into a jar file -->
948
      <javac srcdir="${build.tests}"
949
             destdir="${build.tests}"
950
             debug="on"
951
       includes="**/*.java">
952
        <classpath>
953
          <path refid="compile.classpath"/>
954
          <fileset dir="${build.dir}">
955
            <includes name="${name}.jar"/>
956
            <includes name="${name}-client.jar"/>
957
            <includes name="harvester.jar"/>
958
          </fileset>
959
        </classpath>
960
      </javac>
961

    
962
      <jar jarfile="${build.dir}/${name}-junittests.jar"
963
        basedir="${build.tests}"
964
                includes="**/*.class" />
965
   </target>
966

    
967
   <target name="test" depends="testprep"
968
            description="Uses the ant junit task to run all JUnit tests">
969

    
970
      <!-- use the ant "junit" task to run JUnit tests. -->
971
      <junit printsummary="yes" haltonfailure="no" fork="yes"
972
             haltonerror="no">
973
        <jvmarg value="-Djava.protocol.handler.pkgs=HTTPClient"/>
974
        <classpath>
975
          <path refid="compile.classpath"/>
976
          <fileset dir="${build.dir}">
977
            <includes name="${name}.jar"/>
978
            <includes name="${name}-client.jar"/>
979
            <includes name="harvester.jar"/>
980
            <includes name="${name}-junittests.jar"/>
981
          </fileset>
982
        </classpath>
983

    
984
        <formatter type="plain" />
985

    
986
        <batchtest fork="yes" todir="${build.dir}">
987
          <fileset dir="${build.tests}">
988
            <include name="**/*.class" />
989
          </fileset>
990
        </batchtest>
991
     </junit>
992
   </target>
993

    
994
    <target name="runonetest" depends="testprep"
995
            description="Uses the ant junit task to run a single JUnit test, defined by the ${testtorun} property">
996

    
997
              <echo>testtorun: ${testtorun}</echo>
998

    
999
      <!-- use the ant "junit" task to run JUnit tests. -->
1000
      <junit printsummary="yes" haltonfailure="no" fork="yes"
1001
             haltonerror="no">
1002
        <!--<jvmarg value="-Djava.protocol.handler.pkgs=HTTPClient"/>-->
1003
        <classpath>
1004
          <path refid="compile.classpath"/>
1005
          <fileset dir="${build.dir}">
1006
            <includes name="${name}.jar"/>
1007
            <includes name="${name}-client.jar"/>
1008
            <includes name="harvester.jar"/>
1009
            <includes name="${name}-junittests.jar"/>
1010
          </fileset>
1011
        </classpath>
1012

    
1013
        <formatter type="plain" />
1014

    
1015
        <batchtest fork="yes" todir="${build.dir}">
1016
          <fileset dir="${build.tests}">
1017
            <include name="**/${testtorun}.class" />
1018
          </fileset>
1019
        </batchtest>
1020
     </junit>
1021
   </target>
1022

    
1023
   <target name="testharvester"
1024
           depends="testprep"
1025
           description="Uses the ant junit task to test only the Harvester code">
1026
     <junit printsummary="yes"
1027
            haltonfailure="off"
1028
            fork="yes"
1029
            haltonerror="off">
1030
        <classpath>
1031
          <path refid="compile.classpath"/>
1032
          <fileset dir="${build.dir}">
1033
            <includes name="${name}.jar"/>
1034
            <includes name="${name}-client.jar"/>
1035
            <includes name="harvester.jar"/>
1036
            <includes name="${name}-junittests.jar"/>
1037
          </fileset>
1038
        </classpath>
1039
       <formatter type="plain" />
1040
       <batchtest fork="yes" todir="${build.dir}">
1041
         <fileset dir="${build.tests}">
1042
           <include name="**/harvesterClient/*.class" />
1043
         </fileset>
1044
       </batchtest>
1045
     </junit>
1046
   </target>
1047

    
1048
  <target name="gethttpclient" depends="prepare"
1049
            description="checks out and compiles morpho httpclient code">
1050
  <!--mkdir dir="${morphosourcedir}" -->
1051
        <cvs cvsRoot="${cvsroot}"
1052
             package="morpho"
1053
             dest="." />
1054
        <ant dir="${morphosourcedir}" inheritAll="false"  target="jar" />
1055
   </target>
1056

    
1057
   <!-- run this target, we need to check out a another morpho souce dir was checked out. -->
1058
   <target name="nettest" depends="install"
1059
            description="compiles and runs the metacatnettest code">
1060

    
1061
      <echo>***********************************
1062
      Please run ant gethttpclient first!
1063
      ***********************************
1064
      </echo>
1065
      <!-- copy and compile the tests into a jar file -->
1066
      <mkdir dir="${build.metacatnettest}"/>
1067
      <javac srcdir="${junitnettestsdir}"
1068
             destdir="${build.metacatnettest}"
1069
             includes="**/*.java">
1070
        <classpath>
1071
          <path refid="compile.classpath"/>
1072
          <fileset dir="${build.dir}">
1073
            <includes name="${name}.jar"/>
1074
          </fileset>
1075
        </classpath>
1076
      </javac>
1077

    
1078
      <jar jarfile="${build.dir}/${name}-junitnettests.jar"
1079
                    basedir="${build.metacatnettest}"
1080
                    includes="**/*.class" />
1081

    
1082
      <!-- use the ant "junit" task to run JUnit tests. -->
1083
      <junit printsummary="yes" haltonfailure="no" fork="yes"
1084
             haltonerror="no">
1085
        <jvmarg value="-Djava.protocol.handler.pkgs=HTTPClient" />
1086
        <classpath>
1087
          <path refid="compile.classpath"/>
1088
          <fileset dir="${build.dir}">
1089
            <includes name="${name}.jar"/>
1090
            <includes name="${name}-junitnettests.jar"/>
1091
          </fileset>
1092
        </classpath>
1093

    
1094
        <formatter type="plain" />
1095

    
1096
        <batchtest fork="yes" todir="${build.dir}">
1097
          <fileset dir="${build.metacatnettest}">
1098
            <include name="**/*.class" />
1099
          </fileset>
1100
        </batchtest>
1101
     </junit>
1102
   </target>
1103

    
1104
   <target name="cleanweb" depends="clean"
1105
            description="deletes tomcat web context dir and all its contents">
1106
     <delete dir="${installdir}" />
1107
   </target>
1108

    
1109

    
1110
   <target name="clean" depends="init"
1111
            description="deletes build dir and files that can be regenerated form the release">
1112
       <delete dir="${build.dir}" />
1113
       <delete dir="${dist.dir}" />
1114
   </target>
1115

    
1116
   <target name="fullclean" depends="clean"
1117
            description="deletes even jars that depend on external sources such as stylesheets and jars">
1118
       <delete file="lib/httpclient.jar" />
1119
       <delete file="lib/utilities.jar" />
1120
       <delete includeEmptyDirs="true" failonerror="false">
1121
         <fileset dir="${style-common-cvsrelpath}">
1122
           <include name="${eml-css}" />
1123
           <include name="eml-*/*.xsl" />
1124
           <include name="eml-*" />
1125
         </fileset>
1126
       </delete>
1127
   </target>
1128

    
1129
   <target name="jdoc" depends="prepare"
1130
            description="generates javadoc documentation">
1131
       <javadoc packagenames="edu.ucsb.nceas.*"
1132
           sourcepath="${build.src}"
1133
           destdir="${build.javadocs}"
1134
           author="true"
1135
           version="true"
1136
           use="true"
1137
           windowtitle="${Name} API"
1138
           doctitle="&lt;h1&gt;${Name}&lt;/h1&gt;"
1139
           bottom="&lt;i&gt;Copyright &#169; 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.&lt;/i&gt;">
1140
         <classpath>
1141
           <path refid="compile.classpath"/>
1142
         </classpath>
1143
       </javadoc>
1144
   </target>
1145

    
1146
   <target name="dist"
1147
       depends="geteml,jar,protocol,jdoc,getConversionXSL,getutilities"
1148
            description="prepares a full release distribution">
1149
      <mkdir dir="${dist.dir}"/>
1150
      <delete dir="${ver.dir}" />
1151
      <mkdir dir="${ver.dir}"/>
1152
      <copy todir="${ver.dir}">
1153
        <fileset dir="."
1154
            excludes="**/CVS* **/.#* src/** test/** build/** docs/** ${dist.dir}/** ${dist.dir.hle}/**"/>
1155
      </copy>
1156
      <copy todir="${ver.dir}" file="build.xml"/>
1157
      <copy todir="${ver.dir}" file="build.properties"/>
1158

    
1159
      <copy todir="${ver.dir}/docs" filtering="yes">
1160
        <fileset dir="docs" excludes="**/*gif **/*jpg **/*png" />
1161
      </copy>
1162
      <copy todir="${ver.dir}/docs" filtering="no">
1163
        <fileset dir="docs" includes="**/*gif **/*jpg **/*png" />
1164
      </copy>
1165
      <copy todir="${ver.dir}/docs/dev">
1166
        <fileset dir="${build.dir}/docs"/>
1167
      </copy>
1168
      <copy todir="${ver.dir}/src">
1169
        <fileset dir="${build.dir}/src"/>
1170
      </copy>
1171
      <!-- copy loaddtdschemal.sql form src dir(which has the server token to ver.dir/src-->
1172
      <copy todir="${ver.dir}/src" file="${srcdir}/loaddtdschema.sql" overwrite="yes" filtering="no"/>
1173
      <copy todir="${ver.dir}/src" file="${srcdir}/upgrade-db-to-1.5.sql" overwrite="yes" filtering="no"/>
1174
      <!--
1175
      <delete dir="./${ver.dir}/${build.dir}"/>
1176
      <delete dir="./${ver.dir}/dist"/>
1177
      -->
1178
      <delete file="./${name}-${release}.zip"/>
1179
      <zip zipfile="./${name}-${release}.zip" basedir="${dist.dir}" excludes="${name}-${release}/src/**, ${name}-${release}/build/src/**"/>
1180
      <delete file="./${name}-${release}.tar.gz" />
1181
      <tar tarfile="./${name}-${release}.tar" basedir="${dist.dir}" excludes="${name}-${release}/src/**, ${name}-${release}/build/src/**"/>
1182
      <gzip zipfile="./${name}-${release}.tar.gz"
1183
                src="./${name}-${release}.tar"/>
1184
      <delete file="./${name}-${release}.tar" />
1185
  </target>
1186

    
1187
  <target name="distsrc" depends="dist"
1188
            description="prepares a source distribution">
1189
      <mkdir dir="${ver.src}"/>
1190
      <copy todir="${ver.src}">
1191
        <fileset dir="./src"/>
1192
      </copy>
1193
      <mkdir dir="${util.dir}"/>
1194
      <copy todir="${util.dir}">
1195
        <fileset dir="${build.tmp}/utilities" excludes="**/CVS*" />
1196
      </copy>
1197

    
1198
      <delete file="./${name}-src-${release}.zip"/>
1199
      <zip zipfile="./${name}-src-${release}.zip" basedir="${dist.dir}"/>
1200
      <delete file="./${name}-src-${release}.tar.gz" />
1201
      <tar tarfile="./${name}-src-${release}.tar" basedir="${dist.dir}"/>
1202
      <gzip zipfile="./${name}-src-${release}.tar.gz"
1203
                src="./${name}-src-${release}.tar"/>
1204
      <delete file="./${name}-src-${release}.tar" />
1205
      <delete dir="${dist.dir}"/>
1206
  </target>
1207

    
1208
   <target name="stylesheettest">
1209
     <xslt in="${input}" out="eml.html" style="${style-common-cvsrelpath}/eml-2.0.0/eml-2.0.0.xsl">
1210
      <param name="displaymodule" expression="${displaymodule}"/>
1211
      <param name="docid" expression="${input}"/>
1212
      <param name="entitytype" expression="${entitytype}"/>
1213
      <param name="entityindex" expression="${entityindex}"/>
1214
      <outputproperty name="method" value="html"/>
1215
      <outputproperty name="standalone" value="yes"/>
1216
      <outputproperty name="encoding" value="iso8859_1"/>
1217
      <outputproperty name="indent" value="yes"/>
1218
    </xslt>
1219
  </target>
1220

    
1221
 <target name="gridinit" depends="init">
1222
   <property name="java2wsdl.tool" value="org.apache.axis.wsdl.Java2WSDL" />
1223
   <property name="wsdldecorator.tool" value="org.globus.ogsa.tools.wsdl.DecorateWSDL" />
1224
   <property name="wsdl.tool" value="org.globus.ogsa.tools.wsdl.GSDL2Java"/>
1225
   <property environment="env"/>
1226
   <property name="binding.file" value="${env.GLOBUS_LOCATION}/schema/ogsi/ogsi_bindings.wsdl"/>
1227
    <path id="webservicepath">
1228
        <pathelement location="."/>
1229
        <pathelement location="${env.JAVA_HOME}/../lib/tools.jar"/>
1230
        <pathelement location="${build.dest}"/>
1231
        <fileset dir="${env.GLOBUS_LOCATION}/lib">
1232
           <include name="*.jar"/>
1233
        </fileset>
1234
      </path>
1235
</target>
1236

    
1237
 <target name="gridprepare" depends="gridinit, prepare">
1238
 </target>
1239

    
1240
  <target name="compileinterface" depends="clean, gridprepare">
1241
    <javac srcdir="${build.src}" destdir="${build.dest}" includes="**/${interface.name}.java" />
1242
  </target>
1243

    
1244
  <target name="generateWSDL" depends="compileinterface">
1245
    <echo message="Generating wsdl from ${interface.name} interface"/>
1246
    <java classname="${java2wsdl.tool}"
1247
          dir="${build.src}" fork="yes"
1248
          classpathref="webservicepath"  failonerror="true" >
1249
      <arg value="-P"/>
1250
      <arg value="${interface.name}PortType"/>
1251
      <arg value="-S"/>
1252
      <arg value="${interface.name}Service"/>
1253
      <arg value="-y"/>
1254
      <arg value="WRAPPED"/>
1255
      <arg value="-u"/>
1256
      <arg value="LITERAL"/>
1257
      <arg value="-l"/>
1258
      <arg value="http://localhost/ogsa/services/${interface.name}Service"/>
1259
      <arg value="-n"/>
1260
      <arg value="http://${services.namespace}/${interface.name}"/>
1261
      <arg value="${interface.package}.${interface.name}"/>
1262
    </java>
1263
  </target>
1264

    
1265
   <target name="decorateWSDL" depends="generateWSDL">
1266
      <property name="wsdl.file" value="${interface.name}Service.wsdl"/>
1267
      <java classname="${wsdldecorator.tool}" dir="${build.src}"
1268
            fork="yes"
1269
            classpathref="webservicepath" failonerror="true" >
1270
        <arg value="${binding.file}"/>
1271
        <arg value="${wsdl.file}"/>
1272
      </java>
1273
   </target>
1274

    
1275
   <target name="generatestubs" depends="decorateWSDL">
1276
      <echo message=" Generating stubs " />
1277
      <echo message="wsdl file is ${wsdl.file}"/>
1278
      <echo message="build.src is ${build.src}"/>
1279
      <java classname="${wsdl.tool}" dir="${build.src}" fork="yes"
1280
            classpathref="webservicepath" failonerror="true" >
1281
         <arg value="${wsdl.file}"/>
1282
    </java>
1283
  </target>
1284

    
1285
  <target name="compileStubsAndImpl" depends="generatestubs, utilities">
1286
     <echo message=" Compiling stubs " />
1287
     <javac srcdir="${build.src}" destdir="${build.dest}" classpathref="webservicepath" includes="**/${interface.name}/*.java" />
1288
     <echo message=" Compiling impl " />
1289
     <javac srcdir="${build.src}" destdir="${build.dest}" classpathref="webservicepath" classpath="./lib/utilities.jar" includes="**/impl/*.java" />
1290
  </target>
1291

    
1292
  <target name="jarStubsAndImpl" depends="compileStubsAndImpl">
1293
     <echo message=" jar stubs classes " />
1294
     <jar destfile="${build.dir}/${interface.name}-stubs.jar" basedir="${build.dest}" includes="**/${interface.name}/*.class" />
1295
     <echo message=" jar impl classes " />
1296
     <jar destfile="${build.dir}/${interface.name}.jar" basedir="${build.dest}" includes="**/impl/*.class" />
1297
  </target>
1298

    
1299
  <target name="gar" depends="jarStubsAndImpl">
1300
     <echo message=" jar the gar file"/>
1301
     <mkdir dir="${build.dir}/gar"/>
1302
     <mkdir dir="${build.dir}/gar/schema/edu"/>
1303
     <copy file="${build.dir}/${interface.name}.jar" todir="${build.dir}/gar" />
1304
     <copy file="${build.dir}/${interface.name}-stubs.jar" todir="${build.dir}/gar" />
1305
     <copy file="lib/utilities.jar" todir="${build.dir}/gar" />
1306
     <copy file="lib/server-deploy.wsdd" todir="${build.dir}/gar" />
1307
     <copy file="${build.src}/${interface.name}Service.wsdl" todir="${build.dir}/gar/schema/edu" />
1308
     <jar destfile="lib/${interface.name}.gar" basedir="${build.dir}/gar"/>
1309
  </target>
1310

    
1311
  <target name="compilewebclient" depends="prepare">
1312
     <javac srcdir="${build.src}" destdir="${build.dest}" includes="**/application/*.java" classpathref="webservicepath" />
1313
  </target>
1314

    
1315
  <target name="runwebclient" depends="compilewebclient">
1316
     <java classname="edu.ucsb.nceas.metacat.stringclient.application.MetacatStringServiceApplication"
1317
           dir="${build.dest}" fork="yes"
1318
           classpathref="webservicepath" classpath="./lib/utilities.jar" failonerror="true">
1319
         <arg value="${serviceUrl}"/>
1320
         <arg value="${docid}"/>
1321
     </java>
1322
  </target>
1323
  
1324
  <target name="spatial_option" depends="prepare" description=" -- compiles code for the spatial option">
1325

    
1326
    <echo message="Compiling the metatcat shapefile creator"/>
1327
    <echo message="using the shapelib at: ${shapelib.dir}"/>
1328
    <exec dir="." executable="g++" os="Linux, Unix" failonerror="true">
1329
     <arg line="./src/spatial/cpp/metacat_shapefile.cpp -I ${shapelib.dir} -c -o build/metacat_shapefile.o" />
1330
    </exec>
1331
  
1332
    <exec dir="." executable="g++" os="Linux, Unix" failonerror="true">
1333
     <arg line="build/metacat_shapefile.o ${shapelib.dir}/.libs/libshp.a -o bin/metacat_shapefile" />
1334
    </exec>
1335
  </target>
1336

    
1337
    <!-- LSID Authority support -->
1338
    <patternset id="lsid.jars">
1339
        <include name="axis.jar" />
1340
        <include name="commons-discovery-0.2.jar" />
1341
        <include name="jaxrpc.jar" />
1342
        <include name="lsid-client-1.1.1.jar" />
1343
        <include name="lsid-server-1.1.1.jar" />
1344
        <include name="saaj.jar" />
1345
        <include name="wsdl4j-1.5.1.jar" />
1346
        <include name="activation.jar" />
1347
        <include name="castor-0.9.5.jar" />
1348
        <include name="dnsjava-1.3.2.jar" />
1349
        <include name="mail.jar" />
1350
        <include name="commons-logging-1.0.4.jar" />
1351
        <!-- These jars may be needed but seem to not actually be,
1352
             so leaving them out for now
1353
        <include name="axis-ant.jar" />
1354
        -->
1355
        <!--<include name="GenCastor.class" />-->
1356
    </patternset>
1357
    <patternset id="lib.jars">
1358
        <include name="httpclient.jar" />
1359
        <include name="log4j-1.2.12.jar" />
1360
        <include name="utilities.jar" />
1361
        <include name="xercesImpl.jar" />
1362
        <include name="xalan.jar" />
1363
        <include name="xml-apis.jar" />
1364
    </patternset>
1365

    
1366
    <path id="lsid.classpath">
1367
        <fileset dir="${lsid.lib.dir}">
1368
            <patternset refid="lsid.jars"/>
1369
        </fileset>
1370
        <fileset dir="${lib.dir}">
1371
            <patternset refid="lsid.jars"/>
1372
        </fileset>
1373
        <fileset dir="${lib.dir}/xalan">
1374
            <include name="xalan.jar" />
1375
            <include name="xml-apis.jar" />
1376
        </fileset>
1377
        <fileset dir="${build.dir}">
1378
            <include name="metacat-client.jar" />
1379
        </fileset>
1380
    </path>
1381

    
1382
    <filterset id="configFilters">
1383
        <filter token="LSID_AUTHORITY_HOSTNAME"
1384
                value="${config.hostname}" />
1385
        <filter token="LSID_AUTHORITY_PORT"
1386
                value="${config.port}" />
1387
        <filter token="METADATA_LABELS"
1388
                value="${config.metadataLabelLsid}" />
1389
        <filter token="METACAT_SERVER"
1390
                value="${config.metacatserver}" />
1391
        <filter token="LSID_AUTHORITY_STRING"
1392
                value="${config.lsidauthority}" />
1393
    </filterset>
1394
    
1395
    <target name="prepare-lsid"
1396
            depends="prepare,utilities,clientjar"
1397
            description="Configure files prior to compilation">
1398
        <mkdir dir="${lsid.build.dir}" />
1399
        <!-- Copy the properties file into the build -->
1400
        <copy file="${conf.dir}/metacat-lsid.properties"
1401
              tofile="${lsid.build.dir}/WEB-INF/classes/metacat-lsid.properties"
1402
              overwrite="true">
1403
            <filterset refid="configFilters" />
1404
        </copy>
1405
        <copy file="${conf.dir}/log4j.properties"
1406
              tofile="${lsid.build.dir}/WEB-INF/classes/log4j.properties"
1407
              overwrite="true">
1408
            <filterset refid="configFilters" />
1409
        </copy>
1410
        <!-- Copy config files into the build -->
1411
        <copy todir="${lsid.build.dir}/WEB-INF">
1412
            <fileset dir="${webinf.dir}"
1413
                     includes="**/*.wsdd" />
1414
        </copy>
1415
        <!-- Copy the metadata configuration files into the build -->
1416
        <mkdir dir="${lsid.build.dir}/WEB-INF/classes/${lsid.classes.dir}" />
1417
        <copy todir="${lsid.build.dir}/WEB-INF/classes/${lsid.classes.dir}">
1418
            <fileset dir="${conf.dir}"
1419
                     includes="**/*.xml" />
1420
            <fileset dir="${conf.dir}"
1421
                     includes="**/*.xslt" />
1422
            <filterset refid="configFilters" />
1423
        </copy>
1424
        <!-- Copy services files into the build -->
1425
        <mkdir dir="${lsid.build.dir}/services" />
1426
        <copy todir="${lsid.build.dir}/services">
1427
            <fileset dir="${services.dir}" />
1428
            <filterset refid="configFilters" />
1429
        </copy>
1430
        <!-- Copy axis files into the build -->
1431
        <mkdir dir="${lsid.build.dir}" />
1432
        <copy todir="${lsid.build.dir}">
1433
            <fileset dir="${conf.dir}/axis"
1434
                     excludes="*.properties"/>
1435
        </copy>
1436
        <mkdir dir="${lsid.build.dir}/WEB-INF/classes" />
1437
        <copy todir="${lsid.build.dir}/WEB-INF/classes">
1438
            <fileset dir="${conf.dir}/axis"
1439
                     includes="*.properties"/>
1440
        </copy>
1441
    </target>
1442
    
1443
    <target name="compile-lsid"
1444
            depends="prepare-lsid"
1445
            description="Compile Java sources">
1446
        <mkdir dir="${lsid.build.dir}/WEB-INF/classes" />
1447
        <javac srcdir="src/edu/ucsb/nceas/metacat/lsid"
1448
               destdir="${lsid.build.dir}/WEB-INF/classes"
1449
               debug="${compile.debug}"
1450
               deprecation="${compile.deprecation}"
1451
               optimize="${compile.optimize}">
1452
            <classpath refid="lsid.classpath" />
1453
        </javac>
1454
    </target>
1455
    
1456
    <target name="war-lsid"
1457
            depends="compile-lsid"
1458
            description="Create a war file for the application">
1459
        <mkdir dir="${dist.dir}" />
1460
        <war destfile="${dist.dir}/${authority.context}.war"
1461
             webxml="${webinf.dir}/web.xml">
1462
            <fileset dir="${lsid.build.dir}" />
1463
            <lib dir="${lsid.lib.dir}">
1464
                <patternset refid="lsid.jars"/>
1465
            </lib>
1466
            <lib dir="${lib.dir}">
1467
                <patternset refid="lib.jars"/>
1468
            </lib>
1469
            <lib dir="${lib.dir}/xalan">
1470
                <include name="xalan.jar" />
1471
                <include name="xml-apis.jar" />
1472
            </lib>
1473
            <lib dir="${build.dir}">
1474
                <include name="metacat-client.jar" />
1475
            </lib>
1476
        </war>
1477
    </target>
1478
    
1479
    <target name="deploy-lsid"
1480
            depends="war-lsid"
1481
            description="Deploy LSID war to servlet container">
1482
        <delete dir="${deploy.dir}/${authority.context}" />
1483
        <delete file="${deploy.dir}/${authority.context}.war" />
1484
        <mkdir dir="${deploy.dir}" />
1485
        <copy todir="${deploy.dir}">
1486
            <fileset dir="${dist.dir}" />
1487
        </copy>
1488
    </target>
1489
</project>
(5-5/5)