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: 2003-12-09 23:07:32 -0800 (Tue, 09 Dec 2003) $'
11
  *    '$Revision: 1954 $'
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

    
34
  <property file="build.properties"/>  <!-- USER SPECIFIC PROPS -->
35

    
36
  <target name="check-db">
37
    <condition property="use-oracle">
38
      <equals arg1="${database}" arg2="oracle" />
39
    </condition>
40
    <condition property="use-postgresql">
41
      <equals arg1="${database}" arg2="postgresql" />
42
    </condition>
43
    <condition property="use-sqlserver">
44
      <equals arg1="${database}" arg2="sqlserver" />
45
    </condition>
46
  </target>
47

    
48
  <target name="oracle" if="use-oracle">
49
     <!-- Customize these properties if you are using oracle -->
50
     <echo message="Using oracle..."/>
51
     <property name="dbDriver" value="oracle.jdbc.driver.OracleDriver"/>
52
     <property name="dbAdapter" value="edu.ucsb.nceas.dbadapter.OracleAdapter"/>
53
     <property name="jdbc" value="${jdbc_base}/classes111.zip" />
54
     <!-- Property to indicate is not MSSQL installation-->
55
     <property name="other" value="yes"/>
56
   </target>
57

    
58
   <target name="postgresql" if="use-postgresql">
59
     <!-- Customize these properties if you are using postgres -->
60
     <echo message="Using PostgreSQL..."/>
61
     <property name="dbDriver" value="org.postgresql.Driver"/>
62
     <property name="dbAdapter"
63
               value="edu.ucsb.nceas.dbadapter.PostgresqlAdapter"/>
64
     <property name="jdbc" value="lib/jdbc7.1-1.2.jar" />
65
     <!-- Property to indicate is not MSSQL installation-->
66
     <property name="other" value="yes"/>
67
    </target>
68
   
69
   <target name="sqlserver" if="use-sqlserver">
70
     <!-- Customize these properties if you are using SQL server -->
71
     <echo message="Using SQL Server..."/>
72
     <property name="dbDriver" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
73
     <property name="dbAdapter"
74
               value="edu.ucsb.nceas.dbadapter.SqlserverAdapter"/>
75
     <property name="jdbc" value="${jdbc-base}/msbase.jar" />
76
     <property name="jdbc-add1" value="${jdbc-base}/msutil.jar" />
77
     <property name="jdbc-add2" value="${jdbc-base}/mssqlserver.jar" />
78
     <!-- Property to indicate is a MSSQL installation-->
79
     <property name="MSSQL" value="yes"/>
80
   </target>
81

    
82
   <target name="config" depends="check-db,oracle,postgresql,sqlserver">
83
      <!-- usr for client testing, generally you don't need change-->
84
      <property name="mcuser" value="uid=tao,o=NCEAS,dc=ecoinformatics,dc=org"/>
85
      <property name="mcpassword" value=""/>
86
      <property name="mcanotheruser" value="uid=jtao,o=LTER,dc=ecoinformatics,dc=org"/>
87
      <property name="mcanotherpassword" value=""/>
88

    
89
      <property name="debug" value="on" />
90
      <property name="debuglevel" value="55" />
91

    
92
      <property name="morphosourcedir" value="../morpho" />
93
      <property name="defaultcontenttype" value="application/octet-stream" />
94
      <property name="utilitiesdir" value="../utilities" />
95
    
96
      <!-- Make sure these paths match the location of the jar files
97
           on your system, the defaults should usually work -->
98
      <condition property="jsdk" value="${tomcat}/lib/common/servlet.jar">
99
        <equals arg1="${tomcatversion}" arg2="tomcat3" />
100
      </condition>
101
      <condition property="jsdk" value="${tomcat}/common/lib/servlet.jar">
102
        <equals arg1="${tomcatversion}" arg2="tomcat4" />
103
      </condition>
104
      <echo>*********** tomcatversion = ${tomcatversion}</echo>
105
      <echo>*********** set jsdk to ${jsdk}</echo>
106
      <property name="xmlp"
107
                value="lib/xercesImpl.jar" />
108
      <property name="cos"
109
                value="lib/cos.jar" />
110
      <property name="morpho"
111
                value="lib/morpho.jar" />
112
      <property name="xalan"
113
                value="lib/xalan/xalan.jar" />
114
      <property name="apis"
115
                value="lib/xalan/xml-apis.jar" />
116
      <property name="httpclient"
117
                value="lib/httpclient.jar" />
118
      <property name="emlparser"
119
                value="lib/eml.jar" />
120
      <property name="configxml"
121
                value="lib/configxml.jar" />
122
      <property name="itislib"
123
                value="lib/itislib.jar" />
124
      <property name="emlparser"
125
      
126
                value="lib/eml.jar" />
127
      <property name="util"
128
                value="lib/utilities.jar" />
129
      <property name="srb"
130
                value="lib/srbrmi" />
131
  </target>
132

    
133
   <target name="init" depends="config">
134
      <!-- It is less likely you'll need to make any changes from here down,
135
           but customization is possible -->
136
      <property name="installdir"          value="${webapps}/${context}" />
137
      <property name="temp-dir"            value="/tmp/${context}" />
138
      <property name="name"                value="metacat"/>
139
      <property name="Name"                value="MetaCat"/>
140
      <property name="debugprefix"         value="${Name}:"/>
141
      <property name="release"             value="1.2.1"/>
142
      <property name="replication-path"    value="/${context}/servlet/replication"/>
