Project

General

Profile

metacat / build.xml @ 2052

1
<?xml version="1.0"?>
2
<!--
3
  *   '$RCSfile$'
4
  *     Authors: Matt Jones, Chad Berkley, Jivka Bojilova
5
  *   Copyright: 2000 Regents of the University of California and the
6
  *              National Center for Ecological Analysis and Synthesis
7
  * For Details: http://www.nceas.ucsb.edu/
8
  *
9
  *    '$Author: sgarg $'
10
  *    '$Date: 2004-03-17 15:04:40 -0800 (Wed, 17 Mar 2004) $'
11
  *    '$Revision: 2052 $'
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="100" />
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="install-skin" depends="init" 
522
            description="Install a Skin">
523

    
524
      <input message="Please enter name of the skin" 
525
             addproperty="skin-name"/>
526

    
527
      <mkdir dir="${installdir}/style/skins/${skin-name}" />
528
      <copy todir="${installdir}/style/skins/${skin-name}" filtering="yes">
529
       <fileset dir="lib/style/skins/${skin-name}">
530
         <include name="*.*"/>
531
       </fileset>
532
      </copy>
533

    
534
      <echo message="Install Skin completed." />
535
   </target>
536

    
537
   <target name="war" depends="warPrepare,warMSSQL"
538
            description="Create a web archive (WAR) for servlet deployment">
539
       <war destfile="${build.dir}/${context}.war" 
540
            webxml="${build.war}/web.xml">
541
         <fileset dir="${war.context}"/>
542
         <lib dir="${war.lib}"/>
543
         <webinf dir="${war.webinf}"/>
544
       </war>
545
   </target>
546

    
547
   <target name="warPrepare" depends="jar,clientjar"
548
            description="Prepare files for creating a web archive (WAR)">
549

    
550
       <property name="war.lib" value="${build.war}/lib" />
551
       <property name="war.webinf" value="${build.war}/WEB-INF" />
552
       <property name="war.context" value="${build.war}/${context}" />
553
       <mkdir dir="${war.lib}" />
554
       <mkdir dir="${war.webinf}" />
555
       <mkdir dir="${war.context}" />
556

    
557
       <copy file="${build.dir}/${name}.jar" todir="${war.lib}" />
558
       <copy file="${build.dir}/${name}-client.jar" todir="${war.lib}" />
559
       <copy todir="${war.lib}" filtering="no">
560
         <fileset dir="lib">
561
           <include name="*.jar"/>
562
         </fileset>
563
         <fileset dir="lib/xalan">
564
           <include name="*.jar"/>
565
         </fileset>
566
       </copy>
567
       <copy file="${jdbc}" tofile="${war.lib}/jdbc.jar" />
568
       <copy file="lib/web.xml.${tomcatversion}"
569
             tofile="${build.war}/web.xml" />
570
       <copy file="lib/metacat.properties" todir="${war.webinf}"
571
             filtering="yes" />
572
       <copy todir="${war.context}" filtering="no">
573
         <fileset dir="lib">
574
           <include name="**/*.jpg"/>
575
           <include name="**/*.png"/>
576
           <include name="**/*.gif"/>
577
         </fileset>
578
       </copy>
579
       <copy todir="${war.context}" filtering="yes">
580
         <fileset dir="lib">
581
           <exclude name="*.jar"/>
582
           <exclude name="*.properties"/>
583
           <exclude name="web.xml"/>
584
           <exclude name="**/*.jpg"/>
585
           <exclude name="**/*.png"/>
586
           <exclude name="**/*.gif"/>
587
         </fileset>
588
       </copy>
589
       <copy todir="${war.context}" filtering="no">
590
         <fileset dir="lib">
591
           <include name="**/*.jpg"/>
592
           <include name="**/*.png"/>
593
           <include name="**/*.gif"/>
594
         </fileset>
595
       </copy>
596
   </target>
597

    
598
   <target name="warMSSQL" if="MSSQL" depends="warPrepare">
599
      <copy file="${jdbc-add1}" tofile="${war.lib}/msutil.jar" />
600
       <copy file="${jdbc-add2}" tofile="${war.lib}/mssqlserver.jar" />
601
   </target>
602

    
603
   <target name="getConversionXSL" depends="prepare" 
604
            unless="styles.not.needed"
605
            description="Gets the conversion stylesheets for eml2 beta 6 to eml 2.0.0">
606
     <echo>Enter CVS password: </echo>
607
     <cvs cvsRoot="${cvsroot-alternate}"
608
          package="${conversion-module}"
609
          dest="${build.tmp}" />
610
   </target>
611

    
612
   <target name="testprep" depends="jar,clientjar">
613
      <mkdir dir="${build.tests}"/>
614
      <copy todir="${build.tests}" filtering="yes">
615
        <fileset dir="${testdir}">
616
          <include name="edu/**"/>
617
        </fileset>
618
      </copy>
