Project

General

Profile

metacat / build.xml @ 2127

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: costa $'
10
  *    '$Date: 2004-04-13 10:54:09 -0700 (Tue, 13 Apr 2004) $'
11
  *    '$Revision: 2118 $'
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
     <property name="install-sql" 
57
               value="xmltables.sql" />
58
     <property name="upgrade-1.2-sql" 
59
               value="upgrade-db-to-1.2.sql" />
60
     <property name="upgrade-1.3-sql" 
61
               value="upgrade-db-to-1.3.sql" />
62
     <property name="upgrade-1.4-sql" 
63
               value="upgrade-db-to-1.4.sql" />
64
   </target>
65

    
66
   <target name="postgresql" if="use-postgresql">
67
     <!-- Customize these properties if you are using postgres -->
68
     <echo message="Using PostgreSQL..."/>
69
     <property name="dbDriver" value="org.postgresql.Driver"/>
70
     <property name="dbAdapter"
71
               value="edu.ucsb.nceas.dbadapter.PostgresqlAdapter"/>
72
     <property name="jdbc" value="lib/jdbc7.1-1.2.jar" />
73
     <!-- Property to indicate is not MSSQL installation-->
74
     <property name="other" value="yes"/>
75
     <property name="install-sql" 
76
               value="xmltables_postgres.sql" />
77
     <property name="upgrade-1.2-sql" 
78
               value="upgrade-db-to-1.2_postgres.sql" />
79
     <property name="upgrade-1.3-sql" 
80
               value="upgrade-db-to-1.3_postgres.sql" />
81
     <property name="upgrade-1.4-sql" 
82
               value="upgrade-db-to-1.4_postgres.sql" />
83
    </target>
84
   
85
   <target name="sqlserver" if="use-sqlserver">
86
     <!-- Customize these properties if you are using SQL server -->
87
     <echo message="Using SQL Server..."/>
88
     <property name="dbDriver" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
89
     <property name="dbAdapter"
90
               value="edu.ucsb.nceas.dbadapter.SqlserverAdapter"/>
91
     <property name="jdbc" value="${jdbc-base}/msbase.jar" />
92
     <property name="jdbc-add1" value="${jdbc-base}/msutil.jar" />
93
     <property name="jdbc-add2" value="${jdbc-base}/mssqlserver.jar" />
94
     <!-- Property to indicate is a MSSQL installation-->
95
     <property name="MSSQL" value="yes"/>
96
     <property name="install-sql" 
97
               value="xmltables-sqlserver.sql" />
98
   </target>
99

    
100
   <target name="config" depends="check-db,oracle,postgresql,sqlserver">
101
      <!-- usr for client testing, generally you don't need change-->
102
      <property name="mcuser" value="uid=tao,o=NCEAS,dc=ecoinformatics,dc=org"/>
103
      <property name="mcpassword" value=""/>
104
      <property name="mcanotheruser" value="uid=jtao,o=LTER,dc=ecoinformatics,dc=org"/>
105
      <property name="mcanotherpassword" value=""/>
106

    
107
      <property name="debug" value="on" />
108
      <property name="debuglevel" value="55" />
109

    
110
      <property name="morphosourcedir" value="../morpho" />
111
      <property name="defaultcontenttype" value="application/octet-stream" />
112
      <property name="utilitiesdir" value="../utilities" />
113
    
114
      <!-- Make sure these paths match the location of the jar files
115
           on your system, the defaults should usually work -->
116
      <condition property="jsdk" value="${tomcat}/lib/common/servlet.jar">
117
        <equals arg1="${tomcatversion}" arg2="tomcat3" />
118
      </condition>
119
      <condition property="jsdk" value="${tomcat}/common/lib/servlet.jar">
120
        <equals arg1="${tomcatversion}" arg2="tomcat4" />
121
      </condition>
122
      <condition property="jsdk" value="${tomcat}/common/lib/servlet-api.jar">
123
        <equals arg1="${tomcatversion}" arg2="tomcat5" />
124
      </condition>
125
      <echo>*********** tomcatversion = ${tomcatversion}</echo>
126
      <echo>*********** set jsdk to ${jsdk}</echo>
127
      <property name="xmlp"
128
                value="lib/xercesImpl.jar" />
129
      <property name="cos"
130
                value="lib/cos.jar" />
131
      <property name="morpho"
132
                value="lib/morpho.jar" />
133
      <property name="xalan"
134
                value="lib/xalan/xalan.jar" />
135
      <property name="apis"
136
                value="lib/xalan/xml-apis.jar" />
137
      <property name="httpclient"
138
                value="lib/httpclient.jar" />
139
      <property name="emlparser"
140
                value="lib/eml.jar" />
141
      <property name="configxml"
142
                value="lib/configxml.jar" />