143
      <property name="servlet-path"        value="/${context}/metacat"/>
144
      <property name="html-path"           value="/${context}"/>
145
      <property name="systemidserver"      value="http://${server}"/>
146
      <property name="style-common-relpath" 
147
                                           value="/style/common"/>
148
      <property name="style-common-cvsrelpath" 
149
                                           value="lib${style-common-relpath}"/>
150
      <property name="style-common-fullpath" 
151
                                           value="/${installdir}${style-common-relpath}"/>
152
      <property name="style-common-path" 
153
                                           value="/${context}${style-common-relpath}"/>
154
      <property name="style-skins-relpath" value="/style/skins"/>
155
      <property name="style-skins-path"    value="/${context}${style-skins-relpath}"/>
156
      <property name="replication-log"     value="/tmp/metacatreplication.log"/>
157
      <property name="replicationerrorlog" value="/tmp/metacatreplication.err"/>
158
      <property name="config-dir"          value="${webapps}/${style-skins-path}" />
159
      <property name="eml-module"          value="eml" />
160
      <property name="eml-version"         value="2.0.0beta6" />
161
      <property name="eml-tag"             value="EML_2_0_0_BETA_6_FOR_METACAT" />
162
      <property name="eml2-tag"            value="EML_2_0_0_FOR_METACAT" />
163
      <property name="eml2namespace"       value="eml://ecoinformatics.org/eml-2.0.0" />
164
      <property name="stmmlnamespace"      value="http://www.xml-cml.org/schema/stmml" />
165
      <property name="eml-css"             value="eml_xsl.css"/>
166
      <property name="eml-module.default.css"
167
                                           value="default.css"/>
168
      <property name="conversion-module"   value="webmdentry" />
169

    
170
      <!-- Config for registry variables -->
171
      <property name="scope"               value="obfs"/>
172
      <property name="responseForm"        value="genericResponse.tmpl"/>
173
      <property name="entryForm"           value="entryForm.tmpl"/>
174
      <property name="guide"               value="genericGuide.tmpl"/>
175
      <property name="confirmData" value="confirmData.tmpl"/>
176
      <property name="deleteData" value="deleteData.tmpl"/>
177
      <property name="genericHeader" value="genericHeader.tmpl"/>
178
      <property name="genericFooter" value="genericFooter.tmpl"/>
179
      <property name="adminname" value="KNB Support"/>
180
      <property name="recipient" value="knb-software\@nceas.ucsb.edu"/>
181
      <filter token="scope" value="${scope}"/>
182
      <filter token="responseForm" value="${responseForm}"/>
183
      <filter token="entryForm" value="${entryForm}"/>
184
      <filter token="guide" value="${guide}"/>      
185
      <filter token="confirmData" value="${confirmData}"/>
186
      <filter token="deleteData" value="${deleteData}"/>
187
      <filter token="genericHeader" value="${genericHeader}"/>
188
      <filter token="genericFooter" value="${genericFooter}"/>
189
      <filter token="adminname" value="${adminname}"/>
190
      <filter token="recipient" value="${recipient}"/>
191

    
192
      <property name="cpath"
193
                value="${xmlp}:${xalan}:${apis}:${jdbc}:${jsdk}:${srb}:${cos}:${morpho}:${emlparser}:${jdbc-add1}:${jdbc-add2}:${util}:${httpclient}"/>
194

    
195
      <filter token="docrooturl" value="./" />
196
      <filter token="jdbc-connect" value="${jdbc-connect}"/>
197
      <filter token="dbDriver" value="${dbDriver}"/>
198
      <filter token="dbAdapter" value="${dbAdapter}"/>
199
      <filter token="install-dir" value="${installdir}"/>
200
      <filter token="temp-dir" value="${temp-dir}"/>
201
      <filter token="server" value="${server}"/>
202
      <filter token="systemidserver" value="${systemidserver}"/>
203
      <filter token="cgi-prefix" value="${cgi-prefix}"/>
204
      <filter token="ldapUrl" value="${ldapUrl}"/>
205
      <filter token="replication-log" value="${replication-log}"/>
206
      <filter token="replicationerrorlog" value="${replicationerrorlog}"/>
207
      <filter token="release" value="${release}"/>
208
      <filter token="servlet-path" value="${servlet-path}"/>
209
      <filter token="html-path" value="${html-path}"/>
210
      <filter token="user" value="${user}"/>
211
      <filter token="password" value="${password}"/>
212
      <filter token="mcuser" value="${mcuser}"/>
213
      <filter token="mcpassword" value="${mcpassword}"/>
214
      <filter token="mcanotheruser" value="${mcanotheruser}"/>
215
      <filter token="mcanotherpassword" value="${mcanotherpassword}"/>
216
      <filter token="knb-site-url" value="${knb-site-url}"/>
217
      <filter token="eml-css" value="${eml-css}"/>
218
      <filter token="style-skins-relpath" value="${style-skins-relpath}"/>
219
      <filter token="style-skins-path" value="${style-skins-path}"/>
220
      <filter token="style-common-relpath" value="${style-common-relpath}"/>
221
      <filter token="style-common-fullpath" value="${style-common-fullpath}"/>
222
      <filter token="style-common-path" value="${style-common-path}"/>
223
      <!-- The "style-path" filter is used by the eml xsl stylesheets!!  -->
224
      <filter token="style-path" value="${style-skins-path}"/>
225
      <filter token="replication-path" value="${replication-path}"/>
