1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3
<!-- Content Stylesheet for Site -->
6
<!-- start the processing -->
9
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
11
<meta name="author" value="Stefan Bodewig">
12
<meta name="email" value="bodewig@apache.org">
14
<title>The Jakarta Site - Frequently Asked Questions</title>
17
<body bgcolor="#ffffff" text="#000000" link="#525D76">
18
<table border="0" width="100%" cellspacing="0">
22
<a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" align="left" border="0"/></a>
26
<table border="0" width="100%" cellspacing="4">
28
<hr noshade="" size="1"/>
32
<!-- LEFT SIDE NAVIGATION -->
33
<td valign="top" nowrap="true">
34
<p><strong>Ant</strong></p>
36
<li> <a href="./index.html">Front Page</a>
38
<li> <a href="./antnews.html">News</a>
40
<li> <a href="./manual/index.html">Documentation</a>
42
<li> <a href="./external.html">External Tools and Tasks</a>
44
<li> <a href="./resources.html">Resources</a>
46
<li> <a href="./faq.html">Ant FAQ</a>
48
<li> <a href="./problems.html">Having Problems?</a>
51
<p><strong>Download</strong></p>
53
<li> <a href="http://jakarta.apache.org/site/binindex.html">Binaries</a>
55
<li> <a href="http://jakarta.apache.org/site/sourceindex.html">Source Code</a>
58
<p><strong>Jakarta</strong></p>
60
<li> <a href="http://jakarta.apache.org/site/news.html">News & Status</a>
62
<li> <a href="http://jakarta.apache.org/site/mission.html">Mission</a>
64
<li> <a href="http://jakarta.apache.org/site/guidelines.html">Guidelines Notes</a>
66
<li> <a href="http://jakarta.apache.org/site/faqs.html">FAQs</a>
69
<p><strong>Get Involved</strong></p>
71
<li> <a href="http://jakarta.apache.org/site/getinvolved.html">Overview</a>
73
<li> <a href="http://jakarta.apache.org/site/cvsindex.html">CVS Repositories</a>
75
<li> <a href="http://jakarta.apache.org/site/mail.html">Mailing Lists</a>
77
<li> <a href="http://jakarta.apache.org/site/library.html">Reference Library</a>
79
<li> <a href="http://nagoya.apache.org/bugzilla/enter_bug.cgi?product=Ant">Bug Database</a>
81
<li> <a href="http://nagoya.apache.org/bugzilla/enter_bug.cgi?product=Ant&bug_severity=Enhancement">Enhancement Requests</a>
85
<td align="left" valign="top">
86
<table border="0" cellspacing="0" cellpadding="2" width="100%">
87
<tr><td bgcolor="#525D76">
88
<font color="#ffffff" face="arial,helvetica,sanserif">
89
<strong>Questions</strong>
94
<table border="0" cellspacing="0" cellpadding="2" width="100%">
95
<tr><td bgcolor="#828DA6">
96
<font color="#ffffff" face="arial,helvetica,sanserif">
97
<strong>General</strong>
103
<li><a href="#what-is-ant">
106
<li><a href="#ant-name">
107
Why do you call it Ant?
109
<li><a href="#history">
110
Tell us a little bit about Ant's history.
116
<table border="0" cellspacing="0" cellpadding="2" width="100%">
117
<tr><td bgcolor="#828DA6">
118
<font color="#ffffff" face="arial,helvetica,sanserif">
119
<strong>Installation</strong>
125
<li><a href="#no-gnu-tar">
126
I get checksum errors when I try to extract the
127
<code>tar.gz</code> distribution file. Why?
133
<table border="0" cellspacing="0" cellpadding="2" width="100%">
134
<tr><td bgcolor="#828DA6">
135
<font color="#ffffff" face="arial,helvetica,sanserif">
136
<strong>Using Ant</strong>
142
<li><a href="#always-recompiles">
143
Why does Ant always recompile all my Java files?
145
<li><a href="#passing-cli-args">
146
How do I pass parameters from the command line to my
149
<li><a href="#jikes-switches">
150
How can I use Jikes specific command line
153
<li><a href="#shell-redirect-1">
154
How do I include a < character in my command line arguments?
156
<li><a href="#shell-redirect-2">
157
How do I redirect standard input or standard output
158
in the <code><exec></code> task?
164
<table border="0" cellspacing="0" cellpadding="2" width="100%">
165
<tr><td bgcolor="#828DA6">
166
<font color="#ffffff" face="arial,helvetica,sanserif">
167
<strong>Ant and IDEs/Editors</strong>
173
<li><a href="#integration">
174
Is Ant supported by my IDE/Editor?
176
<li><a href="#emacs-mode">
177
Why doesn't (X)Emacs/vi/MacOS X's project builder
178
parse the error messages generated by Ant correctly?
184
<table border="0" cellspacing="0" cellpadding="2" width="100%">
185
<tr><td bgcolor="#828DA6">
186
<font color="#ffffff" face="arial,helvetica,sanserif">
187
<strong>Advanced issues</strong>
194
Is there a DTD that I can use to validate my build
197
<li><a href="#xml-entity-include">
198
How do I include an XML snippet in my build file?
200
<li><a href="#mail-logger">
201
How do I send an email with the result of my build
208
<table border="0" cellspacing="0" cellpadding="2" width="100%">
209
<tr><td bgcolor="#828DA6">
210
<font color="#ffffff" face="arial,helvetica,sanserif">
211
<strong>Known problems</strong>
217
<li><a href="#remove-cr">
218
<chmod> or <exec> don't work in Ant
221
<li><a href="#javadoc-cannot-execute">
222
JavaDoc failed: java.io.IOException: javadoc: cannot execute
232
<table border="0" cellspacing="0" cellpadding="2" width="100%">
233
<tr><td bgcolor="#525D76">
234
<font color="#ffffff" face="arial,helvetica,sanserif">
235
<strong>Answers</strong>
240
<a name="what-is-ant">
241
<table border="0" cellspacing="0" cellpadding="2" width="100%">
242
<tr><td bgcolor="#828DA6">
243
<font color="#ffffff" face="arial,helvetica,sanserif">
251
<p> Ant is a Java based build tool. In theory it is kind of
252
like "make" without makes wrinkles and with the full
253
portability of pure Java code.</p>
259
<table border="0" cellspacing="0" cellpadding="2" width="100%">
260
<tr><td bgcolor="#828DA6">
261
<font color="#ffffff" face="arial,helvetica,sanserif">
263
Why do you call it Ant?
269
<p>According to Ant's original author James Duncan
270
Davidson, the name is an acronym for "Another Neat
272
<p>Later explanations go along the lines of "Ants are
273
doing an extremely good job at building things" or
274
"Ants are very small and can carry a weight a dozen times
275
of their own" - describing what Ant is intended to
282
<table border="0" cellspacing="0" cellpadding="2" width="100%">
283
<tr><td bgcolor="#828DA6">
284
<font color="#ffffff" face="arial,helvetica,sanserif">
286
Tell us a little bit about Ant's history.
292
<p>Initially Ant was part of the Tomcat code base when it was
293
donated to the Apache Software Foundation - it has been
294
created by James Duncan Davidson, who also is the original
295
author of Tomcat. Ant was there to build Tomcat, nothing
297
<p>Soon thereafter several open source Java projects realized
298
that Ant could solve the problems they had with makefiles.
299
Starting with the projects hosted at Jakarta and the old Java
300
Apache project, Ant spread like a virus and now is the build
301
tool of choice for a lot of projects.</p>
302
<p>In January 2000 Ant was moved to a separate CVS module and
303
was promoted to a project of its own, independent of
305
<p>The first version of Ant that was exposed a lager audience
306
was the one that shipped with Tomcat's 3.1 release on 19 April
307
2000. This version has later been referenced to as Ant
309
<p>The first official release of Ant as a stand alone product was
310
Ant 1.1 released on 19 July 2000. The complete release
314
<td bgcolor="#039acc" colspan="" rowspan=""
315
valign="top" align="left">
316
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
320
<td bgcolor="#039acc" colspan="" rowspan=""
321
valign="top" align="left">
322
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
328
<td bgcolor="#a0ddf0" colspan="" rowspan=""
329
valign="top" align="left">
330
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
334
<td bgcolor="#a0ddf0" colspan="" rowspan=""
335
valign="top" align="left">
336
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
342
<td bgcolor="#a0ddf0" colspan="" rowspan=""
343
valign="top" align="left">
344
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
348
<td bgcolor="#a0ddf0" colspan="" rowspan=""
349
valign="top" align="left">
350
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
356
<td bgcolor="#a0ddf0" colspan="" rowspan=""
357
valign="top" align="left">
358
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
362
<td bgcolor="#a0ddf0" colspan="" rowspan=""
363
valign="top" align="left">
364
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
374
<a name="no-gnu-tar">
375
<table border="0" cellspacing="0" cellpadding="2" width="100%">
376
<tr><td bgcolor="#828DA6">
377
<font color="#ffffff" face="arial,helvetica,sanserif">
379
I get checksum errors when I try to extract the
380
<code>tar.gz</code> distribution file. Why?
386
<p>Ant's distribution contains file names that are longer
387
than 100 characters, which is not supported by the standard
388
tar file format. Several different implementations of tar use
389
different and incompatible ways to work around this
391
<p>Ant's <tar> task can create tar archives that use
392
the GNU tar extension, and this has been used when putting
393
together the distribution. If you are using a different
394
version of tar (for example, the one shipping with Solaris),
395
you cannot use it to extract the archive.</p>
396
<p>The solution is to either install GNU tar, which can be
397
found <a href="http://www.gnu.org/software/tar/tar.html">here</a>
398
or use the zip archive instead (you can extract it using
399
<code>jar xf</code>).</p>
404
<a name="always-recompiles">
405
<table border="0" cellspacing="0" cellpadding="2" width="100%">
406
<tr><td bgcolor="#828DA6">
407
<font color="#ffffff" face="arial,helvetica,sanserif">
409
Why does Ant always recompile all my Java files?
415
<p>In order to find out which files should be compiled, Ant
416
compares the timestamps of the source files to those of the
417
resulting <code>.class</code> files. Opening all source files
418
to find out which package they belong to would be very
419
inefficient - instead of this, Ant expects you to place your
420
source files in a directory hierarchy that mirrors your
421
package hierarchy and to point Ant to the root of this
422
directory tree with the <code>srcdir</code> attribute.</p>
423
<p>Say you have <code><javac srcdir="src"
424
destdir="dest" /></code>. If Ant finds a file
425
<code>src/a/b/C.java</code> it expects it to be in package
426
<code>a.b</code> so that the resulting <code>.class</code>
427
file is going to be <code>dest/a/b/C.class</code>.</p>
428
<p>If your setup is different, Ant's heuristic won't work and
429
it will recompile classes that are up to date. Ant is not the
430
only tool, that expects a source tree layout like this.</p>
435
<a name="passing-cli-args">
436
<table border="0" cellspacing="0" cellpadding="2" width="100%">
437
<tr><td bgcolor="#828DA6">
438
<font color="#ffffff" face="arial,helvetica,sanserif">
440
How do I pass parameters from the command line to my
447
<p>Use properties: <code>ant
448
-D<name>=<value></code> lets you define values for
449
properties. These can then be used within your build file as
450
any normal property: <code>${<name>}</code> will put in
451
<code><value></code>.</p>
456
<a name="jikes-switches">
457
<table border="0" cellspacing="0" cellpadding="2" width="100%">
458
<tr><td bgcolor="#828DA6">
459
<font color="#ffffff" face="arial,helvetica,sanserif">
461
How can I use Jikes specific command line
468
<p>A couple of switches are supported via magic
472
<td bgcolor="#039acc" colspan="" rowspan=""
473
valign="top" align="left">
474
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
478
<td bgcolor="#039acc" colspan="" rowspan=""
479
valign="top" align="left">
480
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
484
<td bgcolor="#039acc" colspan="" rowspan=""
485
valign="top" align="left">
486
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
492
<td bgcolor="#a0ddf0" colspan="" rowspan=""
493
valign="top" align="left">
494
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
498
<td bgcolor="#a0ddf0" colspan="" rowspan=""
499
valign="top" align="left">
500
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
504
<td bgcolor="#a0ddf0" colspan="" rowspan=""
505
valign="top" align="left">
506
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
512
<td bgcolor="#a0ddf0" colspan="" rowspan=""
513
valign="top" align="left">
514
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
518
<td bgcolor="#a0ddf0" colspan="" rowspan=""
519
valign="top" align="left">
520
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
521
build.compiler.pedantic
524
<td bgcolor="#a0ddf0" colspan="" rowspan=""
525
valign="top" align="left">
526
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
532
<td bgcolor="#a0ddf0" colspan="" rowspan=""
533
valign="top" align="left">
534
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
538
<td bgcolor="#a0ddf0" colspan="" rowspan=""
539
valign="top" align="left">
540
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
541
build.compiler.fulldepend
544
<td bgcolor="#a0ddf0" colspan="" rowspan=""
545
valign="top" align="left">
546
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
552
<td bgcolor="#a0ddf0" colspan="" rowspan=""
553
valign="top" align="left">
554
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
555
<strong>only for Ant < 1.4, replaced by the nowarn
556
attribute of javac after that</strong> -nowarn
559
<td bgcolor="#a0ddf0" colspan="" rowspan=""
560
valign="top" align="left">
561
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
562
build.compiler.warnings
565
<td bgcolor="#a0ddf0" colspan="" rowspan=""
566
valign="top" align="left">
567
<font color="#000000" size="-1" face="arial,helvetica,sanserif">
577
<a name="shell-redirect-1">
578
<table border="0" cellspacing="0" cellpadding="2" width="100%">
579
<tr><td bgcolor="#828DA6">
580
<font color="#ffffff" face="arial,helvetica,sanserif">
582
How do I include a < character in my command line arguments?
588
<p>The short answer is "Use <code>&lt;</code>".</p>
589
<p>The long answer is, that this probably won't do what you
590
want anyway, see <a href="#shell-redirect-2">the next
596
<a name="shell-redirect-2">
597
<table border="0" cellspacing="0" cellpadding="2" width="100%">
598
<tr><td bgcolor="#828DA6">
599
<font color="#ffffff" face="arial,helvetica,sanserif">
601
How do I redirect standard input or standard output
602
in the <code><exec></code> task?
608
<p>Say you want to redirect the standard input stream of the
609
<code>cat</code> command to read from a file, something
612
<table cellspacing="4" cellpadding="0" border="0">
614
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
615
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
616
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
619
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
620
<td bgcolor="#ffffff"><pre>
621
shell-prompt> cat < foo
623
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
626
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
627
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
628
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
632
<p>and try to translate it into</p>
634
<table cellspacing="4" cellpadding="0" border="0">
636
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
637
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
638
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
641
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
642
<td bgcolor="#ffffff"><pre>
643
<exec executable="cat">
644
<arg value="&lt;" />
645
<arg value="foo" />
648
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
651
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
652
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
653
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
657
<p>This will not do what you expect. The input-redirection is
658
performed by your shell, not the command itself, so this
661
<table cellspacing="4" cellpadding="0" border="0">
663
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
664
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
665
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
668
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
669
<td bgcolor="#ffffff"><pre>
670
<exec executable="/bin/sh">
671
<arg value="-c" />
672
<arg value="cat &lt; foo" />
675
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
678
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
679
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
680
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
684
<p>Note, that you must use the <code>value</code> attribute of
685
<code><arg></code> in the last element.</p>
690
<a name="integration">
691
<table border="0" cellspacing="0" cellpadding="2" width="100%">
692
<tr><td bgcolor="#828DA6">
693
<font color="#ffffff" face="arial,helvetica,sanserif">
695
Is Ant supported by my IDE/Editor?
701
<p>See the <a href="external.html#IDE and Editor Integration">section
702
on IDE integration</a> on our external tools page.</p>
707
<a name="emacs-mode">
708
<table border="0" cellspacing="0" cellpadding="2" width="100%">
709
<tr><td bgcolor="#828DA6">
710
<font color="#ffffff" face="arial,helvetica,sanserif">
712
Why doesn't (X)Emacs/vi/MacOS X's project builder
713
parse the error messages generated by Ant correctly?
719
<p>Ant adds a "banner" with the name of the current
720
task in front of all messages - and there are no built-in
721
regular expressions in your Editor that would account for
723
<p>You can disable this banner by invoking Ant with the
724
<code>-emacs</code> switch. Alternatively you can add the
725
following snippet to your <code>.emacs</code> to make Emacs
726
understand Ant's output.</p>
728
<table cellspacing="4" cellpadding="0" border="0">
730
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
731
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
732
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
735
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
736
<td bgcolor="#ffffff"><pre>
738
(setq compilation-error-regexp-alist
741
'("^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:" 1 2 3)
743
'("^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):" 1 2))
744
compilation-error-regexp-alist))
746
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
749
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
750
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
751
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
755
<p>Yet another alternative that preserves most of Ant's
756
formatting is to pipe Ant's output through the following Perl
757
script by Dirk-Willem van Gulik:</p>
759
<table cellspacing="4" cellpadding="0" border="0">
761
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
762
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
763
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
766
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
767
<td bgcolor="#ffffff"><pre>
770
# May 2001 dirkx@apache.org - remove any
771
# [foo] lines from the output; keeping
772
# spacing more or less there.
775
while(<STDIN>) {
776
if (s/^(\s+)\[(\w+)\]//) {
778
print "$1\[$2\]";
779
$s = ' ' x length($2);
781
print "$1 $s ";
788
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
791
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
792
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
793
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
802
<table border="0" cellspacing="0" cellpadding="2" width="100%">
803
<tr><td bgcolor="#828DA6">
804
<font color="#ffffff" face="arial,helvetica,sanserif">
806
Is there a DTD that I can use to validate my build
813
<p>An incomplete DTD can be created by the
814
<code><antstructure></code> task - but this one
815
has a few problems:</p>
817
<li>It doesn't know about required attributes. Only
818
manual tweaking of this file can help here.</li>
820
<li>It is not complete - if you add new tasks via
821
<code><taskdef></code> it won't know about it. See
822
<a href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html">this
823
page</a> by Michel Casabianca for a solution to this
824
problem. Note that the DTD you can download at this page
825
is based on Ant 0.3.1.</li>
827
<li>It may even be an invalid DTD. As Ant allows tasks
828
writers to define arbitrary elements, name collisions will
829
happen quite frequently - if your version of Ant contains
830
the optional <code><test></code> and
831
<code><junit></code> tasks, there are two XML
832
elements named test (the task and the nested child element
833
of <code><junit></code>) with different attribute
834
lists. This problem cannot be solved, DTDs don't give a
835
syntax rich enough to support this.</li>
841
<a name="xml-entity-include">
842
<table border="0" cellspacing="0" cellpadding="2" width="100%">
843
<tr><td bgcolor="#828DA6">
844
<font color="#ffffff" face="arial,helvetica,sanserif">
846
How do I include an XML snippet in my build file?
852
<p>You can use XML's way of including external files and let
853
the parser do the job for Ant:</p>
855
<table cellspacing="4" cellpadding="0" border="0">
857
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
858
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
859
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
862
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
863
<td bgcolor="#ffffff"><pre>
864
<?xml version="1.0"?>
866
<!DOCTYPE project [
867
<!ENTITY common SYSTEM "file:./common.xml">
870
<project name="test" default="test" basedir=".">
872
<target name="setup">
882
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
885
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
886
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
887
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
891
<p>will literally include the contents of <code>common.xml</code> where
892
you've placed the <code>&common;</code> entity.</p>
893
<p>In combination with a DTD, this would look like this:</p>
895
<table cellspacing="4" cellpadding="0" border="0">
897
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
898
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
899
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
902
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
903
<td bgcolor="#ffffff"><pre>
904
<!DOCTYPE project PUBLIC "-//ANT//DTD project//EN" "file:./ant.dtd" [
905
<!ENTITY include SYSTEM "file:./header.xml">
908
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
911
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
912
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
913
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
921
<a name="mail-logger">
922
<table border="0" cellspacing="0" cellpadding="2" width="100%">
923
<tr><td bgcolor="#828DA6">
924
<font color="#ffffff" face="arial,helvetica,sanserif">
926
How do I send an email with the result of my build
933
<p>You can use a custom BuildListener, that sends out an email
934
in the buildFinished() method. Will Glozer
935
<will.glozer@jda.com> has written such a listener based
936
on <a href="http://java.sun.com/products/javamail/">JavaMail</a>,
939
<table cellspacing="4" cellpadding="0" border="0">
941
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
942
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
943
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
946
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
947
<td bgcolor="#ffffff"><pre>
951
import javax.mail.internet.*;
952
import org.apache.tools.ant.*;
955
* A simple listener that waits for a build to finish and sends an email
956
* of the results. The settings are stored in "monitor.properties" and
957
* are fairly self explanatory.
959
* @author Will Glozer
960
* @version 1.05a 09/06/2000
962
public class BuildMonitor implements BuildListener {
963
protected Properties props;
966
* Create a new BuildMonitor.
968
public BuildMonitor() throws Exception {
969
props = new Properties();
970
InputStream is = getClass().getResourceAsStream("monitor.properties");
975
public void buildStarted(BuildEvent e) {
979
* Determine the status of the build and the actions to follow, now that
980
* the build has completed.
982
* @param e Event describing the build tatus.
984
public void buildFinished(BuildEvent e) {
985
Throwable th = e.getException();
986
String status = (th != null) ? "failed" : "succeeded";
989
String key = "build." + status;
990
if (props.getProperty(key + ".notify").equalsIgnoreCase("false")) {
994
Session session = Session.getDefaultInstance(props, null);
996
MimeMessage message = new MimeMessage(session);
997
message.addRecipients(Message.RecipientType.TO, parseAddresses(
998
props.getProperty(key + ".email.to")));
999
message.setSubject(props.getProperty(key + ".email.subject"));
1001
BufferedReader br = new BufferedReader(new FileReader(
1002
props.getProperty("build.log")));
1003
StringWriter sw = new StringWriter();
1005
String line = br.readLine();
1006
while (line != null) {
1008
sw.write("\n");
1009
line = br.readLine();
1013
message.setText(sw.toString(), "UTF-8");
1016
Transport transport = session.getTransport();
1017
transport.connect();
1018
transport.send(message);
1020
} catch (Exception ex) {
1021
System.out.println("BuildMonitor failed to send email!");
1022
ex.printStackTrace();
1027
* Parse a comma separated list of internet email addresses.
1029
* @param s The list of addresses.
1030
* @return Array of Addresses.
1032
protected Address[] parseAddresses(String s) throws Exception {
1033
StringTokenizer st = new StringTokenizer(s, ",");
1034
Address[] addrs = new Address[st.countTokens()];
1036
for (int i = 0; i < addrs.length; i++) {
1037
addrs[i] = new InternetAddress(st.nextToken());
1042
public void messageLogged(BuildEvent e) {
1045
public void targetStarted(BuildEvent e) {
1048
public void targetFinished(BuildEvent e) {
1051
public void taskStarted(BuildEvent e) {
1054
public void taskFinished(BuildEvent e) {
1058
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1061
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1062
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1063
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1067
<p>With a <code>monitor.properties</code> like this</p>
1069
<table cellspacing="4" cellpadding="0" border="0">
1071
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1072
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1073
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1076
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1077
<td bgcolor="#ffffff"><pre>
1078
# configuration for build monitor
1080
mail.transport.protocol=smtp
1081
mail.smtp.host=<host>
1082
mail.from=Will Glozer <will.glozer@jda.com>
1086
build.failed.notify=true
1087
build.failed.email.to=will.glozer@jda.com
1088
build.failed.email.subject=Nightly build failed!
1090
build.succeeded.notify=true
1091
build.succeeded.email.to=will.glozer@jda.com
1092
build.succeeded.email.subject=Nightly build succeeded!
1094
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1097
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1098
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1099
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1103
<p><code>monitor.properties</code> should be placed right next
1104
to your compiled <code>BuildMonitor.class</code>. To use it,
1107
<table cellspacing="4" cellpadding="0" border="0">
1109
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1110
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1111
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1114
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1115
<td bgcolor="#ffffff"><pre>
1116
ant -listener BuildMonitor
1118
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1121
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1122
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1123
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1127
<p>Make sure that <code>mail.jar</code> from JavaMail and
1128
<code>activation.jar</code> from the
1129
<a href="http://java.sun.com/products/javabeans/glasgow/jaf.html">Java
1130
Beans Activation Framework</a> in your <code>CLASSPATH</code>.</p>
1135
<a name="remove-cr">
1136
<table border="0" cellspacing="0" cellpadding="2" width="100%">
1137
<tr><td bgcolor="#828DA6">
1138
<font color="#ffffff" face="arial,helvetica,sanserif">
1140
<chmod> or <exec> don't work in Ant
1147
<p>The <code>antRun</code> script in <code>ANT_HOME/bin</code>
1148
has DOS instead of Unix line endings, you must remove the
1149
carriage return characters from this file. This can be done by
1150
using Ant's <fixcrlf> task or something like:</p>
1152
<table cellspacing="4" cellpadding="0" border="0">
1154
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1155
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1156
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1159
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1160
<td bgcolor="#ffffff"><pre>
1161
tr -d '\r' < $ANT_HOME/bin/antRun > /tmp/foo
1162
mv /tmp/foo $ANT_HOME/bin/antRun
1164
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1167
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1168
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1169
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
1177
<a name="javadoc-cannot-execute">
1178
<table border="0" cellspacing="0" cellpadding="2" width="100%">
1179
<tr><td bgcolor="#828DA6">
1180
<font color="#ffffff" face="arial,helvetica,sanserif">
1182
JavaDoc failed: java.io.IOException: javadoc: cannot execute
1188
<p>There is a bug in the Solaris reference implementation of
1189
the JDK, see <a href="http://developer.java.sun.com/developer/bugParade/bugs/4230399.html">http://developer.java.sun.com/developer/bugParade/bugs/4230399.html</a>.
1190
This also appears to be true under Linux, moving the JDK to
1191
the front of the PATH fixes the problem.</p>
1203
<tr><td colspan="2">
1204
<hr noshade="" size="1"/>
1206
<tr><td colspan="2">
1207
<div align="center"><font color="#525D76" size="-1"><em>
1208
Copyright © 1999-2001, Apache Software Foundation
1214
<!-- end the processing -->