143
      <property name="itislib"
144
                value="lib/itislib.jar" />
145
      <property name="emlparser"
146
      
147
                value="lib/eml.jar" />
148
      <property name="util"
149
                value="lib/utilities.jar" />
150
  </target>
151

    
152
   <target name="init" depends="config">
153
      <!-- It is less likely you'll need to make any changes from here down,
154
           but customization is possible -->
155
      <property name="installdir"          value="${webapps}/${context}" />
156
      <property name="temp-dir"            value="/tmp/${context}" />
157
      <property name="name"                value="metacat"/>
158
      <property name="Name"                value="MetaCat"/>
159
      <property name="debugprefix"         value="${Name}:"/>
160
      <property name="release"             value="1.4.0"/>
161
      <property name="replication-path"    value="/${context}/servlet/replication"/>
162
      <property name="servlet-path"        value="/${context}/metacat"/>
163
      <property name="html-path"           value="/${context}"/>
164
      <property name="systemidserver"      value="http://${server}"/>
165
      <property name="style-common-relpath" 
166
                                           value="/style/common"/>
167
      <property name="style-common-cvsrelpath" 
168
                                           value="lib${style-common-relpath}"/>
169
      <property name="style-common-fullpath" 
170
                                           value="/${installdir}${style-common-relpath}"/>
171
      <property name="style-common-path" 
172
                                           value="/${context}${style-common-relpath}"/>
173
      <property name="style-skins-relpath" value="/style/skins"/>
174
      <property name="style-skins-path"    value="/${context}${style-skins-relpath}"/>
175
      <property name="replication-log"     value="/tmp/metacatreplication.log"/>
176
      <property name="replicationerrorlog" value="/tmp/metacatreplication.err"/>
177
      <property name="config-dir"          value="${webapps}/${style-skins-path}" />
178
      <property name="eml-module"          value="eml" />
179
      <property name="eml-version"         value="2.0.0beta6" />
180
      <property name="eml-tag"             value="EML_2_0_0_BETA_6_FOR_METACAT" />
181
      <property name="eml2-tag"            value="EML_2_0_0_FOR_METACAT" />
182
      <property name="eml2namespace"       value="eml://ecoinformatics.org/eml-2.0.0" />
183
      <property name="stmmlnamespace"      value="http://www.xml-cml.org/schema/stmml" />
184
      <property name="eml-css"             value="eml_xsl.css"/>
185
      <property name="eml-module.default.css"
186
                                           value="default.css"/>
187
      <property name="conversion-module"   value="webmdentry" />
188

    
189
      <!-- Config for registry variables -->
190
      <property name="scope"               value="obfs"/>
191
      <property name="responseForm"        value="genericResponse.tmpl"/>
192
      <property name="entryForm"           value="entryForm.tmpl"/>
193
      <property name="guide"               value="genericGuide.tmpl"/>
194
      <property name="confirmData" value="confirmData.tmpl"/>
195
      <property name="deleteData" value="deleteData.tmpl"/>
196
      <property name="genericHeader" value="genericHeader.tmpl"/>
197
      <property name="genericFooter" value="genericFooter.tmpl"/>
198
      <property name="adminname" value="KNB Support"/>
199
      <property name="recipient" value="knb-software\@nceas.ucsb.edu"/>
200
      <filter token="scope" value="${scope}"/>
201
      <filter token="responseForm" value="${responseForm}"/>
202
      <filter token="entryForm" value="${entryForm}"/>
203
      <filter token="guide" value="${guide}"/>      
204
      <filter token="confirmData" value="${confirmData}"/>
205
      <filter token="deleteData" value="${deleteData}"/>
206
      <filter token="genericHeader" value="${genericHeader}"/>
207
      <filter token="genericFooter" value="${genericFooter}"/>
208
      <filter token="adminname" value="${adminname}"/>
209
      <filter token="recipient" value="${recipient}"/>
210

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

    
214
      <filter token="docrooturl" value="./" />
215
      <filter token="jdbc-connect" value="${jdbc-connect}"/>
216
      <filter token="dbDriver" value="${dbDriver}"/>
217
      <filter token="dbAdapter" value="${dbAdapter}"/>
218
      <filter token="install-dir" value="${installdir}"/>
219
      <filter token="temp-dir" value="${temp-dir}"/>
220
      <filter token="server" value="${server}"/>
221
      <filter token="systemidserver" value="${systemidserver}"/>
222
      <filter token="cgi-prefix" value="${cgi-prefix}"/>
223
      <filter token="ldapUrl" value="${ldapUrl}"/>
224
      <filter token="replication-log" value="${replication-log}"/>
225
      <filter token="replicationerrorlog" value="${replicationerrorlog}"/>
226
      <filter token="release" value="${release}"/>