619
      <!-- copy and compile the tests into a jar file -->
620
      <javac srcdir="${build.tests}"
621
             destdir="${build.tests}"
622
             classpath="${cpath}:${build.dir}/${name}.jar:${build.dir}/${name}-client.jar"
623
             debug="on"
624
       includes="**/*.java" />
625

    
626
      <jar jarfile="${build.dir}/${name}-junittests.jar"
627
        basedir="${build.tests}"
628
                includes="**/*.class" />
629
   </target>
630

    
631
   <target name="test" depends="testprep"
632
            description="Uses the ant junit task to run all JUnit tests">
633

    
634
      <!-- use the ant "junit" task to run JUnit tests. -->
635
      <junit printsummary="yes" haltonfailure="no" fork="yes"
636
             haltonerror="no">
637
        <jvmarg value="-Djava.protocol.handler.pkgs=HTTPClient"/>
638
        <classpath>
639
          <pathelement path="${cpath}:${build.dir}/${name}.jar:${build.dir}/${name}-client.jar:${build.dir}/${name}-junittests.jar" />
640
        </classpath>
641

    
642
        <formatter type="plain" />
643

    
644
        <batchtest fork="yes" todir="${build.dir}">
645
          <fileset dir="${build.tests}">
646
            <include name="**/*.class" />
647
          </fileset>
648
        </batchtest>
649
     </junit>
650
   </target>
651

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

    
655
              <echo>testtorun: ${testtorun}</echo>
656

    
657
      <!-- use the ant "junit" task to run JUnit tests. -->
658
      <junit printsummary="yes" haltonfailure="no" fork="yes"
659
             haltonerror="no">
660
        <!--<jvmarg value="-Djava.protocol.handler.pkgs=HTTPClient"/>-->
661
        <classpath>
662
          <pathelement path="${cpath}:${build.dir}/${name}.jar:${build.dir}/${name}-client.jar:${build.dir}/${name}-junittests.jar" />
663
        </classpath>
664

    
665
        <formatter type="plain" />
666

    
667
        <batchtest fork="yes" todir="${build.dir}">
668
          <fileset dir="${build.tests}">
669
            <include name="**/${testtorun}.class" />
670
          </fileset>
671
        </batchtest>
672
     </junit>
673
   </target>
674

    
675
  <target name="gethttpclient" depends="prepare"
676
            description="checks out and compiles morpho httpclient code">
677
  <!--mkdir dir="${morphosourcedir}" -->
678
        <cvs cvsRoot="${cvsroot}"
679
             package="morpho"
680
             dest="." />
681
        <ant dir="${morphosourcedir}" inheritAll="false"  target="jar" />
682
   </target>
683

    
684
   <!-- run this target, we need to check out a another morpho souce dir was checked out. -->
685
   <target name="nettest" depends="install"
686
            description="compiles and runs the metacatnettest code">
687
            
688
      <echo>***********************************
689
      Please run ant gethttpclient first!
690
      ***********************************
691
      </echo>
692
      <!-- copy and compile the tests into a jar file -->
693
      <mkdir dir="${build.metacatnettest}"/>
694
      <javac srcdir="${junitnettestsdir}"
695
             destdir="${build.metacatnettest}"
696
             classpath="${cpath}:${build.dir}/${name}.jar:${httpclient}"
697
             includes="**/*.java" />
698

    
699
      <jar jarfile="${build.dir}/${name}-junitnettests.jar"
700
                    basedir="${build.metacatnettest}"
701
                    includes="**/*.class" />
702

    
703
      <!-- use the ant "junit" task to run JUnit tests. -->
704
      <junit printsummary="yes" haltonfailure="no" fork="yes"
705
             haltonerror="no">
706
        <jvmarg value="-Djava.protocol.handler.pkgs=HTTPClient" />
707
        <classpath>
708
          <pathelement path="${cpath}:${build.dir}/${name}.jar:${httpclient}:${build.dir}/${name}-junitnettests.jar:${itislib}" />
709
        </classpath>
710

    
711
        <formatter type="plain" />
712

    
713
        <batchtest fork="yes" todir="${build.dir}">
714
          <fileset dir="${build.metacatnettest}">
715
            <include name="**/*.class" />
716
          </fileset>
717
        </batchtest>
718
     </junit>
719
   </target>
720

    
721
   <target name="cleanweb" depends="clean"
722
            description="deletes tomcat web context dir and all its contents">
723
     <delete dir="${installdir}" />
724
   </target>
725

    
726

    
727
   <target name="clean" depends="init"
728
            description="deletes build dir and any files copied to cvs sandbox by build process (jars, xsl) Currently *not* schema/DTDs">
729
       <delete dir="/usr/tomcat/webapps/knb-test" />
730
       <delete file="/usr/tomcat/webapps/knb-test.war" />
731
       <delete dir="${build.dir}" />
732
       <delete file="lib/httpclient.jar" />