226
      <filter token="config-dir" value="${config-dir}"/>
227
      <filter token="default-style" value="${default-style}"/>
228
      <filter token="eml-version" value="${eml-version}"/>
229
      <filter token="eml2namespace" value="${eml2namespace}"/>
230
      <filter token="stmmlnamespace" value="${stmmlnamespace}"/>
231
      <filter token="context" value="${context}"/>
232
      <filter token="forcereplicationwaitingtime" value="${forcereplicationwaitingtime}" />
233
      <filter token="debuglevel" value="${debuglevel}" />
234
      <filter token="datafilepath" value="${datafilepath}" />
235
      <filter token="inlinedatafilepath" value="${inlinedatafilepath}" />
236
      <filter token="defaultcontenttype" value="${defaultcontenttype}" />
237
      <filter token="debugprefix" value="${debugprefix}"/>
238

    
239
      <property name="srcdir" value="./src" />
240
      <property name="testdir" value="./test" />
241
      <property name="testtorun" value="MetacatClientTest" />
242
      <property name="junittestsdir" value="./test/edu/ucsb/nceas/metacattest" />
243
      <property name="junitnettestsdir" value="./test/edu/ucsb/nceas/metacatnettest" />
244
      <property name="build.dir" value="./build"/>
245
      <property name="build.src" value="${build.dir}/src"/>
246
      <property name="build.dest" value="${build.dir}/classes"/>
247
      <property name="build.docs" value="${build.dir}/docs"/>
248
      <property name="build.samples" value="${build.dir}/samples"/>
249
      <property name="build.tests" value="${build.dir}/tests"/>
250
      <property name="build.tmp" value="${build.dir}/tmp"/>
251
      <property name="build.metacattest" value="${build.tests}/metacattest"/>
252
      <property name="build.metacatnettest" value="${build.tests}/metacatnettest"/>
253
      <property name="build.data" value="${build.dir}/data"/>
254
      <property name="build.javadocs" value="${build.dir}/docs/api"/>
255
      <property name="build.war" value="${build.dir}/war"/>
256

    
257
      <property name="dist.dir" value="dist"/>
258
      <property name="ver.dir" value="${dist.dir}/${name}-${release}"/>
259
      <property name="ver.src" value="${ver.dir}/src"/>
260

    
261
      <property name="package.home" value="edu/ucsb/nceas/metacat" />
262
   </target>
263

    
264
   <target name="prepare" depends="init">
265
      <mkdir dir="${build.dir}"/>
266
      <mkdir dir="${build.src}"/>
267
      <mkdir dir="${build.dest}"/>
268
      <mkdir dir="${build.javadocs}"/>
269
      <mkdir dir="${build.tmp}"/>
270

    
271
      <copy todir="${build.src}" filtering="yes">
272
        <fileset dir="${srcdir}">
273
          <include name="edu/**"/>
274
          <include name="com/**"/>
275
          <include name="**/*.sql"/>
276
          <exclude name="**/CVS*"/>
277
          <exclude name="**/.#*"/>
278
        </fileset>
279
      </copy>
280
      <available file="build/tmp/${conversion-module}" type="dir" 
281
                 property="styles.not.needed"/>
282
   </target>
283

    
284
   <target name="compile" depends="prepare,utilities"
285
    description="Compiles java code to build dir, and copies metacat + srb props files there">
286

    
287
       <javac srcdir="${build.src}"
288
              destdir="${build.dest}"
289
              classpath="${cpath}"
290
              debug="${debug}"
291
              excludes="**/*.sql **/stringclient/** **/client/*.java"/>
292
       <copy file="lib/srbProps.properties"
293
             tofile="${build.dest}/${package.home}/srbProps.properties"/>
294
   </target>
295

    
296
   <target name="jar" depends="compile"
297
    description="Compiles and jars metacat java code to metacat.jar in build dir">
298

    
299
       <delete file="${build.dir}/${name}.jar" />
300
       <copy todir="${build.dest}">
301
         <fileset dir="lib/srbrmi"/>
302
       </copy>
303
       <jar jarfile="${build.dir}/${name}.jar" basedir="${build.dest}"
304
            excludes="**/protocols/" />
305
   </target>
306

    
307
   <target name="protocol" depends="compile"
308
    description="Compiles and jars protocol java code to protocol.jar in build dir">
309
       <delete file="${build.dir}/protocol.jar" />
310
       <jar jarfile="${build.dir}/protocol.jar" basedir="${build.dest}"
311
            includes="**/protocols/" />
312
   </target>
313

    
314
   <target name="utilities" depends="config">
315
     <ant dir="${utilitiesdir}" target="clean" inheritAll="false" />
316
     <ant dir="${utilitiesdir}" target="jar" inheritAll="false" />
317
     <copy file="${utilitiesdir}/lib/httpclient.jar" todir="lib" />
318
     <copy file="${utilitiesdir}/build/utilities.jar" todir="lib" />
319
   </target>
320

    
321
   <target name="client" depends="utilities, prepare"
322
    description="Compiles metacat-client java code to build dir">
323
       <javac srcdir="${build.src}"
324
              destdir="${build.dest}"
325
              classpath="${cpath}"
326
              includes="edu/ucsb/nceas/metacat/client/*" />
327
   </target>
328

    
329
   <target name="clientjar" depends="client"
330
    description="Compiles and jars metacat-client java code to metacat-client.jar in build dir">
331
       <delete file="${build.dir}/${name}-client.jar" />