227
      <filter token="servlet-path" value="${servlet-path}"/>
228
      <filter token="html-path" value="${html-path}"/>
229
      <filter token="user" value="${user}"/>
230
      <filter token="password" value="${password}"/>
231
      <filter token="mcuser" value="${mcuser}"/>
232
      <filter token="mcpassword" value="${mcpassword}"/>
233
      <filter token="mcanotheruser" value="${mcanotheruser}"/>
234
      <filter token="mcanotherpassword" value="${mcanotherpassword}"/>
235
      <filter token="knb-site-url" value="${knb-site-url}"/>
236
      <filter token="eml-css" value="${eml-css}"/>
237
      <filter token="style-skins-relpath" value="${style-skins-relpath}"/>
238
      <filter token="style-skins-path" value="${style-skins-path}"/>
239
      <filter token="style-common-relpath" value="${style-common-relpath}"/>
240
      <filter token="style-common-fullpath" value="${style-common-fullpath}"/>
241
      <filter token="style-common-path" value="${style-common-path}"/>
242
      <!-- The "style-path" filter is used by the eml xsl stylesheets!!  -->
243
      <filter token="style-path" value="${style-skins-path}"/>
244
      <filter token="replication-path" value="${replication-path}"/>
245
      <filter token="config-dir" value="${config-dir}"/>
246
      <filter token="default-style" value="${default-style}"/>
247
      <filter token="eml-version" value="${eml-version}"/>
248
      <filter token="eml2namespace" value="${eml2namespace}"/>
249
      <filter token="stmmlnamespace" value="${stmmlnamespace}"/>
250
      <filter token="context" value="${context}"/>
251
      <filter token="forcereplicationwaitingtime" value="${forcereplicationwaitingtime}" />
252
      <filter token="debuglevel" value="${debuglevel}" />
253
      <filter token="datafilepath" value="${datafilepath}" />
254
      <filter token="inlinedatafilepath" value="${inlinedatafilepath}" />
255
      <filter token="defaultcontenttype" value="${defaultcontenttype}" />
256
      <filter token="debugprefix" value="${debugprefix}"/>
257

    
258
      <property name="srcdir" value="./src" />
259
      <property name="testdir" value="./test" />
260
      <property name="testtorun" value="MetacatClientTest" />
261
      <property name="junittestsdir" value="./test/edu/ucsb/nceas/metacattest" />
262
      <property name="junitnettestsdir" value="./test/edu/ucsb/nceas/metacatnettest" />
263
      <property name="build.dir" value="./build"/>
264
      <property name="build.src" value="${build.dir}/src"/>
265
      <property name="build.dest" value="${build.dir}/classes"/>
266
      <property name="build.docs" value="${build.dir}/docs"/>
267
      <property name="build.samples" value="${build.dir}/samples"/>
268
      <property name="build.tests" value="${build.dir}/tests"/>
269
      <property name="build.tmp" value="${build.dir}/tmp"/>
270
      <property name="build.metacattest" value="${build.tests}/metacattest"/>
271
      <property name="build.metacatnettest" value="${build.tests}/metacatnettest"/>
272
      <property name="build.data" value="${build.dir}/data"/>
273
      <property name="build.javadocs" value="${build.dir}/docs/api"/>
274
      <property name="build.war" value="${build.dir}/war"/>
275

    
276
      <property name="dist.dir" value="dist"/>
277
      <property name="ver.dir" value="${dist.dir}/${name}-${release}"/>
278
      <property name="ver.src" value="${ver.dir}/src"/>
279

    
280
      <property name="package.home" value="edu/ucsb/nceas/metacat" />
281
   </target>
282

    
283
   <target name="prepare" depends="init">
284
      <mkdir dir="${build.dir}"/>
285
      <mkdir dir="${build.src}"/>
286
      <mkdir dir="${build.dest}"/>
287
      <mkdir dir="${build.javadocs}"/>
288
      <mkdir dir="${build.tmp}"/>
289

    
290
      <copy todir="${build.src}" filtering="yes">
291
        <fileset dir="${srcdir}">
292
          <include name="edu/**"/>
293
          <include name="com/**"/>
294
          <include name="**/*.sql"/>
295
          <exclude name="**/CVS*"/>
296
          <exclude name="**/.#*"/>
297
        </fileset>
298
      </copy>
299
      <available file="build/tmp/${conversion-module}" type="dir" 
300
                 property="styles.not.needed"/>
301
   </target>
302

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

    
306
       <javac srcdir="${build.src}"
307
              destdir="${build.dest}"
308
              classpath="${cpath}"
309
              debug="${debug}"
310
              excludes="**/*.sql **/stringclient/** **/client/*.java"/>
311
   </target>
312

    
313
   <target name="jar" depends="compile"
