File: build.xml

package info (click to toggle)
jspwiki 2.0.52-12
  • links: PTS
  • area: contrib
  • in suites: sarge
  • size: 2,328 kB
  • ctags: 1,756
  • sloc: java: 13,848; jsp: 1,171; xml: 233; sh: 123; makefile: 54; perl: 31
file content (447 lines) | stat: -rw-r--r-- 14,974 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
<!--
    Copyright (C) Janne Jalkanen 2001.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-->

<!--
    This is the Ant build file for the JSPWiki project.

    The verbosity in this file is intentional - it is also
    an example for those who don't know Ant yet that well
    and would like to learn it.

    The build file assumes the following directory structure:

    JSPWiki
    |___build.xml
    |  
    |___etc
    |   |___[jspwiki.properties and web.xml]
    |          
    |___src     
    |   |___webdocs
    |   |   |___[all .jsp files]
    |   |       
    |   |___com 
    |       |___[...and the rest of the source code files]
    |
    |___docs
    |
    |___lib
    | 
    |___tests   
        |___com 
            |___[...and the rest of the test source code]
                  
    $Id: build.xml,v 1.26.2.1 2003/04/11 19:17:58 jalkanen Exp $
-->    
       
<!--   
    First, we define the project.  We assign it a name,
    and the default action if no action is specified on the
    command line.  Also, all relative directory references
    in the rest of the project file should be calculated from
    the current directory.