332
       <jar jarfile="${build.dir}/${name}-client.jar" basedir="${build.dest}"
333
            includes="**/metacat/client/" />
334
   </target>
335

    
336
   <target name="harvester" depends="clientjar"
337
           description="Compiles harvester java code to build dir">
338
       <echo message="classpath is:   ${cpath}"/>
339
       <javac srcdir="${build.src}"
340
              destdir="${build.dest}"
341
              classpath="${cpath}"
342
              includes="edu/ucsb/nceas/metacat/harvesterClient/*" />
343
   </target>
344

    
345
   <target name="harvesterjar" depends="harvester"
346
           description="Compiles and jars harvester java code to harvester-client.jar in build dir">
347
       <delete file="${build.dir}/harvester-client.jar" />
348
       <jar jarfile="${build.dir}/harvester-client.jar" basedir="${build.dest}"
349
            includes="**/metacat/harvesterClient/" />
350
   </target>
351

    
352
   <target name="installharvester" depends="harvesterjar,install"
353
           description="Installs harvester web-server files">
354
      <mkdir dir="${installdir}/WEB-INF/lib" />
355
      <copy file="lib/style/skins/dev/harvesterLogin.html"
356
            tofile="${installdir}/harvesterLogin.html" />
357
      <copy file="lib/style/skins/dev/harvesterUpload.html"
358
            tofile="${installdir}/harvesterUpload.html" />
359
      <copy file="${build.dir}/harvester-client.jar"
360
            tofile="${installdir}/WEB-INF/lib/harvester-client.jar" />
361
   </target>
362
   
363
   <target  name="geteml" depends="getemlpre2,geteml2+" 
364
            description="Calls getemlpre2 and geteml2+ targets" />
365

    
366
   <target name="getemlpre2" depends="prepare"
367
   description="Checks EML-beta6 out of cvs and copies dtds and xsl to your metacat cvs sandbox">
368
     <echo>Enter CVS password: </echo>
369
     <cvs cvsRoot="${cvsroot}"
370
          package="${eml-module}"
371
          tag="${eml-tag}"
372
          dest="${build.tmp}/eml_${eml-tag}" />
373
     <mkdir dir="lib/dtd" />
374
     <copy todir="lib/dtd" filtering="yes">
375
       <fileset dir="${build.tmp}/eml_${eml-tag}/${eml-module}">
376
         <include name="*.dtd"/>
377
       </fileset>
378
       <mapper type="glob" from="eml-*.dtd" to="eml-*-${eml-version}.dtd" />
379
     </copy>
380
     <antcall target="copyxsl">
381
        <param name="cvs.tagname" value="${eml-tag}" />
382
     </antcall>
383
   </target>
384

    
385
   <target name="geteml2+" depends="prepare"
386
   description="Checks eml-2 out of cvs and copies schema and xsl to your metacat cvs sandbox">
387
     <echo>Enter CVS password: </echo>
388
     <cvs cvsRoot="${cvsroot}"
389
          package="${eml-module}"
390
          tag="${eml2-tag}"
391
          dest="${build.tmp}/eml_${eml2-tag}" />
392
     <mkdir dir="lib/schema" />
393
     <copy todir="lib/schema" filtering="yes">
394
       <fileset dir="${build.tmp}/eml_${eml2-tag}/${eml-module}">
395
         <include name="*.xsd"/>
396
       </fileset>
397
       
398
       <!-- shouldn't we have a mapper here like this??
399
       <mapper type="glob" from="eml-*.xsd" to="eml-*-${eml-version}.xsd" />
400
       
401
       Jing's code didn't nave one - does it need to be added? 
402
       NOTE that eml-version is set to beta 6, so this would need changing -->
403
     
404
     </copy>
405
     <antcall target="copyxsl">
406
        <param name="cvs.tagname" value="${eml2-tag}" />
407
     </antcall>
408
   </target>
409
   
410
   
411

    
412
   <target  name="copyxsl" 
413
   description="Copies xsl stylesheets from checkout in build/tmp to your metacat cvs sandbox">
414

    
415
     <delete file="${style-common-cvsrelpath}/${eml-css}"/>
416
     
417
     <copy todir="${style-common-cvsrelpath}" filtering="yes">
418
       <fileset dir="${build.tmp}/eml_${cvs.tagname}/${eml-module}/style">
419
       <include name="**/*.xsl"/>
420
     </fileset>
421
     </copy>
422
     
423

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

    
429
   </target>
430
   
431
   
432
   
433
   <target name="dtdschemasql" depends="prepare"
434
   description="Registers the DTDs with the new Metacat instance">
435
     <echo/>
436
     <echo>Registering the DTDs with the new Metacat instance...</echo>
437
     <sql driver="${dbDriver}"
438
          classpath="${jdbc}:${jdbc-add1}:${jdbc-add2}"
439
          url="${jdbc-connect}"
440
          userid="${user}"
441
          password="${password}"
442
          src="${build.src}/loaddtdschema.sql" />
443
   </target>
444

    
445
   <target name="schemasql" depends="prepare"
446
            description="Registers the Schema with the new Metacat instance">
447
     <echo/>
448
     <echo>Registering the Schema with the new Metacat instance...</echo>
449
     <sql driver="${dbDriver}"
450
          classpath="${jdbc}:${jdbc-add1}:${jdbc-add2}"
451
          url="${jdbc-connect}"
452
          userid="${user}"
453
          password="${password}"
454
          src="${build.src}/loadschema.sql" />
