File: cactus-sample-build.xml.txt

package info (click to toggle)
libgroboutils-java 5-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 9,396 kB
  • ctags: 11,186
  • sloc: java: 59,748; xml: 12,762; sh: 377; perl: 104; makefile: 20
file content (442 lines) | stat: -rw-r--r-- 17,628 bytes parent folder | download | duplicates (3)
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
<?xml version="1.0"?>

<!--
  =============================================================================
    Build file for the Cactus Servlet Sample subproject. It shows how to use
    Cactus for unit testing the Servlet API (Servlets, Filters and Taglibs).

    The following Ant tasks need to be available in your ant installation (i.e.
    the Ant task themselves and their dependent jars need to be put in
    ANT_HOME/lib):

        junit                  [REQUIRED] JUnit Ant task

    Check the build.properties file to find out what properties need to be set
    in order to successfully run this script.

    This script should be started with the following command line:

        ant <target>

    Run "ant -projecthelp" to get a list of available targets.
  =============================================================================
-->
<project name="Cactus Servlet Sample" default="dist" basedir=".">

    <!-- Give user a chance to override without editing this file
       (and without typing -D each time it compiles it) -->
  <property file="build.properties" />
  <property file="${user.home}/build.properties" />

  <!-- Global project properties -->
  <property name="project.name.text" value="Cactus Servlet Sample"/>
  <property name="project.name.file" value="cactus-sample-servlet"/>
  <property name="project.version" value="1.5"/>

  <!-- Prefix to add to all distributable files -->
  <property name="project.prefix" value="jakarta-"/>

  <!-- Generic properties -->
  <property name="year" value="2000-2003"/>
  <property name="debug" value="on"/>
  <property name="optimize" value="off"/>
  <property name="deprecation" value="off"/>

  <!-- Properties for the Cactus tests -->
  <property name="cactus.port" value="8080"/>

  <!-- Location where the logging properties files are located -->
  <property name="base.dir" location="."/>

  <!--
     ========================================================================
       Set the properties related to the source tree.
     ========================================================================
  -->
  <property name="src.dir" location="src"/>
  <property name="src.java.dir" location="${src.dir}/java"/>
  <property name="src.conf.dir" location="${src.dir}/conf"/>
  <property name="src.cactus.dir" location="${src.dir}/test-cactus"/>
  <property name="src.webapp.dir" location="${src.dir}/webapp"/>

  <!--
     ========================================================================
       Set the properties related to the target area
     ========================================================================
  -->
  <!-- Destination locations for the build -->
  <property name="target.dir" location="target"/>
  <property name="target.classes.dir" location="${target.dir}/classes"/>
  <property name="target.classes.java.dir"
      location="${target.classes.dir}/java"/>
  <property name="target.classes.cactus.dir"
      location="${target.classes.dir}/cactus"/>
  <property name="target.testreports.dir"
      location="${target.dir}/test-reports"/>

  <!-- Distribution directory, i.e. where the expanded distibutable files
       are located -->
  <property name="dist.dir" location="dist"/>

  <!--
     ========================================================================
       Set the properties related to the required libraries
     ========================================================================
  -->

  <!-- Libraries required for the sample project -->
  <property name="servlet.jar"
      location="../../lib/servletapi-2.2.jar"/>
  <!-- property name="jstl.jar"
      location="lib/jstl-1.0.2.jar"/ -->
  <!-- property name="standard.jar"
      location="lib/standard-1.0.2.jar"/ -->
  <path id="project.classpath">
    <pathelement location="${servlet.jar}"/>
    <!-- pathelement location="${jstl.jar}"/ -->
    <!-- pathelement location="${standard.jar}"/ -->
  </path>

  <!-- Libraries required for the Cactus tests -->
  <property name="aspectjrt.jar"
      location="../../lib/aspectjrt-1.1.1.jar"/>
  <property name="cactus.jar"
      location="../../lib/cactus-1.5.jar"/>
  <property name="cactus.ant.jar"
      location="../../lib/cactus-ant-1.5.jar"/>
  <property name="commons.httpclient.jar"
      location="../../lib/commons-httpclient-2.0-rc2.jar"/>
  <property name="commons.logging.jar"
      location="../../lib/commons-logging-1.0.3.jar"/>
  <property name="httpunit.jar"
      location="../../lib/httpunit-1.5.3.jar"/>
  <property name="junit.jar"
      location="../../lib/junit-3.8.1.jar"/>
  <property name="nekohtml.jar"
      location="../../lib/nekohtml-0.7.4.jar"/>

  <!-- This is optional and only needed if you wish to debug and use 
       Log4J for logging -->
  <property name="log4j.jar"
      location="../../lib/log4j-1.2.8.jar"/>

  <path id="cactus.classpath">
    <path refid="project.classpath"/>
    <pathelement location="${aspectjrt.jar}"/>
    <pathelement location="${cactus.jar}"/>
    <pathelement location="${cactus.ant.jar}"/>
    <pathelement location="${commons.httpclient.jar}"/>
    <pathelement location="${commons.logging.jar}"/>
    <pathelement location="${junit.jar}"/>
  </path>

  <!--
     ========================================================================
       Initialize the build. Must be called by all targets
     ========================================================================
  -->
  <target name="init">

    <condition property="properties.ok">
      <and>
        <available file="${servlet.jar}"/>
        <!-- available file="${jstl.jar}"/ -->
        <!-- available file="${standard.jar}"/ -->
      </and>
    </condition>
    <fail unless="properties.ok">Missing property or property pointing to an invalid file