-->    
<project name="JSPWiki" default="compile" basedir=".">
       
  <!-- This denotes the directory where the source code lies. -->
  <property name="code.src" value="src" />
       
  <!-- The class files are actually put in this directory.  It is
       a good habit to keep .class -files separate from the .java -files. -->
  <property name="code.build" value ="build" />
       
  <!-- Define a temporary directory, based on the system temporary directory,
       the user name, and the project name (defined above) -->
  <property name="tmpdir" value="${java.io.tmpdir}/${user.name}/${ant.project.name}" />

  <!-- The following three properties define the location of the
       test sources, the location of the test .class files and the
       directory where the test results are written in. -->

  <property name="tests.src" value="tests" />
  <property name="tests.build" value="tests/build" />
  <property name="tests.reports" value="tests/reports" />

  <!-- The place where the javadocs are created -->

  <property name="docs.javadoc" value="doc/javadoc" />

  <!-- The temporary installation directory where all war-files 
       are collected, for example -->
  <property name="install.fulldir" value="${tmpdir}/install" />

  <!-- The directory where the CVS sources are checked out. -->
  <property name="install.src" value="${tmpdir}/cvssrc" />

  <!-- Define the CVS properties.  These are used when building the
       source distribution.  Normally, you shouldn't have to care about these. 
   -->
  <property name="cvs.root" value=":ext:grey.ecyrd.com:/p/cvs" />
  <property name="cvs.module" value="JSPWiki" />
  <property name="cvs.tag" value="JSPWIKI_2_0_BRANCH" />

  <!-- And finally, the directory where the final .zip-file is put -->
  <property name="release.dir" value="releases" />
  
  <!--  PATH DEFINITIONS -->

  <!-- The base path for compilation.  We include, of course, the
       already built files in the build-directory, and then we
       add all the jar files in the "lib" -directory. -->
  <path id="path.base">
     <pathelement path="${code.build}" />
     <fileset dir="lib">
        <include name="*.jar" />
     </fileset>
  </path>

  <!-- The path used for running tests.  We add the tests/etc directory
       to the base path defined above, since we put all the relevant
       .properties-files in tests/etc. -->
  <path id="path.tests">
      <pathelement path="${tests.src}/etc" />
      <path refid="path.base" />
  </path>

  <!-- ============================================================== -->

  <!-- Initialising, cleaning, etc. -->

  <target name="init" 
          description="Initializes everything, creates directories, etc.">
     <mkdir dir="${code.build}" />
     <mkdir dir="${tests.build}" />
     <mkdir dir="${tests.reports}" />
     <mkdir dir="${java.io.tmpdir}/testrepository" />
  </target>

  <!-- Removes the build directory and the tests build directory -->
  <target name="clean"
          description="Cleans away all generated files.">
    <delete dir="${tests.build}" />
    <delete dir="${code.build}" />
    <delete>
      <fileset dir="." includes="**/*~" defaultexcludes="no"/>
      <fileset dir="." includes="**/#*#" defaultexcludes="no"/>
    </delete>
  </target>

  <!-- ============================================================== -->

  <!-- Compilation targets -->

  <!-- In English this means that the "init" -target must be executed
       first.  After this, the java compiler is invoked with options
       that compile every .java file in ${code.src} into .class files
       in directory ${code.build}.  The is no debugging information
       and the compiler is instructed to optimize the resulting code.

       For the classpath we use the previously defined path called
       "path.base" -->

  <target name="compile" depends="init"
          description="Builds the source code.">
    <javac srcdir="${code.src}"
           destdir="${code.build}"
           debug="on"
           optimize="off">
      <classpath refid="path.base" />
    </javac>
  </target>

  <target name="compile-optimized" depends="clean,init"
          description="Builds the source code for distribution.">
    <javac srcdir="${code.src}"
           destdir="${code.build}"
           debug="off"
           optimize="on">
      <classpath refid="path.base" />
    </javac>
  </target>


  <!-- This is similar to above.  We use this to compile the
       tests. -->
  <target name="compiletests" depends="init"
          description="Builds the test code.">
    <javac srcdir="${tests.src}"
           destdir="${tests.build}">
      <classpath refid="path.base" />
    </javac>
  </target>

  <!-- Creates javadocs -->

  <!-- FIXME: Must not use constant package name! -->
  <target name="javadoc"
          description="Compiles the javadocs.">

    <mkdir dir="${docs.javadoc}" />

    <javadoc sourcepath="${code.src}"
             destdir="${docs.javadoc}"
             packagenames="com.ecyrd.jspwiki,com.ecyrd.jspwiki.plugin,com.ecyrd.jspwiki.rss,com.ecyrd.jspwiki.xmlrpc,com.ecyrd.jspwiki.tags,com.ecyrd.jspwiki.providers,com.ecyrd.jspwiki.attachment">
      <classpath refid="path.base" />
    </javadoc>
             
  </target>

  <!-- ============================================================== -->

  <!--  Installation targets -->

  <!-- This target makes sure all the necessary directories exist
       for building the installation package. -->
  <target name="installinit">
    <mkdir dir="${install.fulldir}" />
    <delete dir="${install.src}" />
    <mkdir dir="${install.src}" />
    <delete dir="${release.dir}" />
    <mkdir dir="${release.dir}" />
  </target>

  <!--  Builds the jar of all compiled class files -->

  <target name="jar" depends="compile,installinit">
      <property name="jarfile" value="${code.build}/${ant.project.name}.jar" />

      <jar jarfile="${jarfile}">
         <fileset dir="${code.build}" includes="**/*.class" />
      </jar>

  </target>

  <target name="jar-optimized" depends="compile-optimized,installinit">
      <property name="jarfile" value="${code.build}/${ant.project.name}.jar" />

      <jar jarfile="${jarfile}">
         <fileset dir="${code.build}" includes="**/*.class" />
      </jar>

  </target>

  <!--  Builds a Web Archive - basically a JAR file which
        also contains all of the JSP pages and can be deployed
        as-is. 
        
        The archive gets put in the ${install.fulldir}.  The 
        reason for this is that this is just a temporary
        step when building the entire distribution archive.

        We include the following things:

        1) All .jar -files in the lib-directory (except servlet.jar, since
           it's gonna be provided by the servlet container anyway.)
        2) All .class-files from the build-directory
        3) Everything from the src/webdocs -directory
        4) Everything from the etc-directory go to the WEB-INF -directory
           of the WAR-file.
   -->

  <target name="war" depends="installinit,jar"
          description="Builds the WAR file for installation.">

    <property name="warfile" value="${install.fulldir}/${ant.project.name}.war" />

    <delete file="${warfile}" />

    <war warfile="${install.fulldir}/${ant.project.name}.war"
         webxml="etc/web.xml">
       <lib dir="lib" includes="*.jar" excludes="servlet.jar,junit.jar"/>
       <lib dir="${code.build}" includes="*.jar" />
       <fileset dir="${code.src}/webdocs" includes="**" excludes="images/godiagram/**" />
       <webinf dir="etc" includes="**" />
    </war>

  </target>


  <target name="opened-war" depends="war"
   description="Creates an opened JSPWiki war hierarhcy into the build dir.">

    <mkdir dir="${code.build}/${ant.project.name}" />
    <unzip src="${install.fulldir}/${ant.project.name}.war"
           dest="${code.build}/${ant.project.name}" />

  </target>


  <!--
       Here goes some nice Ant magic...  We build the source
       code archive by directly exporting all code from the CVS
       repository, and then zipping it to the temporary installation
       directory.

       Note that you must have your CVS set up so that it does
       not ask for a password when you're checking it out.

       If you don't have CVS access, you can't build a source 
       zip with this.  Sorry.
   -->
  <target name="srczip" depends="installinit"
          description="Builds source zip.">

    <cvs cvsRoot="${cvs.root}" 
         dest="${install.src}" 
         package="${cvs.module}" 
         command="export" 
         tag="${cvs.tag}" />

    <zip zipfile="${release.dir}/${ant.project.name}-src.zip">
        <zipfileset dir="${install.src}" />
    </zip>

    <zip zipfile="${install.fulldir}/${ant.project.name}-samplepages.zip">
        <zipfileset dir="${install.src}/${ant.project.name}/src/wikipages" />
    </zip>

  </target>

  <!-- Builds the entire distribution set.

       We build both the WAR-file and the source zip, then
       copy in some useful files and zip the whole thing
       into the release directory.

       Note that if you don't have CVS access set up, you 
       probably can't run this.
    -->
  <target name="dist" depends="installinit,srczip,war"
          description="Builds the entire distribution archive.">
     <copy file="README" todir="${install.fulldir}" />
     <copy file="ChangeLog" todir="${install.fulldir}" />
     <copy file="ReleaseNotes" todir="${install.fulldir}" />
     <copy file="doc/LICENSE" todir="${install.fulldir}" />     

     <zip zipfile="${release.dir}/${ant.project.name}-bin.zip">
        <zipfileset dir="${install.fulldir}" prefix="${ant.project.name}" />
     </zip>

  </target>

  <!-- ============================================================== -->

  <!-- Running tests -->

  <!-- This target runs the JUnit tests that are available
       under tests/.  It generates the test result files
       into the ${tests.reports} -directory, one file per
       each tested class.  The tests are generated in
       plain text, but you can easily get XML format results
       as well, just by setting the formatter, below.

       Only tests that end with "*Test.java" are included.
       This is because then you can also use a manual
       "AllTests.java" in each directory, as per the JUnit
       Cookbook.

       This runs the tests in text mode.  If you want the
       pretty GUI you probably want to write a new target.
   -->
  <target name="tests" depends="compile,compiletests"
          description="Runs the JUnit tests.">

    <junit printsummary="yes" haltonfailure="no" fork="no">
        <classpath>
           <path refid="path.tests" />
           <pathelement path="${tests.build}" />
           <pathelement path="${java.class.path}" />
        </classpath>

        <formatter type="plain" />

        <batchtest todir="${tests.reports}">
           <fileset dir="${tests.src}">
                <include name="**/*Test.java" />
                <exclude name="**/AllTest*java" />
           </fileset>
        </batchtest>
     </junit>

  </target>

  <target name="stresstests" depends="compile,compiletests"
          description="Runs the complete stress testing framework.">

    <junit printsummary="yes" haltonfailure="no" fork="no">
        <classpath>
           <path refid="path.tests" />
           <pathelement path="${tests.build}" />
           <pathelement path="${java.class.path}" />
        </classpath>

        <formatter type="plain" />

        <batchtest todir="${tests.reports}">
           <fileset dir="${tests.src}">
                <include name="**/StressTest*.java" />
           </fileset>
        </batchtest>
     </junit>

  </target>