455
   </target>
456
   
457
   <target name="installdb" depends="prepare"
458
            description="Installs the database tables">
459
     <echo/>
460
     <echo>Installing the database tables...</echo>
461
     <sql driver="${dbDriver}"
462
          classpath="${jdbc}:${jdbc-add1}:${jdbc-add2}"
463
          url="${jdbc-connect}"
464
          userid="${user}"
465
          password="${password}"
466
          src="${build.src}/xmltables.sql" />
467
   </target>
468

    
469
   <target name="upgrade12" depends="prepare"
470
            description="Updates the database tables to upgrade to version 1.2">
471
     <echo/>
472
     <echo>Updating the database tables to upgrade to version 1.2...</echo>
473
     <sql driver="${dbDriver}"
474
          classpath="${jdbc}:${jdbc-add1}:${jdbc-add2}"
475
          url="${jdbc-connect}"
476
          userid="${user}"
477
          password="${password}"
478
          src="${build.src}/upgrade-db-to-1.2.sql" />
479
   </target>
480

    
481
   <target name="upgrade13" depends="prepare"
482
            description="Updates the database tables to upgrade to version 1.3">
483
     <echo/>
484
     <echo>Updating the database tables to upgrade to version 1.3...</echo>
485
     <sql driver="${dbDriver}"
486
          classpath="${jdbc}:${jdbc-add1}:${jdbc-add2}"
487
          url="${jdbc-connect}"
488
          userid="${user}"
489
          password="${password}"
490
          src="${build.src}/upgrade-db-to-1.3.sql" />
491
   </target>
492

    
493
   <target name="install" depends="war" description="* Full Install *">
494
       <mkdir dir="${datafilepath}" />
495
       <mkdir dir="${inlinedatafilepath}" />
496
       <chmod dir="${datafilepath}" perm="ug+w" />
497
       <mkdir dir="${temp-dir}"/>
498
       <chmod dir="${temp-dir}" perm="ug+w" />
499
       <copy file="${build.dir}/${context}.war" todir="${webapps}"/>
500
   </target>
501
   
502
   <target name="upgrade" depends="install" 
503
          description="* Upgrade an existing metacat installation with a new version *">
504
       <unwar src="${webapps}/${context}.war" dest="${webapps}/${context}" />
505
   </target>
506

    
507
   <target name="install-registry" depends="init,getConversionXSL" 
508
            description="Install Registry">
509
            
510
      <copy file="${srcdir}/perl/register-dataset.cgi"
511
            todir="${inst.cgi.dir}" filtering="yes"/>
512
      <chmod file="${inst.cgi.dir}/register-dataset.cgi" perm="ugo+x" />
513
  
514
      <mkdir dir="${temp-dir}" />
515
     <copy todir="${temp-dir}" filtering="yes">
516
       <fileset dir="${build.tmp}/${conversion-module}/lib/style">
517
         <include name="*.xsl"/>
518
         <include name="*.xml"/>
519
       </fileset>
520
     </copy>
521

    
522
      <echo message="Install Registry completed." />
523
   </target>
524

    
525
   <target name="war" depends="warPrepare,warMSSQL"
526
            description="Create a web archive (WAR) for servlet deployment">
527
       <war destfile="${build.dir}/${context}.war" 
528
            webxml="${build.war}/web.xml">
529
         <fileset dir="${war.context}"/>
530
         <lib dir="${war.lib}"/>
531
         <webinf dir="${war.webinf}"/>
532
       </war>
533
   </target>
534

    
535
   <target name="warPrepare" depends="jar,clientjar"
536
            description="Prepare files for creating a web archive (WAR)">
537

    
538
       <property name="war.lib" value="${build.war}/lib" />
539
       <property name="war.webinf" value="${build.war}/WEB-INF" />
540
       <property name="war.context" value="${build.war}/${context}" />
541
       <mkdir dir="${war.lib}" />
542
       <mkdir dir="${war.webinf}" />
543
       <mkdir dir="${war.context}" />
544

    
545
       <copy file="${build.dir}/${name}.jar" todir="${war.lib}" />
546
       <copy file="${build.dir}/${name}-client.jar" todir="${war.lib}" />
547
       <copy todir="${war.lib}" filtering="no">
548
         <fileset dir="lib">
549
           <include name="*.jar"/>
550
         </fileset>
551
         <fileset dir="lib/xalan">
552
           <include name="*.jar"/>
553
         </fileset>
554
       </copy>
555
       <copy file="${jdbc}" tofile="${war.lib}/jdbc.jar" />
556
       <copy file="lib/web.xml.${tomcatversion}"
557
             tofile="${build.war}/web.xml" />
558
       <copy file="lib/metacat.properties" todir="${war.webinf}"
559
             filtering="yes" />
560
       <copy todir="${war.context}" filtering="no">
561
         <fileset dir="lib">
562
           <include name="**/*.jpg"/>
563
           <include name="**/*.png"/>
564
           <include name="**/*.gif"/>
565
         </fileset>
566
       </copy>
567
       <copy todir="${war.context}" filtering="yes">
568
         <fileset dir="lib">
569
           <exclude name="*.jar"/>
570
           <exclude name="*.properties"/>
571
           <exclude name="web.xml"/>
572
           <exclude name="**/srbrmi*"/>
573
           <exclude name="**/*.jpg"/>
574
           <exclude name="**/*.png"/>
575
           <exclude name="**/*.gif"/>
576
         </fileset>
577
       </copy>
