@@ -11,7 +11,7 @@
<question>Where do I find the latest version of this
document?</question>
<answer>
<p>The latest version can always be found at Ant's homepage
<p>The latest version can always be found at Ant's homepage
<a href="http://ant.apache.org/faq.html">http://ant.apache.org/faq.html</a>.</p>
</answer>
</faq>
@@ -19,12 +19,12 @@
<faq id="adding-faqs">
<question>How can I contribute to this FAQ?</question>
<answer>
<p>The page you are looking it is generated from
<p>The page you are looking it is generated from
<a href="http://cvs.apache.org/viewcvs.cgi/~checkout~/ant/xdocs/faq.xml">this</a>
document. If you want to add a new question, please submit
a patch against this document to one of Ant's mailing lists;
hopefully, the structure is self-explanatory.</p>
<p>If you don't know how to create a patch, see the patches
section of <a href="http://jakarta.apache.org/site/source.html">this
page</a>.</p>
@@ -36,7 +36,7 @@
FAQ?</question>
<answer>
<p>We use
<p>We use
<a href="http://jakarta.apache.org/velocity/anakia.html">Anakia</a>
to render the HTML version from the original XML file.</p>
@@ -73,8 +73,8 @@
<p>According to Ant's original author, James Duncan
Davidson, the name is an acronym for "Another Neat
Tool".</p>
<p>Later explanations go along the lines of "ants
<p>Later explanations go along the lines of "ants
do an extremely good job at building things", or
"ants are very small and can carry a weight dozens of times
their own" - describing what Ant is intended to
@@ -320,7 +320,7 @@
<source><![CDATA[
shell-prompt> m4 foo.m4 > foo
]]></source>
<p>and try to translate it into</p>
<source><![CDATA[
@@ -334,7 +334,7 @@ shell-prompt> m4 foo.m4 > foo
<p>This will not do what you expect. The output redirection is
performed by your shell, not the command itself, so this
should read:</p>
<source><![CDATA[
<exec executable="/bin/sh">
<arg value="-c" />
@@ -398,7 +398,7 @@ shell-prompt> m4 foo.m4 > foo
<p>To see how this works, assume you have three properties:
<code>prop1</code>, <code>prop2</code>, and <code>prop3</code>.
You want to test that <code>prop1</code> and <code>prop2</code>
You want to test that <code>prop1</code> and <code>prop2</code>
are set, and that <code>prop3</code> is not. If the condition
holds true you want to echo "yes".</p>
@@ -470,8 +470,8 @@ shell-prompt> m4 foo.m4 > foo
<p>Because testing for a literal <code>${property}</code> string
isn't all that readable or easy to understand,
post-1.4.1 Ant introduces the <code><isset></code> element
to the <code><condition></code> task.</p>
post-1.4.1 Ant introduces the <code><isset></code> element
to the <code><condition></code> task.</p>
<p>Here is the previous example done using
<code><isset></code>:</p>
@@ -501,7 +501,7 @@ shell-prompt> m4 foo.m4 > foo
details.</p>
</answer>
</faq>
<faq id="encoding">
<question>How can I include national characters like German
umlauts in my build file?</question>
@@ -510,7 +510,7 @@ shell-prompt> m4 foo.m4 > foo
<p>You need to tell the XML parser which character encoding
your build file uses, this is done inside the <a
href="http://www.w3.org/TR/2000/REC-xml-20001006#sec-prolog-dtd">XML
declaration</a>.</p>
declaration</a>.</p>
<p>By default the parser assumes you are using the UTF-8
encoding instead of your platform's default. For most Western
@@ -540,6 +540,24 @@ shell-prompt> m4 foo.m4 > foo
necessary.</p>
</answer>
</faq>
<faq id="propertyvalue-as-name-for-property">
<question>How can I do something like <code><property name="prop"
value="${${anotherprop}}"/></code> (double expanding the property)?</question>
<answer>
<p>Without any external help you can not.</p>
<p>With <script/>, which needs external libraries, you can do</p>
<source><![CDATA[
<script language="javascript">
propname = project.getProperty("anotherprop");
project.setNewProperty("prop", propname);
</script>
]]></source>
<p>With AntContrib (external task library) you can do <code>
<propertycopy name="prop" from="${anotherprop}"/></code>.</p>
</answer>
</faq>
</faqsection>
<faqsection title="It doesn't work (as expected)">
@@ -593,7 +611,7 @@ shell-prompt> m4 foo.m4 > foo
<p>Here's what you probably did:</p>
<source><![CDATA[
<source><![CDATA[
<delete>
<fileset dir="${build.src}" includes="**/vssver.scc"/>
</delete>
@@ -601,13 +619,13 @@ shell-prompt> m4 foo.m4 > foo
<p>You need to switch off the default exclusions,
and it will work:</p>
<source><![CDATA[
<source><![CDATA[
<delete>
<fileset dir="${build.src}" includes="**/vssver.scc"
defaultexcludes="no"/>
</delete>
]]></source>
<p>For a complete listing of the patterns that are excluded
by default, see <a href="manual/dirtasks.html#defaultexcludes">the user
manual</a>.</p>
@@ -617,34 +635,34 @@ shell-prompt> m4 foo.m4 > foo
<faq id="stop-dependency">
<question>I have a target I want to skip if a property is set,
so I have <code>unless="property"</code> as an attribute
of the target, but all the targets this target
so I have <code>unless="property"</code> as an attribute
of the target, but all the targets this target
depends on are still executed. Why?</question>
<answer>
<p>The list of dependencies is generated by Ant before any of the
targets are run. This allows dependent targets, such as an
<code>init</code> target, to set properties that can control the
execution of the targets higher in the dependency graph. This
is a good thing.</p>
targets are run. This allows dependent targets, such as an
<code>init</code> target, to set properties that can control the
execution of the targets higher in the dependency graph. This
is a good thing.</p>
<p>However, when your dependencies break down the
higher-level task
into several smaller steps, this behaviour becomes
into several smaller steps, this behaviour becomes
counter-intuitive. There are a couple of solutions available:
</p>
<ol>
<li>Put the same condition on each of the dependent targets.</li>
<li>Execute the steps using <code><antcall></code>,
instead of specifying them inside the <code>depends</code>
attribute.</li>
</ol>
</answer>
</faq>
<faq id="include-order">
<question>In my <code><fileset></code>, I've put in an
<code><exclude></code> of all files followed by an
@@ -662,14 +680,14 @@ shell-prompt> m4 foo.m4 > foo
elements only apply to the file list produced by the
<code><include></code> elements.</p>
<p>To get the files you want, focus on just the
<code><include></code> patterns that would be necessary
to get them. If you find you need to trim the list that the
<code><include></code> elements produce, then use
<code><exclude></code> elements.</p>
<p>To get the files you want, focus on just the
<code><include></code> patterns that would be necessary
to get them. If you find you need to trim the list that the
<code><include></code> elements produce, then use
<code><exclude></code> elements.</p>
</answer>
</faq>
<faq id="properties-not-trimmed">
<question><code>ant</code> failed to build my program via javac
even when I put the needed jars in an external
@@ -718,7 +736,7 @@ shell-prompt> m4 foo.m4 > foo
<faq id="integration">
<question>Is Ant supported by my IDE/Editor?</question>
<answer>
<p>See the <a href="external.html#IDE and Editor Integration">section
<p>See the <a href="external.html#IDE and Editor Integration">section
on IDE integration</a> on our External Tools and Tasks page.</p>
</answer>
</faq>
@@ -740,10 +758,10 @@ shell-prompt> m4 foo.m4 > foo
<source><![CDATA[
# Detect (X)Emacs compile mode
if [ "$EMACS" = "t" ] ; then
ANT_ARGS="$ANT_ARGS -emacs"
ANT_OPTS="$ANT_OPTS -Dbuild.compiler.emacs=true"
fi
if [ "$EMACS" = "t" ] ; then
ANT_ARGS="$ANT_ARGS -emacs"
ANT_OPTS="$ANT_OPTS -Dbuild.compiler.emacs=true"
fi
]]></source>
<p>Alternatively, you can add the following snippet to your
@@ -753,10 +771,10 @@ fi
<source><![CDATA[
(require 'compile)
(setq compilation-error-regexp-alist
(append (list
(append (list
;; works for jikes
'("^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):\\([0-9]+\\):[0-9]+:[0-9]+:" 1 2 3)
;; works for javac
;; works for javac
'("^\\s-*\\[[^]]*\\]\\s-*\\(.+\\):\\([0-9]+\\):" 1 2))
compilation-error-regexp-alist))
]]></source>
@@ -774,16 +792,16 @@ fi
#
$|=1;
while(<STDIN>) {
if (s/^(\s+)\[(\w+)\]//) {
if ($2 ne $last) {
print "$1\[$2\]";
$s = ' ' x length($2);
} else {
print "$1 $s ";
};
$last = $2;
};
print;
if (s/^(\s+)\[(\w+)\]//) {
if ($2 ne $last) {
print "$1\[$2\]";
$s = ' ' x length($2);
} else {
print "$1 $s ";
};
$last = $2;
};
print;
};
]]></source>
@@ -805,7 +823,7 @@ while(<STDIN>) {
<ul>
<li>It doesn't know about required attributes. Only
manual tweaking of this file can help here.</li>
<li>It is not complete - if you add new tasks via
<code><taskdef></code> it won't know about it. See
<a href="http://www.sdv.fr/pages/casa/html/ant-dtd.en.html">this
@@ -911,7 +929,7 @@ while(<STDIN>) {
BuildListener that sends out an email
in the buildFinished() method. Will Glozer
<will.glozer@jda.com> has written such a listener based
on <a href="http://java.sun.com/products/javamail/">JavaMail</a>.
on <a href="http://java.sun.com/products/javamail/">JavaMail</a>.
The source is:</p>
<source><![CDATA[
@@ -954,13 +972,13 @@ public class BuildMonitor implements BuildListener {
public void buildFinished(BuildEvent e) {
Throwable th = e.getException();
String status = (th != null) ? "failed" : "succeeded";
try {
String key = "build." + status;
if (props.getProperty(key + ".notify").equalsIgnoreCase("false")) {
return;
}
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
@@ -971,7 +989,7 @@ public class BuildMonitor implements BuildListener {
BufferedReader br = new BufferedReader(new FileReader(
props.getProperty("build.log")));
StringWriter sw = new StringWriter();
String line = br.readLine();
while (line != null) {
sw.write(line);
@@ -979,10 +997,10 @@ public class BuildMonitor implements BuildListener {
line = br.readLine();
}
br.close();
message.setText(sw.toString(), "UTF-8");
sw.close();
Transport transport = session.getTransport();
transport.connect();
transport.send(message);
@@ -1018,14 +1036,14 @@ public class BuildMonitor implements BuildListener {
public void targetFinished(BuildEvent e) {
}
public void taskStarted(BuildEvent e) {
public void taskStarted(BuildEvent e) {
}
public void taskFinished(BuildEvent e) {
}
}
]]></source>
<p>With a <code>monitor.properties</code> like this:</p>
<source><![CDATA[
@@ -1049,13 +1067,13 @@ build.succeeded.email.subject=Nightly build succeeded!
<p><code>monitor.properties</code> should be placed right next
to your compiled <code>BuildMonitor.class</code>. To use it,
invoke Ant like:</p>
<source><![CDATA[
ant -listener BuildMonitor -logfile build.log
]]></source>
<p>Make sure that <code>mail.jar</code> from JavaMail and
<code>activation.jar</code> from the
<code>activation.jar</code> from the
<a href="http://java.sun.com/products/javabeans/glasgow/jaf.html">Java
Beans Activation Framework</a> are in your <code>CLASSPATH</code>.</p>
@@ -1084,7 +1102,7 @@ public void buildFinished(BuildEvent e) {
results for properties that were specified on the Ant command line.</p>
</answer>
</faq>
</faqsection>
<faqsection title="Known Problems">
@@ -1119,7 +1137,7 @@ mv /tmp/foo $ANT_HOME/bin/antRun
<faq id="delegating-classloader">
<question><style> or <junit> ignores my
<classpath></question>
<answer>
<p>These tasks don't ignore your classpath setting, you
are facing a common problem with delegating classloaders.</p>
@@ -1318,4 +1336,4 @@ mv /tmp/foo $ANT_HOME/bin/antRun
</faqsection>
</document>
</document>