314
    description="Compiles and jars metacat java code to metacat.jar in build dir">
315

    
316
       <delete file="${build.dir}/${name}.jar" />
317
       <jar jarfile="${build.dir}/${name}.jar" basedir="${build.dest}"
318
            excludes="**/protocols/" />
319
   </target>
320

    
321
   <target name="protocol" depends="compile"
322
    description="Compiles and jars protocol java code to protocol.jar in build dir">
323
       <delete file="${build.dir}/protocol.jar" />
324
       <jar jarfile="${build.dir}/protocol.jar" basedir="${build.dest}"
325
            includes="**/protocols/" />
326
   </target>
327

    
328
   <target name="utilities" depends="config">
329
     <ant dir="${utilitiesdir}" target="clean" inheritAll="false" />
330
     <ant dir="${utilitiesdir}" target="jar" inheritAll="false" />
331
     <copy file="${utilitiesdir}/lib/httpclient.jar" todir="lib" />
332
     <copy file="${utilitiesdir}/build/utilities.jar" todir="lib" />
333
   </target>
334

    
335
   <target name="client" depends="utilities, prepare"
336
    description="Compiles metacat-client java code to build dir">
337
       <javac srcdir="${build.src}"
338
              destdir="${build.dest}"
339
              classpath="${cpath}"
340
              includes="edu/ucsb/nceas/metacat/client/*" />
341
   </target>
342

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

    
350
   <target name="harvester" depends="client"
351
           description="Compiles harvester java code to build dir">
352
       <echo message="classpath is:   ${cpath}"/>
353
       <javac srcdir="${build.src}"
354
              destdir="${build.dest}"
355
              classpath="${cpath}"
356
              includes="edu/ucsb/nceas/metacat/harvesterClient/*" />
357
       <copy file="lib/harvester/harvesterDocument.xsd" todir="${build.dest}" />
358
   </target>
359

    
360
   <target name="harvesterjar" depends="harvester"
361
           description="Compiles and jars harvester java code to harvester.jar in build dir">
362
       <delete file="${build.dir}/harvester.jar" />
363
       <jar jarfile="${build.dir}/harvester.jar" basedir="${build.dest}"
364
            includes="**/metacat/harvesterClient/" />
365
   </target>
366

    
367
   <target  name="geteml" depends="getemlpre2,geteml2+" 
368
            description="Calls getemlpre2 and geteml2+ targets" />
369

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

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

    
416
   <target  name="copyxsl" 
417
   description="Copies xsl stylesheets from checkout in build/tmp to your metacat cvs sandbox">
418

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

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

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

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

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

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

    
497
   <target name="upgrade14" depends="prepare"
498
            description="Updates the database tables to upgrade to version 1.4">
499
     <echo/>
500
     <echo>Updating the database tables to upgrade to version 1.4...</echo>
501
     <sql driver="${dbDriver}"
502
          classpath="${jdbc}:${jdbc-add1}:${jdbc-add2}"
503
          url="${jdbc-connect}"
504
          userid="${user}"
505
          password="${password}"
506
          src="${build.src}/${upgrade-1.4-sql}" />
507
   </target>
508

    
509
   <target name="install" depends="war" description="* Full Install *">
510
       <mkdir dir="${datafilepath}" />
511
       <mkdir dir="${inlinedatafilepath}" />
512
       <chmod dir="${datafilepath}" perm="ug+w" />
513
       <mkdir dir="${temp-dir}"/>
514
       <chmod dir="${temp-dir}" perm="ug+w" />
515
       <copy file="${build.dir}/${context}.war" todir="${webapps}"/>
516
   </target>
517
   
518
   <target name="upgrade" depends="install" 
519
          description="* Upgrade an existing metacat installation with a new version *">
520
       <unwar src="${webapps}/${context}.war" dest="${webapps}/${context}" />
521
   </target>
522

    
523
   <target name="install-registry" depends="init,getConversionXSL" 
524
            description="Install Registry">
525
            
526
      <copy file="${srcdir}/perl/register-dataset.cgi"
527
            todir="${inst.cgi.dir}" filtering="yes"/>
528
      <chmod file="${inst.cgi.dir}/register-dataset.cgi" perm="ugo+x" />
529
  
530
      <mkdir dir="${temp-dir}" />
531
     <copy todir="${temp-dir}" filtering="yes">
532
       <fileset dir="${build.tmp}/${conversion-module}/lib/style">
533
         <include name="*.xsl"/>
534
         <include name="*.xml"/>
535
       </fileset>
536
     </copy>
537

    
538
      <echo message="Install Registry completed." />
539
   </target>
540

    
541
   <target name="install-skin" depends="init" 
542
            description="Install a Skin">
543

    
544
      <input message="Please enter name of the skin" 
