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: cjones $'
10
  *    '$Date: 2004-01-30 12:44:25 -0800 (Fri, 30 Jan 2004) $'
11
  *    '$Revision: 2011 $'
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
      <condition property="jsdk" value="${tomcat}/common/lib/servlet-api.jar">
105
        <equals arg1="${tomcatversion}" arg2="tomcat5" />
106
      </condition>
107
      <echo>*********** tomcatversion = ${tomcatversion}</echo>
108
      <echo>*********** set jsdk to ${jsdk}</echo>
109
      <property name="xmlp"
110
                value="lib/xercesImpl.jar" />
111
      <property name="cos"
112
                value="lib/cos.jar" />
113
      <property name="morpho"
114
                value="lib/morpho.jar" />
115
      <property name="xalan"
116
                value="lib/xalan/xalan.jar" />
117
      <property name="apis"
118
                value="lib/xalan/xml-apis.jar" />
119
      <property name="httpclient"
120
                value="lib/httpclient.jar" />
121
      <property name="emlparser"
122
                value="lib/eml.jar" />
123
      <property name="configxml"
124
                value="lib/configxml.jar" />
125
      <property name="itislib"
126
                value="lib/itislib.jar" />
127
      <property name="emlparser"
128
      
129
                value="lib/eml.jar" />
130
      <property name="util"
131
                value="lib/utilities.jar" />
132
  </target>
133

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

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

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

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

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

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

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

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

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

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

    
288
       <javac srcdir="${build.src}"
289
              destdir="${build.dest}"
290
              classpath="${cpath}"
291
              debug="${debug}"
292
              excludes="**/*.sql **/stringclient/** **/client/*.java"/>
293
   </target>
294

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

    
298
       <delete file="${build.dir}/${name}.jar" />
299
       <jar jarfile="${build.dir}/${name}.jar" basedir="${build.dest}"
300
            excludes="**/protocols/" />
301
   </target>
302

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

    
310
   <target name="utilities" depends="config">
311
     <ant dir="${utilitiesdir}" target="clean" inheritAll="false" />
312
     <ant dir="${utilitiesdir}" target="jar" inheritAll="false" />
313
     <copy file="${utilitiesdir}/lib/httpclient.jar" todir="lib" />
314
     <copy file="${utilitiesdir}/build/utilities.jar" todir="lib" />
315
   </target>
316

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

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

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

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

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

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

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

    
408
   <target  name="copyxsl" 
409
   description="Copies xsl stylesheets from checkout in build/tmp to your metacat cvs sandbox">
410

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

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

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

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

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

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

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

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

    
518
      <echo message="Install Registry completed." />
519
   </target>
520

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

    
531
   <target name="warPrepare" depends="jar,clientjar"
532
            description="Prepare files for creating a web archive (WAR)">
533

    
534
       <property name="war.lib" value="${build.war}/lib" />
535
       <property name="war.webinf" value="${build.war}/WEB-INF" />
536
       <property name="war.context" value="${build.war}/${context}" />
537
       <mkdir dir="${war.lib}" />
538
       <mkdir dir="${war.webinf}" />
539
       <mkdir dir="${war.context}" />
540

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

    
582
   <target name="warMSSQL" if="MSSQL" depends="warPrepare">
583
      <copy file="${jdbc-add1}" tofile="${war.lib}/msutil.jar" />
584
       <copy file="${jdbc-add2}" tofile="${war.lib}/mssqlserver.jar" />
585
   </target>
586

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

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

    
610
      <jar jarfile="${build.dir}/${name}-junittests.jar"
611
        basedir="${build.tests}"
612
                includes="**/*.class" />
613
   </target>
614

    
615
   <target name="test" depends="testprep"
616
            description="Uses the ant junit task to run all JUnit tests">
617

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

    
626
        <formatter type="plain" />
627

    
628
        <batchtest fork="yes" todir="${build.dir}">
629
          <fileset dir="${build.tests}">
630
            <include name="**/*.class" />
631
          </fileset>
632
        </batchtest>
633
     </junit>
634
   </target>
635

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

    
639
              <echo>testtorun: ${testtorun}</echo>
640

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

    
649
        <formatter type="plain" />
650

    
651
        <batchtest fork="yes" todir="${build.dir}">
652
          <fileset dir="${build.tests}">
653
            <include name="**/${testtorun}.class" />
654
          </fileset>
655
        </batchtest>
656
     </junit>
657
   </target>
658

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

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

    
683
      <jar jarfile="${build.dir}/${name}-junitnettests.jar"
684
                    basedir="${build.metacatnettest}"
685
                    includes="**/*.class" />
686

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

    
695
        <formatter type="plain" />
696

    
697
        <batchtest fork="yes" todir="${build.dir}">
698
          <fileset dir="${build.metacatnettest}">
699
            <include name="**/*.class" />
700
          </fileset>
701
        </batchtest>
702
     </junit>
703
   </target>
704

    
705
   <target name="cleanweb" depends="clean"
706
            description="deletes tomcat web context dir and all its contents">
707
     <delete dir="${installdir}" />
708
   </target>
709

    
710

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

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

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

    
752
      <copy todir="${ver.dir}/docs" filtering="yes">
753
        <fileset dir="docs" excludes="**/*gif **/*jpg **/*png" />
754
      </copy>
755
      <copy todir="${ver.dir}/docs" filtering="no">
756
        <fileset dir="docs" includes="**/*gif **/*jpg **/*png" />
757
      </copy>
758
      <copy todir="${ver.dir}/docs/dev">
759
        <fileset dir="${build.dir}/docs"/>
760
      </copy>
761
      <copy todir="${ver.dir}/src">
762
        <fileset dir="${build.dir}/src"/>
763
      </copy>
764

    
765
      <delete dir="./${ver.dir}/${build.dir}"/>
766
      <delete dir="./${ver.dir}/dist"/>
767
      <delete file="./${name}-${release}.zip"/>
768
      <zip zipfile="./${name}-${release}.zip" basedir="${dist.dir}" excludes="${name}-${release}/src/**, ${name}-${release}/build/src/**"/>
769
      <delete file="./${name}-${release}.tar.gz" />
770
      <tar tarfile="./${name}-${release}.tar" basedir="${dist.dir}" excludes="${name}-${release}/src/**, ${name}-${release}/build/src/**"/>
771
      <gzip zipfile="./${name}-${release}.tar.gz"
772
                src="./${name}-${release}.tar"/>
773
      <delete file="./${name}-${release}.tar" />
774
  </target>
775

    
776
  <target name="distsrc" depends="dist"
777
            description="prepares a source distribution">
778
      <mkdir dir="${ver.src}"/>
779
      <copy todir="${ver.src}">
780
        <fileset dir="./src"/>
781
      </copy>
782

    
783
      <delete file="./${name}-src-${release}.zip"/>
784
      <zip zipfile="./${name}-src-${release}.zip" basedir="${dist.dir}"/>
785
      <delete file="./${name}-src-${release}.tar.gz" />
786
      <tar tarfile="./${name}-src-${release}.tar" basedir="${dist.dir}"/>
787
      <gzip zipfile="./${name}-src-${release}.tar.gz"
788
                src="./${name}-src-${release}.tar"/>
789
      <delete file="./${name}-src-${release}.tar" />
790
      <delete dir="${dist.dir}"/>
791
  </target>
792

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

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