578
       <copy todir="${war.context}" filtering="no">
579
         <fileset dir="lib">
580
           <include name="**/*.jpg"/>
581
           <include name="**/*.png"/>
582
           <include name="**/*.gif"/>
583
         </fileset>
584
       </copy>
585
   </target>
586

    
587
   <target name="warMSSQL" if="MSSQL" depends="warPrepare">
588
      <copy file="${jdbc-add1}" tofile="${war.lib}/msutil.jar" />
589
       <copy file="${jdbc-add2}" tofile="${war.lib}/mssqlserver.jar" />
590
   </target>
591

    
592
   <target name="getConversionXSL" depends="prepare" 
593
            unless="styles.not.needed"
594
            description="Gets the conversion stylesheets for eml2 beta 6 to eml 2.0.0">
595
     <echo>Enter CVS password: </echo>
596
     <cvs cvsRoot="${cvsroot-alternate}"
597
          package="${conversion-module}"
598
          dest="${build.tmp}" />
599
   </target>
600

    
601
   <target name="testprep" depends="jar,clientjar">
602
      <mkdir dir="${build.tests}"/>
603
      <copy todir="${build.tests}" filtering="yes">
604
        <fileset dir="${testdir}">
605
          <include name="edu/**"/>
606
        </fileset>
607
      </copy>
608
      <!-- copy and compile the tests into a jar file -->
609
      <javac srcdir="${build.tests}"
610
             destdir="${build.tests}"
611
             classpath="${cpath}:${build.dir}/${name}.jar:${build.dir}/${name}-client.jar"
612
             debug="on"
613
       includes="**/*.java" />
614

    
615
      <jar jarfile="${build.dir}/${name}-junittests.jar"
616
        basedir="${build.tests}"
617
                includes="**/*.class" />
618
   </target>
619

    
620
   <target name="test" depends="testprep"
621
            description="Uses the ant junit task to run all JUnit tests">
622

    
623
      <!-- use the ant "junit" task to run JUnit tests. -->
624
      <junit printsummary="yes" haltonfailure="no" fork="yes"
625
             haltonerror="no">
626
        <jvmarg value="-Djava.protocol.handler.pkgs=HTTPClient"/>
627
        <classpath>
628
          <pathelement path="${cpath}:${build.dir}/${name}.jar:${build.dir}/${name}-client.jar:${build.dir}/${name}-junittests.jar" />
629
        </classpath>
630

    
631
        <formatter type="plain" />
632

    
633
        <batchtest fork="yes" todir="${build.dir}">
634
          <fileset dir="${build.tests}">
635
            <include name="**/*.class" />
636
          </fileset>
637
        </batchtest>
638
     </junit>
639
   </target>
640

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

    
644
              <echo>testtorun: ${testtorun}</echo>
645

    
646
      <!-- use the ant "junit" task to run JUnit tests. -->
647
      <junit printsummary="yes" haltonfailure="no" fork="yes"
648
             haltonerror="no">
649
        <jvmarg value="-Djava.protocol.handler.pkgs=HTTPClient"/>
650
        <classpath>
651
          <pathelement path="${cpath}:${build.dir}/${name}.jar:${build.dir}/${name}-client.jar:${build.dir}/${name}-junittests.jar" />
652
        </classpath>
653

    
654
        <formatter type="plain" />
655

    
656
        <batchtest fork="yes" todir="${build.dir}">
657
          <fileset dir="${build.tests}">
658
            <include name="**/${testtorun}.class" />
659
          </fileset>
660
        </batchtest>
661
     </junit>
662
   </target>
663

    
664
  <target name="gethttpclient" depends="prepare"
665
            description="checks out and compiles morpho httpclient code">
666
  <!--mkdir dir="${morphosourcedir}" -->
667
        <cvs cvsRoot="${cvsroot}"
668
             package="morpho"
669
             dest="." />
670
        <ant dir="${morphosourcedir}" inheritAll="false"  target="jar" />
671
   </target>
672

    
673
   <!-- run this target, we need to check out a another morpho souce dir was checked out. -->
674
   <target name="nettest" depends="install"
675
            description="compiles and runs the metacatnettest code">
676
            
677
      <echo>***********************************
678
      Please run ant gethttpclient first!
679
      ***********************************
680
      </echo>
681
      <!-- copy and compile the tests into a jar file -->
682
      <mkdir dir="${build.metacatnettest}"/>
683
      <javac srcdir="${junitnettestsdir}"
684
             destdir="${build.metacatnettest}"
685
             classpath="${cpath}:${build.dir}/${name}.jar:${httpclient}"
686
             includes="**/*.java" />
687

    
688
      <jar jarfile="${build.dir}/${name}-junitnettests.jar"
689
                    basedir="${build.metacatnettest}"
690
                    includes="**/*.class" />
691

    
692
      <!-- use the ant "junit" task to run JUnit tests. -->
693
      <junit printsummary="yes" haltonfailure="no" fork="yes"
694
             haltonerror="no">
695
        <jvmarg value="-Djava.protocol.handler.pkgs=HTTPClient" />
696
        <classpath>
697
          <pathelement path="${cpath}:${build.dir}/${name}.jar:${httpclient}:${build.dir}/${name}-junitnettests.jar:${itislib}" />
698
        </classpath>
699

    
700
        <formatter type="plain" />
701

    
702
        <batchtest fork="yes" todir="${build.dir}">
703
          <fileset dir="${build.metacatnettest}">
704
            <include name="**/*.class" />