545
             addproperty="skin-name"/>
546

    
547
      <mkdir dir="${installdir}/style/skins/${skin-name}" />
548
      <copy todir="${installdir}/style/skins/${skin-name}" filtering="yes">
549
       <fileset dir="lib/style/skins/${skin-name}">
550
           <include name="*.*"/>
551
           <exclude name="*.png"/>
552
           <exclude name="*.gif"/>
553
       </fileset>
554
      </copy>
555
     <copy todir="${installdir}/style/skins/${skin-name}" filtering="no">
556
       <fileset dir="lib/style/skins/${skin-name}">
557
           <include name="*.png"/>
558
           <include name="*.gif"/>
559
       </fileset>
560
      </copy>
561

    
562
      <echo message="Install Skin completed." />
563
   </target>
564

    
565
   <target name="war" depends="warPrepare,warMSSQL"
566
            description="Create a web archive (WAR) for servlet deployment">
567
       <war destfile="${build.dir}/${context}.war" 
568
            webxml="${build.war}/web.xml">
569
         <fileset dir="${war.context}"/>
570
         <lib dir="${war.lib}"/>
571
         <webinf dir="${war.webinf}"/>
572
       </war>
573
   </target>
574

    
575
   <target name="warPrepare" depends="jar,clientjar,harvesterjar"
576
            description="Prepare files for creating a web archive (WAR)">
577

    
578
       <property name="war.lib" value="${build.war}/lib" />
579
       <property name="war.webinf" value="${build.war}/WEB-INF" />
580
       <property name="war.context" value="${build.war}/${context}" />
581
       <mkdir dir="${war.lib}" />
582
       <mkdir dir="${war.webinf}" />
583
       <mkdir dir="${war.context}" />
584

    
585
       <copy file="${build.dir}/${name}.jar" todir="${war.lib}" />
586
       <copy file="${build.dir}/${name}-client.jar" todir="${war.lib}" />
587
       <copy file="${build.dir}/harvester.jar" todir="${war.lib}" />
588
       <copy todir="${war.lib}" filtering="no">
589
         <fileset dir="lib">
590
           <include name="*.jar"/>
591
         </fileset>
592
         <fileset dir="lib/xalan">
593
           <include name="*.jar"/>
594
         </fileset>
595
       </copy>
596
       <copy file="${jdbc}" tofile="${war.lib}/jdbc.jar" />
597
       <copy file="lib/web.xml.${tomcatversion}"
598
             tofile="${build.war}/web.xml" />
599
       <copy file="lib/metacat.properties" todir="${war.webinf}"
600
             filtering="yes" />
601
       <copy todir="${war.context}" filtering="no">
602
         <fileset dir="lib">
603
           <include name="**/*.jpg"/>
604
           <include name="**/*.png"/>
605
           <include name="**/*.gif"/>
606
         </fileset>
607
       </copy>
608
       <copy todir="${war.context}" filtering="yes">
609
         <fileset dir="lib">
610
           <exclude name="*.jar"/>
611
           <exclude name="*.properties"/>
612
           <exclude name="web.xml"/>
613
           <exclude name="**/*.jpg"/>
614
           <exclude name="**/*.png"/>
615
           <exclude name="**/*.gif"/>
616
         </fileset>
617
       </copy>
618
       <copy todir="${war.context}" filtering="no">
619
         <fileset dir="lib">
620
           <include name="**/*.jpg"/>
621
           <include name="**/*.png"/>
622
           <include name="**/*.gif"/>
623
         </fileset>
624
       </copy>
625
   </target>
626

    
627
   <target name="warMSSQL" if="MSSQL" depends="warPrepare">
628
      <copy file="${jdbc-add1}" tofile="${war.lib}/msutil.jar" />
629
       <copy file="${jdbc-add2}" tofile="${war.lib}/mssqlserver.jar" />
630
   </target>
631

    
632
   <target name="getConversionXSL" depends="prepare" 
633
            unless="styles.not.needed"
634
            description="Gets the conversion stylesheets for eml2 beta 6 to eml 2.0.0">
635
     <echo>Enter CVS password: </echo>
636
     <cvs cvsRoot="${cvsroot-alternate}"
637
          package="${conversion-module}"
638
          dest="${build.tmp}" />
639
   </target>
640

    
641
   <target name="testprep" depends="jar,clientjar">
642
      <mkdir dir="${build.tests}"/>
643
      <copy todir="${build.tests}" filtering="yes">
644
        <fileset dir="${testdir}">
645
          <include name="edu/**"/>
646
        </fileset>
647
      </copy>
648
      <!-- copy and compile the tests into a jar file -->
649
      <javac srcdir="${build.tests}"
650
             destdir="${build.tests}"