733
       <delete file="lib/utilities.jar" />
734
       <delete includeEmptyDirs="true" failonerror="false">
735
         <fileset dir="${style-common-cvsrelpath}">
736
           <include name="${eml-css}" />
737
           <include name="eml-*/*.xsl" />
738
           <include name="eml-*" />
739
         </fileset>
740
     </delete>
741
   </target>
742

    
743
   <target name="jdoc" depends="prepare"
744
            description="generates javadoc documentation">
745
       <javadoc packagenames="edu.ucsb.nceas.*"
746
           sourcepath="${build.src}"
747
           destdir="${build.javadocs}"
748
           author="true"
749
           version="true"
750
           use="true"
751
           windowtitle="${Name} API"
752
           doctitle="&lt;h1&gt;${Name}&lt;/h1&gt;"
753
           bottom="&lt;i&gt;Copyright &#169; 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.&lt;/i&gt;"
754
       />
755
   </target>
756

    
757
   <target name="dist" depends="jar,protocol,jdoc,geteml"
758
            description="prepares a full release distribution">
759
      <mkdir dir="${dist.dir}"/>
760
      <delete dir="${ver.dir}" />
761
      <mkdir dir="${ver.dir}"/>
762
      <copy todir="${ver.dir}">
763
        <fileset dir="."
764
            excludes="**/CVS* **/.#* **/src* **/test* **/build* **/docs* ${dist.dir}"/>
765
      </copy>
766
      <copy todir="${ver.dir}" file="build.xml"/>
767
      <copy todir="${ver.dir}/lib" file="${build.dir}/metacat.jar"/>
768
      <copy todir="${ver.dir}/lib" file="${build.dir}/protocol.jar"/>
769

    
770
      <copy todir="${ver.dir}/docs" filtering="yes">
771
        <fileset dir="docs" excludes="**/*gif **/*jpg **/*png" />
772
      </copy>
773
      <copy todir="${ver.dir}/docs" filtering="no">
774
        <fileset dir="docs" includes="**/*gif **/*jpg **/*png" />
775
      </copy>
776
      <copy todir="${ver.dir}/docs/dev">
777
        <fileset dir="${build.dir}/docs"/>
778
      </copy>
779
      <copy todir="${ver.dir}/src">
780
        <fileset dir="${build.dir}/src"/>
781
      </copy>
782

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

    
794
  <target name="distsrc" depends="dist"
795
            description="prepares a source distribution">
796
      <mkdir dir="${ver.src}"/>
797
      <copy todir="${ver.src}">
798
        <fileset dir="./src"/>
799
      </copy>
800

    
801
      <delete file="./${name}-src-${release}.zip"/>
802
      <zip zipfile="./${name}-src-${release}.zip" basedir="${dist.dir}"/>
803
      <delete file="./${name}-src-${release}.tar.gz" />
804
      <tar tarfile="./${name}-src-${release}.tar" basedir="${dist.dir}"/>
805
      <gzip zipfile="./${name}-src-${release}.tar.gz"
806
                src="./${name}-src-${release}.tar"/>
807
      <delete file="./${name}-src-${release}.tar" />
808
      <delete dir="${dist.dir}"/>
809
  </target>
810

    
811
   <target name="stylesheettest">
812
     <xslt in="${input}" out="eml.html" style="${style-common-cvsrelpath}/eml-2.0.0/eml-2.0.0.xsl">
813
      <param name="displaymodule" expression="${displaymodule}"/>
814
      <param name="docid" expression="${input}"/>
815
      <param name="entitytype" expression="${entitytype}"/>
816
      <param name="entityindex" expression="${entityindex}"/>
817
      <outputproperty name="method" value="html"/>
818
      <outputproperty name="standalone" value="yes"/>
819
      <outputproperty name="encoding" value="iso8859_1"/>
820
      <outputproperty name="indent" value="yes"/>
821
    </xslt>
822
  </target>
823
  
824
 <target name="gridinit" depends="init">
825
   <property name="java2wsdl.tool" value="org.apache.axis.wsdl.Java2WSDL" />
826
   <property name="wsdldecorator.tool" value="org.globus.ogsa.tools.wsdl.DecorateWSDL" />
827
   <property name="wsdl.tool" value="org.globus.ogsa.tools.wsdl.GSDL2Java"/>
828
   <property environment="env"/>
829
   <property name="binding.file" value="${env.GLOBUS_LOCATION}/schema/ogsi/ogsi_bindings.wsdl"/>
830
    <path id="webservicepath">
831
        <pathelement location="."/>
832
        <pathelement location="${env.JAVA_HOME}/../lib/tools.jar"/>
833
        <pathelement location="${build.dest}"/>
834
        <fileset dir="${env.GLOBUS_LOCATION}/lib">
835
           <include name="*.jar"/>
836
        </fileset>
837
      </path>
838
</target>
839

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