705
          </fileset>
706
        </batchtest>
707
     </junit>
708
   </target>
709

    
710
   <target name="cleanweb" depends="clean"
711
            description="deletes tomcat web context dir and all its contents">
712
     <delete dir="${installdir}" />
713
   </target>
714

    
715

    
716
   <target name="clean" depends="init"
717
            description="deletes build dir and any files copied to cvs sandbox by build process (jars, xsl) Currently *not* schema/DTDs">
718
       <delete dir="${build.dir}" />
719
       <delete file="lib/httpclient.jar" />
720
       <delete file="lib/utilities.jar" />
721
       <delete includeEmptyDirs="true" failonerror="false">
722
         <fileset dir="${style-common-cvsrelpath}">
723
           <include name="${eml-css}" />
724
           <include name="eml-*/*.xsl" />
725
           <include name="eml-*" />
726
         </fileset>
727
     </delete>
728
   </target>
729

    
730
   <target name="jdoc" depends="prepare"
731
            description="generates javadoc documentation">
732
       <javadoc packagenames="edu.ucsb.nceas.*"
733
           sourcepath="${build.src}"
734
           destdir="${build.javadocs}"
735
           author="true"
736
           version="true"
737
           use="true"
738
           windowtitle="${Name} API"
739
           doctitle="&lt;h1&gt;${Name}&lt;/h1&gt;"
740
           bottom="&lt;i&gt;Copyright &#169; 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.&lt;/i&gt;"
741
       />
742
   </target>
743

    
744
   <target name="dist" depends="jar,protocol,jdoc,geteml"
745
            description="prepares a full release distribution">
746
      <mkdir dir="${dist.dir}"/>
747
      <delete dir="${ver.dir}" />
748
      <mkdir dir="${ver.dir}"/>
749
      <copy todir="${ver.dir}">
750
        <fileset dir="."
751
            excludes="**/CVS* **/.#* **/src* **/test* **/build* **/docs* ${dist.dir}"/>
752
      </copy>
753
      <copy todir="${ver.dir}" file="build.xml"/>
754
      <copy todir="${ver.dir}/lib" file="${build.dir}/metacat.jar"/>
755
      <copy todir="${ver.dir}/lib" file="${build.dir}/protocol.jar"/>
756

    
757
      <copy todir="${ver.dir}/docs" filtering="yes">
758
        <fileset dir="docs" excludes="**/*gif **/*jpg **/*png" />
759
      </copy>
760
      <copy todir="${ver.dir}/docs" filtering="no">
761
        <fileset dir="docs" includes="**/*gif **/*jpg **/*png" />
762
      </copy>
763
      <copy todir="${ver.dir}/docs/dev">
764
        <fileset dir="${build.dir}/docs"/>
765
      </copy>
766
      <copy todir="${ver.dir}/src">
767
        <fileset dir="${build.dir}/src"/>
768
      </copy>
769

    
770
      <delete dir="./${ver.dir}/${build.dir}"/>
771
      <delete dir="./${ver.dir}/dist"/>
772
      <delete file="./${name}-${release}.zip"/>
773
      <zip zipfile="./${name}-${release}.zip" basedir="${dist.dir}" excludes="${name}-${release}/src/**, ${name}-${release}/build/src/**"/>
774
      <delete file="./${name}-${release}.tar.gz" />
775
      <tar tarfile="./${name}-${release}.tar" basedir="${dist.dir}" excludes="${name}-${release}/src/**, ${name}-${release}/build/src/**"/>
776
      <gzip zipfile="./${name}-${release}.tar.gz"
777
                src="./${name}-${release}.tar"/>
778
      <delete file="./${name}-${release}.tar" />
779
  </target>
780

    
781
  <target name="distsrc" depends="dist"
782
            description="prepares a source distribution">
783
      <mkdir dir="${ver.src}"/>
784
      <copy todir="${ver.src}">
785
        <fileset dir="./src"/>
786
      </copy>
787

    
788
      <delete file="./${name}-src-${release}.zip"/>
789
      <zip zipfile="./${name}-src-${release}.zip" basedir="${dist.dir}"/>
790
      <delete file="./${name}-src-${release}.tar.gz" />
791
      <tar tarfile="./${name}-src-${release}.tar" basedir="${dist.dir}"/>
792
      <gzip zipfile="./${name}-src-${release}.tar.gz"
793
                src="./${name}-src-${release}.tar"/>
794
      <delete file="./${name}-src-${release}.tar" />
795
      <delete dir="${dist.dir}"/>
796
  </target>
797

    
798
   <target name="stylesheettest">
799
     <xslt in="${input}" out="eml.html" style="${style-common-cvsrelpath}/eml-2.0.0/eml-2.0.0.xsl">
800
      <param name="displaymodule" expression="${displaymodule}"/>
801
      <param name="docid" expression="${input}"/>
802
      <param name="entitytype" expression="${entitytype}"/>
803
      <param name="entityindex" expression="${entityindex}"/>
804
      <outputproperty name="method" value="html"/>
805
      <outputproperty name="standalone" value="yes"/>
806
      <outputproperty name="encoding" value="iso8859_1"/>
807
      <outputproperty name="indent" value="yes"/>
808
    </xslt>
809
  </target>
810
  
811
 <target name="gridinit" depends="init">
812
   <property name="java2wsdl.tool" value="org.apache.axis.wsdl.Java2WSDL" />
813
   <property name="wsdldecorator.tool" value="org.globus.ogsa.tools.wsdl.DecorateWSDL" />