651
             classpath="${cpath}:${build.dir}/${name}.jar:${build.dir}/${name}-client.jar"
652
             debug="on"
653
       includes="**/*.java" />
654

    
655
      <jar jarfile="${build.dir}/${name}-junittests.jar"
656
        basedir="${build.tests}"
657
                includes="**/*.class" />
658
   </target>
659

    
660
   <target name="test" depends="testprep"
661
            description="Uses the ant junit task to run all JUnit tests">
662

    
663
      <!-- use the ant "junit" task to run JUnit tests. -->
664
      <junit printsummary="yes" haltonfailure="no" fork="yes"
665
             haltonerror="no">
666
        <jvmarg value="-Djava.protocol.handler.pkgs=HTTPClient"/>
667
        <classpath>
668
          <pathelement path="${cpath}:${build.dir}/${name}.jar:${build.dir}/${name}-client.jar:${build.dir}/${name}-junittests.jar" />
669
        </classpath>
670

    
671
        <formatter type="plain" />
672

    
673
        <batchtest fork="yes" todir="${build.dir}">
674
          <fileset dir="${build.tests}">
675
            <include name="**/*.class" />
676
          </fileset>
677
        </batchtest>
678
     </junit>
679
   </target>
680

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

    
684
              <echo>testtorun: ${testtorun}</echo>
685

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

    
694
        <formatter type="plain" />
695

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

    
704
  <target name="gethttpclient" depends="prepare"
705
            description="checks out and compiles morpho httpclient code">
706
  <!--mkdir dir="${morphosourcedir}" -->
707
        <cvs cvsRoot="${cvsroot}"
708
             package="morpho"
709
             dest="." />
710
        <ant dir="${morphosourcedir}" inheritAll="false"  target="jar" />
711
   </target>
712

    
713
   <!-- run this target, we need to check out a another morpho souce dir was checked out. -->
714
   <target name="nettest" depends="install"
715
            description="compiles and runs the metacatnettest code">
716
            
717
      <echo>***********************************
718
      Please run ant gethttpclient first!
719
      ***********************************
720
      </echo>
721
      <!-- copy and compile the tests into a jar file -->
722
      <mkdir dir="${build.metacatnettest}"/>
723
      <javac srcdir="${junitnettestsdir}"
724
             destdir="${build.metacatnettest}"
725
             classpath="${cpath}:${build.dir}/${name}.jar:${httpclient}"
726
             includes="**/*.java" />
727

    
728
      <jar jarfile="${build.dir}/${name}-junitnettests.jar"
729
                    basedir="${build.metacatnettest}"
730
                    includes="**/*.class" />
731

    
732
      <!-- use the ant "junit" task to run JUnit tests. -->
733
      <junit printsummary="yes" haltonfailure="no" fork="yes"
734
             haltonerror="no">
735
        <jvmarg value="-Djava.protocol.handler.pkgs=HTTPClient" />
736
        <classpath>
737
          <pathelement path="${cpath}:${build.dir}/${name}.jar:${httpclient}:${build.dir}/${name}-junitnettests.jar:${itislib}" />
738
        </classpath>
739

    
740
        <formatter type="plain" />
741

    
742
        <batchtest fork="yes" todir="${build.dir}">
743
          <fileset dir="${build.metacatnettest}">
744
            <include name="**/*.class" />
745
          </fileset>
746
        </batchtest>
747
     </junit>
748
   </target>
749

    
750
   <target name="cleanweb" depends="clean"
751
            description="deletes tomcat web context dir and all its contents">
752
     <delete dir="${installdir}" />
753
   </target>
754

    
755

    
756
   <target name="clean" depends="init"
757
            description="deletes build dir and any files copied to cvs sandbox by build process (jars, xsl) Currently *not* schema/DTDs">
758
       <delete dir="${build.dir}" />
759
       <delete file="lib/httpclient.jar" />
760
       <delete file="lib/utilities.jar" />
761
       <delete includeEmptyDirs="true" failonerror="false">
762
         <fileset dir="${style-common-cvsrelpath}">
763
           <include name="${eml-css}" />
764
           <include name="eml-*/*.xsl" />
765
           <include name="eml-*" />
766
         </fileset>
767
     </delete>
768
   </target>
769

    
770
   <target name="jdoc" depends="prepare"
771
            description="generates javadoc documentation">
772
       <javadoc packagenames="edu.ucsb.nceas.*"
773
           sourcepath="${build.src}"
774
           destdir="${build.javadocs}"
775
           author="true"
776
           version="true"
777
           use="true"
778
           windowtitle="${Name} API"
779
           doctitle="&lt;h1&gt;${Name}&lt;/h1&gt;"
780
           bottom="&lt;i&gt;Copyright &#169; 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.&lt;/i&gt;"