<!--  Commented out since this kills some compiles on grey.
  <target name="report" depends="compile, compiletests">

    <mkdir dir="${tests.reports}/html" />
    <junit printsummary="yes" haltonfailure="no" fork="no">
        <classpath>
           <path refid="path.tests" />
           <pathelement path="${tests.build}" />
           <pathelement path="${java.class.path}" />
        </classpath>

        <formatter type="xml" />

        <batchtest todir="${tests.reports}">
           <fileset dir="${tests.src}">
                <include name="**/*Test.java" />
                <exclude name="**/AllTest*java" />
           </fileset>
        </batchtest>
     </junit>

     <junitreport todir="${tests.reports}/html">
        <fileset dir="${tests.reports}">
           <include name="TEST-*.xml"/>
        </fileset>
        <report format="frames" todir="${tests.reports}/html"/>
     </junitreport>

  </target>
-->

  <target name="guitests" depends="compile,compiletests"
          description="Runs the tests in a pretty window.">

     <java classname="junit.swingui.TestRunner"
           fork="true">
        <classpath>
           <path refid="path.tests" />
           <pathelement path="${tests.build}" />
           <pathelement path="${java.class.path}" />
        </classpath>

        <arg value="com.ecyrd.jspwiki.AllTests" />
     </java>
           

  </target>

</project>