814
   <property name="wsdl.tool" value="org.globus.ogsa.tools.wsdl.GSDL2Java"/>
815
   <property environment="env"/>
816
   <property name="binding.file" value="${env.GLOBUS_LOCATION}/schema/ogsi/ogsi_bindings.wsdl"/>
817
    <path id="webservicepath">
818
        <pathelement location="."/>
819
        <pathelement location="${env.JAVA_HOME}/../lib/tools.jar"/>
820
        <pathelement location="${build.dest}"/>
821
        <fileset dir="${env.GLOBUS_LOCATION}/lib">
822
           <include name="*.jar"/>
823
        </fileset>
824
      </path>
825
</target>
826

    
827
 <target name="gridprepare" depends="gridinit, prepare">
828
 </target> 
829
  
830
  <target name="compileinterface" depends="clean, gridprepare">
831
    <javac srcdir="${build.src}" destdir="${build.dest}" includes="**/${interface.name}.java" />
832
  </target>
833
  
834
  <target name="generateWSDL" depends="compileinterface">
835
    <echo message="Generating wsdl from ${interface.name} interface"/>
836
    <java classname="${java2wsdl.tool}"
837
          dir="${build.src}" fork="yes"
838
          classpathref="webservicepath"  failonerror="true" >
839
      <arg value="-P"/>
840
      <arg value="${interface.name}PortType"/>
841
      <arg value="-S"/>
842
      <arg value="${interface.name}Service"/>
843
      <arg value="-y"/>
844
      <arg value="WRAPPED"/>
845
      <arg value="-u"/>
846
      <arg value="LITERAL"/>
847
      <arg value="-l"/>
848
      <arg value="http://localhost/ogsa/services/${interface.name}Service"/>
849
      <arg value="-n"/>
850
      <arg value="http://${services.namespace}/${interface.name}"/>
851
      <arg value="${interface.package}.${interface.name}"/>
852
    </java>
853
  </target>
854
  
855
   <target name="decorateWSDL" depends="generateWSDL">
856
      <property name="wsdl.file" value="${interface.name}Service.wsdl"/>
857
      <java classname="${wsdldecorator.tool}" dir="${build.src}"
858
            fork="yes"
859
            classpathref="webservicepath" failonerror="true" >
860
        <arg value="${binding.file}"/>
861
        <arg value="${wsdl.file}"/>
862
      </java>
863
   </target>
864
   
865
   <target name="generatestubs" depends="decorateWSDL">
866
      <echo message=" Generating stubs " />
867
      <echo message="wsdl file is ${wsdl.file}"/>
868
      <echo message="build.src is ${build.src}"/>
869
      <java classname="${wsdl.tool}" dir="${build.src}" fork="yes"
870
            classpathref="webservicepath" failonerror="true" >
871
         <arg value="${wsdl.file}"/>
872
    </java>
873
  </target>
874
  
875
  <target name="compileStubsAndImpl" depends="generatestubs, utilities">
876
     <echo message=" Compiling stubs " />
877
     <javac srcdir="${build.src}" destdir="${build.dest}" classpathref="webservicepath" includes="**/${interface.name}/*.java" />
878
     <echo message=" Compiling impl " />
879
     <javac srcdir="${build.src}" destdir="${build.dest}" classpathref="webservicepath" classpath="./lib/utilities.jar" includes="**/impl/*.java" />
880
  </target>
881
  
882
  <target name="jarStubsAndImpl" depends="compileStubsAndImpl">
883
     <echo message=" jar stubs classes " />
884
     <jar destfile="${build.dir}/${interface.name}-stubs.jar" basedir="${build.dest}" includes="**/${interface.name}/*.class" />
885
     <echo message=" jar impl classes " />
886
     <jar destfile="${build.dir}/${interface.name}.jar" basedir="${build.dest}" includes="**/impl/*.class" />
887
  </target>
888
  
889
  <target name="gar" depends="jarStubsAndImpl">
890
     <echo message=" jar the gar file"/>
891
     <mkdir dir="${build.dir}/gar"/>
892
     <mkdir dir="${build.dir}/gar/schema/edu"/>
893
     <copy file="${build.dir}/${interface.name}.jar" todir="${build.dir}/gar" />
894
     <copy file="${build.dir}/${interface.name}-stubs.jar" todir="${build.dir}/gar" />
895
     <copy file="lib/utilities.jar" todir="${build.dir}/gar" />
896
     <copy file="lib/server-deploy.wsdd" todir="${build.dir}/gar" />
897
     <copy file="${build.src}/${interface.name}Service.wsdl" todir="${build.dir}/gar/schema/edu" />
898
     <jar destfile="lib/${interface.name}.gar" basedir="${build.dir}/gar"/>
899
  </target>
900
  
901
  <target name="compilewebclient" depends="prepare">
902
     <javac srcdir="${build.src}" destdir="${build.dest}" includes="**/application/*.java" classpathref="webservicepath" />
903
  </target>
904
  
905
  <target name="runwebclient" depends="compilewebclient">
906
     <java classname="edu.ucsb.nceas.metacat.stringclient.application.MetacatStringServiceApplication" 
907
           dir="${build.dest}" fork="yes"
908
           classpathref="webservicepath" classpath="./lib/utilities.jar" failonerror="true">
909
         <arg value="${serviceUrl}"/>
910
         <arg value="${docid}"/>
911
     </java>
912
  </target>
913
</project>
(5-5/5)