781
       />
782
   </target>
783

    
784
   <target name="dist" depends="jar,protocol,jdoc,geteml"
785
            description="prepares a full release distribution">
786
      <mkdir dir="${dist.dir}"/>
787
      <delete dir="${ver.dir}" />
788
      <mkdir dir="${ver.dir}"/>
789
      <copy todir="${ver.dir}">
790
        <fileset dir="."
791
            excludes="**/CVS* **/.#* **/src* **/test* **/build* **/docs* ${dist.dir}"/>
792
      </copy>
793
      <copy todir="${ver.dir}" file="build.xml"/>
794
      <copy todir="${ver.dir}/lib" file="${build.dir}/metacat.jar"/>
795
      <copy todir="${ver.dir}/lib" file="${build.dir}/protocol.jar"/>
796

    
797
      <copy todir="${ver.dir}/docs" filtering="yes">
798
        <fileset dir="docs" excludes="**/*gif **/*jpg **/*png" />
799
      </copy>
800
      <copy todir="${ver.dir}/docs" filtering="no">
801
        <fileset dir="docs" includes="**/*gif **/*jpg **/*png" />
802
      </copy>
803
      <copy todir="${ver.dir}/docs/dev">
804
        <fileset dir="${build.dir}/docs"/>
805
      </copy>
806
      <copy todir="${ver.dir}/src">
807
        <fileset dir="${build.dir}/src"/>
808
      </copy>
809

    
810
      <delete dir="./${ver.dir}/${build.dir}"/>
811
      <delete dir="./${ver.dir}/dist"/>
812
      <delete file="./${name}-${release}.zip"/>
813
      <zip zipfile="./${name}-${release}.zip" basedir="${dist.dir}" excludes="${name}-${release}/src/**, ${name}-${release}/build/src/**"/>
814
      <delete file="./${name}-${release}.tar.gz" />
815
      <tar tarfile="./${name}-${release}.tar" basedir="${dist.dir}" excludes="${name}-${release}/src/**, ${name}-${release}/build/src/**"/>
816
      <gzip zipfile="./${name}-${release}.tar.gz"
817
                src="./${name}-${release}.tar"/>
818
      <delete file="./${name}-${release}.tar" />
819
  </target>
820

    
821
  <target name="distsrc" depends="dist"
822
            description="prepares a source distribution">
823
      <mkdir dir="${ver.src}"/>
824
      <copy todir="${ver.src}">
825
        <fileset dir="./src"/>
826
      </copy>
827

    
828
      <delete file="./${name}-src-${release}.zip"/>
829
      <zip zipfile="./${name}-src-${release}.zip" basedir="${dist.dir}"/>
830
      <delete file="./${name}-src-${release}.tar.gz" />
831
      <tar tarfile="./${name}-src-${release}.tar" basedir="${dist.dir}"/>
832
      <gzip zipfile="./${name}-src-${release}.tar.gz"
833
                src="./${name}-src-${release}.tar"/>
834
      <delete file="./${name}-src-${release}.tar" />
835
      <delete dir="${dist.dir}"/>
836
  </target>
837

    
838
   <target name="stylesheettest">
839
     <xslt in="${input}" out="eml.html" style="${style-common-cvsrelpath}/eml-2.0.0/eml-2.0.0.xsl">
840
      <param name="displaymodule" expression="${displaymodule}"/>
841
      <param name="docid" expression="${input}"/>
842
      <param name="entitytype" expression="${entitytype}"/>
843
      <param name="entityindex" expression="${entityindex}"/>
844
      <outputproperty name="method" value="html"/>
845
      <outputproperty name="standalone" value="yes"/>
846
      <outputproperty name="encoding" value="iso8859_1"/>
847
      <outputproperty name="indent" value="yes"/>
848
    </xslt>
849
  </target>
850
  
851
 <target name="gridinit" depends="init">
852
   <property name="java2wsdl.tool" value="org.apache.axis.wsdl.Java2WSDL" />
853
   <property name="wsdldecorator.tool" value="org.globus.ogsa.tools.wsdl.DecorateWSDL" />
854
   <property name="wsdl.tool" value="org.globus.ogsa.tools.wsdl.GSDL2Java"/>
855
   <property environment="env"/>
856
   <property name="binding.file" value="${env.GLOBUS_LOCATION}/schema/ogsi/ogsi_bindings.wsdl"/>
857
    <path id="webservicepath">
858
        <pathelement location="."/>
859
        <pathelement location="${env.JAVA_HOME}/../lib/tools.jar"/>
860
        <pathelement location="${build.dest}"/>
861
        <fileset dir="${env.GLOBUS_LOCATION}/lib">
862
           <include name="*.jar"/>
863
        </fileset>
864
      </path>
