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: sgarg $'
10
  *    '$Date: 2005-12-16 14:56:49 -0800 (Fri, 16 Dec 2005) $'
11
  *    '$Revision: 2872 $'
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_2" />
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="localhost"/>
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
      <filter token="indexPaths" value="${indexPaths}"/>
301

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

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

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

    
362
   </target>
363

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
567

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

    
573
   </target>
574

    
575

    
576

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

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

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

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

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

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

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

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

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

    
694
   </target>
695

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

    
711

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

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

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

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

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

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

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

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

    
807

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

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

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

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

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

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

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

    
912
   <target name="warMSSQL" if="MSSQL" depends="warPrepare">
913
      <copy file="${jdbc-add1}" tofile="${war.lib}/msutil.jar" />
914
       <copy file="${jdbc-add2}" tofile="${war.lib}/mssqlserver.jar" />
915
   </target>
916

    
917
   <target name="getConversionXSL" depends="prepare"
918
            unless="styles.not.needed"
919
            description="Gets the conversion stylesheets for eml2 beta 6 to eml 2.0.0">
920

    
921
     <echo>Enter CVS password: </echo>
922
     <cvs cvsRoot="${cvsroot}"
923
          package="${eml-module}"
924
          tag="${eml2_0_1-tag}"
925
          dest="${build.tmp}/eml_${eml2_0_1-tag}" />
926

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

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

    
958
      <jar jarfile="${build.dir}/${name}-junittests.jar"
959
        basedir="${build.tests}"
960
                includes="**/*.class" />
961
   </target>
962

    
963
   <target name="test" depends="testprep"
964
            description="Uses the ant junit task to run all JUnit tests">
965

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

    
980
        <formatter type="plain" />
981

    
982
        <batchtest fork="yes" todir="${build.dir}">
983
          <fileset dir="${build.tests}">
984
            <include name="**/*.class" />
985
          </fileset>
986
        </batchtest>
987
     </junit>
988
   </target>
989

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

    
993
              <echo>testtorun: ${testtorun}</echo>
994

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

    
1009
        <formatter type="plain" />
1010

    
1011
        <batchtest fork="yes" todir="${build.dir}">
1012
          <fileset dir="${build.tests}">
1013
            <include name="**/${testtorun}.class" />
1014
          </fileset>
1015
        </batchtest>
1016
     </junit>
1017
   </target>
1018

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

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

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

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

    
1074
      <jar jarfile="${build.dir}/${name}-junitnettests.jar"
1075
                    basedir="${build.metacatnettest}"
1076
                    includes="**/*.class" />
1077

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

    
1090
        <formatter type="plain" />
1091

    
1092
        <batchtest fork="yes" todir="${build.dir}">
1093
          <fileset dir="${build.metacatnettest}">
1094
            <include name="**/*.class" />
1095
          </fileset>
1096
        </batchtest>
1097
     </junit>
1098
   </target>
1099

    
1100
   <target name="cleanweb" depends="clean"
1101
            description="deletes tomcat web context dir and all its contents">
1102
     <delete dir="${installdir}" />
1103
   </target>
1104

    
1105

    
1106
   <target name="clean" depends="init"
1107
            description="deletes build dir and files that can be regenerated form the release">
1108
       <delete dir="${build.dir}" />
1109
       <delete dir="${dist.dir}" />
1110
   </target>
1111

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

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

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

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

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

    
1194
      <delete file="./${name}-src-${release}.zip"/>
1195
      <zip zipfile="./${name}-src-${release}.zip" basedir="${dist.dir}"/>
1196
      <delete file="./${name}-src-${release}.tar.gz" />
1197
      <tar tarfile="./${name}-src-${release}.tar" basedir="${dist.dir}"/>
1198
      <gzip zipfile="./${name}-src-${release}.tar.gz"
1199
                src="./${name}-src-${release}.tar"/>
1200
      <delete file="./${name}-src-${release}.tar" />
1201
      <delete dir="${dist.dir}"/>
1202
  </target>
1203

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

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

    
1233
 <target name="gridprepare" depends="gridinit, prepare">
1234
 </target>
1235

    
1236
  <target name="compileinterface" depends="clean, gridprepare">
1237
    <javac srcdir="${build.src}" destdir="${build.dest}" includes="**/${interface.name}.java" />
1238
  </target>
1239

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

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

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

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

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

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

    
1307
  <target name="compilewebclient" depends="prepare">
1308
     <javac srcdir="${build.src}" destdir="${build.dest}" includes="**/application/*.java" classpathref="webservicepath" />
1309
  </target>
1310

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

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

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

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

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