(check your build.properties file)</fail>

    <taskdef resource="cactus.tasks" classpathref="cactus.classpath"/>

    <tstamp/>

  </target>

  <!--
     ========================================================================
       Compiles the sources
     ========================================================================
  -->
  <!-- Compiles the java sources -->
  <target name="compile.java" depends="init">

    <mkdir dir="${target.classes.java.dir}"/>
    <javac destdir="${target.classes.java.dir}"
        deprecation="${deprecation}" optimize="${optimize}">
      <src path="${src.java.dir}"/>
      <classpath>
        <path refid="project.classpath"/>
      </classpath>
    </javac>

  </target>

  <!-- Compiles the Cactus test sources -->
  <target name="compile.cactus" depends="compile.java">

    <mkdir dir="${target.classes.cactus.dir}"/>
    <javac destdir="${target.classes.cactus.dir}"
        deprecation="${deprecation}" optimize="${optimize}">
      <src path="${src.cactus.dir}"/>
      <classpath>
        <path refid="cactus.classpath"/>
        <pathelement location="${httpunit.jar}"/>
        <pathelement location="${nekohtml.jar}"/>
        <pathelement location="${target.classes.java.dir}"/>
      </classpath>
    </javac>

  </target>

  <target name="compile" depends="compile.java, compile.cactus"
      description="Compile the sources"/>

  <!--
     ========================================================================
       Create the runtime war file
     ========================================================================
  -->
  <target name="war" depends="compile.java"
      description="Generate the runtime war">

    <war warfile="${target.dir}/${project.name.file}.war"
         webxml="${src.webapp.dir}/WEB-INF/web.xml">
      <fileset dir="${src.webapp.dir}">
        <exclude name="cactus-report.xsl"/>
        <exclude name="WEB-INF/cactus-web.xml"/>
        <exclude name="WEB-INF/web.xml"/>
      </fileset>
      <classes dir="${target.classes.java.dir}"/>
      <!-- lib file="${jstl.jar}"/ -->
      <!-- lib file="${standard.jar}"/ -->
    </war>

  </target>

  <!--
     ========================================================================
       Generate the distributable files
     ========================================================================
  -->
  <target name="dist" depends="clean, war, test"
      description="Generate the distributable files">

    <copy todir="${dist.dir}"
        file="${target.dir}/${project.name.file}.war"/>

  </target>

  <!--
     ========================================================================
       Clean generated files (including distributables)
     ========================================================================
  -->
  <target name="clean" depends="init" description="Clean all generated files">

    <delete dir="${target.dir}"/>
    <delete dir="${dist.dir}"/>

  </target>

  <!--
     ========================================================================
       Run the tests on the containers for which the Ant property
       "cactus.home.[container name]" has been defined.
     ========================================================================
  -->
  <target name="test.prepare.logging">
  
	<!-- Convert the path to logging_*.properties to use forward slashes
	     so that it works when loaded as a String in Java (backslashes
	     won't work. -->
	<pathconvert property="target.dir.normalized" dirsep="/">
	  <path>
	    <pathelement location="${target.dir}"/>
	  </path>
	</pathconvert>
	<copy todir="${target.dir}" filtering="on" failonerror="false">
	  <fileset dir="${base.dir}">
	    <include name="logging_*.properties"/>
	  </fileset>
	  <filterset>
        <filter token="target.dir" value="${target.dir.normalized}"/>
      </filterset>
	</copy>
    <!-- Make sure logging_*.properties files exist, even if empty -->
    <touch file="${target.dir}/logging_client.properties"/>
    <touch file="${target.dir}/logging_server.properties"/>

  </target>
  
  <target name="test.prepare" 
      depends="war, compile.cactus, test.prepare.logging">
  
    <!-- Cactify the web-app archive -->
    <cactifywar srcfile="${target.dir}/${project.name.file}.war"
        destfile="${target.dir}/${project.name.file}-cactified.war"
        mergewebxml="${src.webapp.dir}/WEB-INF/cactus-web.xml">
      <classes dir="${target.classes.cactus.dir}"/>
      <lib file="${httpunit.jar}"/>
      <lib file="${log4j.jar}"/>
      <!-- Provide a secured servlet redirector in addition to the
           default servlet redirector -->
      <servletredirector/>
      <servletredirector name="ServletRedirectorSecure"
          mapping="/ServletRedirectorSecure" roles="test"/>
      <!-- Orion fails on a servlet filter that is not mapped to an actual
           resource, to trick it -->
      <filterredirector mapping="/test/filterRedirector.jsp"/>
      <!-- Files needed for JBoss -->
      <classes dir="${src.conf.dir}/jboss3x">
        <include name="*.properties" if="cactus.home.jboss3x"/>
      </classes>
      <webinf dir="${src.conf.dir}/jboss3x">
        <include name="jboss-web.xml" if="cactus.home.jboss3x"/>
      </webinf>
      <!-- Needed for Clover coverage reports -->
      <lib file="${clover.jar}"/>
    </cactifywar>

    <!-- Prepare the directories for the JUnit reports -->
    <mkdir dir="${target.testreports.dir}"/>
    <!-- mkdir dir="${target.testreports.dir}/jboss3x"/ -->
    <mkdir dir="${target.testreports.dir}/orion1x"/>
    <mkdir dir="${target.testreports.dir}/orion2x"/>
    <mkdir dir="${target.testreports.dir}/resin2x"/>
    <mkdir dir="${target.testreports.dir}/tomcat3x"/>
    <mkdir dir="${target.testreports.dir}/tomcat4x"/>
    <mkdir dir="${target.testreports.dir}/tomcat5x"/>
    <mkdir dir="${target.testreports.dir}/weblogic7x"/>

  </target>

  <target name="test" depends="test.prepare"
      description="Run the tests on the defined containers">

    <!-- Run the tests -->
    <cactus warfile="${target.dir}/${project.name.file}-cactified.war" 
        fork="yes" failureproperty="tests.failed" haltonerror="true">

      <!-- Configure the cactus task for logging -->
      <cactusproperty server="false"
          propertiesFile="${target.dir.normalized}/logging_client.properties"/>
      <cactusproperty server="true"
          propertiesFile="${target.dir.normalized}/logging_server.properties"/>

      <classpath>
        <path refid="project.classpath"/>
        <pathelement location="${clover.jar}"/>
        <pathelement location="${httpunit.jar}"/>
        <pathelement location="${nekohtml.jar}"/>
        <pathelement location="${target.classes.java.dir}"/>
        <pathelement location="${target.classes.cactus.dir}"/>
        <pathelement location="${log4j.jar}"/>
      </classpath>
      <containerset>
        <!-- jboss3x if="cactus.home.jboss3x"
            dir="${cactus.home.jboss3x}"
            output="${target.testreports.dir}/jboss3x.out"
            todir="${target.testreports.dir}/jboss3x"/ -->
        <orion1x if="cactus.home.orion1x"
            dir="${cactus.home.orion1x}" port="${cactus.port}"
            output="${target.testreports.dir}/orion1x.out"
            todir="${target.testreports.dir}/orion1x"/>
        <orion2x if="cactus.home.orion2x"
            dir="${cactus.home.orion2x}" port="${cactus.port}"
            output="${target.testreports.dir}/orion2x.out"
            todir="${target.testreports.dir}/orion2x"/>
        <resin2x if="cactus.home.resin2x"
            dir="${cactus.home.resin2x}" port="${cactus.port}"
            output="${target.testreports.dir}/resin2x.out"
            todir="${target.testreports.dir}/resin2x"/>
        <tomcat3x if="cactus.home.tomcat3x"
            dir="${cactus.home.tomcat3x}" port="${cactus.port}"
            output="${target.testreports.dir}/tomcat3x.out"
            todir="${target.testreports.dir}/tomcat3x"/>
        <tomcat4x if="cactus.home.tomcat4x"
            dir="${cactus.home.tomcat4x}" port="${cactus.port}"
            output="${target.testreports.dir}/tomcat4x.out"
            todir="${target.testreports.dir}/tomcat4x"/>
        <tomcat5x if="cactus.home.tomcat5x"
            dir="${cactus.home.tomcat5x}" port="${cactus.port}"
            output="${target.testreports.dir}/tomcat5x.out"
            todir="${target.testreports.dir}/tomcat5x"/>
        <weblogic7x if="cactus.home.weblogic7x"
            dir="${cactus.home.weblogic7x}" port="${cactus.port}"
            output="${target.testreports.dir}/weblogic7x.out"
            todir="${target.testreports.dir}/weblogic7x"/>
      </containerset>
      <formatter type="brief" usefile="false"/>
      <formatter type="xml"/>
      <batchtest>
        <fileset dir="${src.cactus.dir}">
          <!-- Due to some Cactus synchronization bug, the 'unit' tests need
               to run before the 'sample' tests -->
          <include name="**/unit/Test*.java"/>
          <exclude name="**/unit/Test*All.java"/>
        </fileset>
      </batchtest>
      <batchtest>
        <fileset dir="${src.cactus.dir}">
          <include name="**/sample/Test*.java"/>
          <exclude name="**/sample/Test*All.java"/>
        </fileset>
      </batchtest>
    </cactus>

    <!-- Generate the JUnit reports -->
    <!-- junitreport todir="${target.testreports.dir}/jboss3x">
      <fileset dir="${target.testreports.dir}/jboss3x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/jboss3x"
          format="frames"/>
    </junitreport -->
    <junitreport todir="${target.testreports.dir}/orion1x">
      <fileset dir="${target.testreports.dir}/orion1x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/orion1x"
          format="frames"/>
    </junitreport>
    <junitreport todir="${target.testreports.dir}/orion2x">
      <fileset dir="${target.testreports.dir}/orion2x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/orion2x"
          format="frames"/>
    </junitreport>
    <junitreport todir="${target.testreports.dir}/resin2x">
      <fileset dir="${target.testreports.dir}/resin2x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/resin2x"
          format="frames"/>
    </junitreport>
    <junitreport todir="${target.testreports.dir}/tomcat3x">
      <fileset dir="${target.testreports.dir}/tomcat3x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/tomcat3x"
          format="frames"/>
    </junitreport>
    <junitreport todir="${target.testreports.dir}/tomcat4x">
      <fileset dir="${target.testreports.dir}/tomcat4x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/tomcat4x"
          format="frames"/>
    </junitreport>
    <junitreport todir="${target.testreports.dir}/tomcat5x">
      <fileset dir="${target.testreports.dir}/tomcat5x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/tomcat5x"
          format="frames"/>
    </junitreport>
    <junitreport todir="${target.testreports.dir}/weblogic7x">
      <fileset dir="${target.testreports.dir}/weblogic7x"
          includes="TEST-*.xml"/>
      <report todir="${target.testreports.dir}/weblogic7x"
          format="frames"/>
    </junitreport>

    <fail if="tests.failed">At least one test failed!</fail>

  </target>

</project>