865
</target>
866

    
867
 <target name="gridprepare" depends="gridinit, prepare">
868
 </target> 
869
  
870
  <target name="compileinterface" depends="clean, gridprepare">
871
    <javac srcdir="${build.src}" destdir="${build.dest}" includes="**/${interface.name}.java" />
872
  </target>
873
  
874
  <target name="generateWSDL" depends="compileinterface">
875
    <echo message="Generating wsdl from ${interface.name} interface"/>
876
    <java classname="${java2wsdl.tool}"
877
          dir="${build.src}" fork="yes"
878
          classpathref="webservicepath"  failonerror="true" >
879
      <arg value="-P"/>
880
      <arg value="${interface.name}PortType"/>
881
      <arg value="-S"/>
882
      <arg value="${interface.name}Service"/>
883
      <arg value="-y"/>
884
      <arg value="WRAPPED"/>
885
      <arg value="-u"/>
886
      <arg value="LITERAL"/>
887
      <arg value="-l"/>
888
      <arg value="http://localhost/ogsa/services/${interface.name}Service"/>
889
      <arg value="-n"/>
890
      <arg value="http://${services.namespace}/${interface.name}"/>
891
      <arg value="${interface.package}.${interface.name}"/>
892
    </java>
893
  </target>
894
  
895
   <target name="decorateWSDL" depends="generateWSDL">
896
      <property name="wsdl.file" value="${interface.name}Service.wsdl"/>
897
      <java classname="${wsdldecorator.tool}" dir="${build.src}"
898
            fork="yes"
899
            classpathref="webservicepath" failonerror="true" >
900
        <arg value="${binding.file}"/>
901
        <arg value="${wsdl.file}"/>
902
      </java>
903
   </target>
904
   
905
   <target name="generatestubs" depends="decorateWSDL">
906
      <echo message=" Generating stubs " />
907
      <echo message="wsdl file is ${wsdl.file}"/>
908
      <echo message="build.src is ${build.src}"/>
909
      <java classname="${wsdl.tool}" dir="${build.src}" fork="yes"
910
            classpathref="webservicepath" failonerror="true" >
911
         <arg value="${wsdl.file}"/>
912
    </java>
913
  </target>
914
  
915
  <target name="compileStubsAndImpl" depends="generatestubs, utilities">
916
     <echo message=" Compiling stubs " />
917
     <javac srcdir="${build.src}" destdir="${build.dest}" classpathref="webservicepath" includes="**/${interface.name}/*.java" />
918
     <echo message=" Compiling impl " />
919
     <javac srcdir="${build.src}" destdir="${build.dest}" classpathref="webservicepath" classpath="./lib/utilities.jar" includes="**/impl/*.java" />
920
  </target>
921
  
922
  <target name="jarStubsAndImpl" depends="compileStubsAndImpl">
923
     <echo message=" jar stubs classes " />
924
     <jar destfile="${build.dir}/${interface.name}-stubs.jar" basedir="${build.dest}" includes="**/${interface.name}/*.class" />
925
     <echo message=" jar impl classes " />
926
     <jar destfile="${build.dir}/${interface.name}.jar" basedir="${build.dest}" includes="**/impl/*.class" />
927
  </target>
928
  
929
  <target name="gar" depends="jarStubsAndImpl">
930
     <echo message=" jar the gar file"/>
931
     <mkdir dir="${build.dir}/gar"/>
932
     <mkdir dir="${build.dir}/gar/schema/edu"/>
933
     <copy file="${build.dir}/${interface.name}.jar" todir="${build.dir}/gar" />
934
     <copy file="${build.dir}/${interface.name}-stubs.jar" todir="${build.dir}/gar" />
935
     <copy file="lib/utilities.jar" todir="${build.dir}/gar" />
936
     <copy file="lib/server-deploy.wsdd" todir="${build.dir}/gar" />
937
     <copy file="${build.src}/${interface.name}Service.wsdl" todir="${build.dir}/gar/schema/edu" />
938
     <jar destfile="lib/${interface.name}.gar" basedir="${build.dir}/gar"/>
939
  </target>
940
  
941
  <target name="compilewebclient" depends="prepare">
942
     <javac srcdir="${build.src}" destdir="${build.dest}" includes="**/application/*.java" classpathref="webservicepath" />
943
  </target>
944
  
945
  <target name="runwebclient" depends="compilewebclient">
946
     <java classname="edu.ucsb.nceas.metacat.stringclient.application.MetacatStringServiceApplication" 
947
           dir="${build.dest}" fork="yes"
948
           classpathref="webservicepath" classpath="./lib/utilities.jar" failonerror="true">
949
         <arg value="${serviceUrl}"/>
950
         <arg value="${docid}"/>
951
     </java>
952
  </target>
953
</project>