diff --git a/docs/faq.html b/docs/faq.html index 56afbd929..2d77aff39 100644 --- a/docs/faq.html +++ b/docs/faq.html @@ -239,6 +239,10 @@
jar
's M
switch?
I don't want a MANIFEST.
+ <property name="prop"
+ value="${${anotherprop}}"/>
(double expanding the property)?
unless="property"
as an attribute
- of the target, but all the targets this target
+ so I have unless="property"
as an attribute
+ of the target, but all the targets this target
depends on are still executed. Why?
The latest version can always be found at Ant's homepage +
The latest version can always be found at Ant's homepage http://ant.apache.org/faq.html.
How can I contribute to this FAQ?
-The page you are looking it is generated from +
The page you are looking it is generated from this document. If you want to add a new question, please submit a patch against this document to one of Ant's mailing lists; @@ -359,7 +363,7 @@ How do you create the HTML version of this FAQ?
-We use +
We use Anakia to render the HTML version from the original XML file.
The Velocity stylesheets used to process the XML files can @@ -386,7 +390,7 @@
According to Ant's original author, James Duncan Davidson, the name is an acronym for "Another Neat Tool".
-Later explanations go along the lines of "ants +
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 @@ -747,7 +751,7 @@ shell-prompt> m4 foo.m4 > foo to determine the specific state you want to test for.
To see how this works, assume you have three properties:
prop1
, prop2
, and prop3
.
- You want to test that prop1
and prop2
+ You want to test that prop1
and prop2
are set, and that prop3
is not. If the condition
holds true you want to echo "yes".
Here is the implementation in Ant 1.3 and earlier:
@@ -811,8 +815,8 @@ shell-prompt> m4 foo.m4 > fooBecause testing for a literal ${property}
string
isn't all that readable or easy to understand,
- post-1.4.1 Ant introduces the <isset>
element
- to the <condition>
task.
<isset>
element
+ to the <condition>
task.
Here is the previous example done using
<isset>
:
@@ -866,6 +870,21 @@ shell-prompt> m4 foo.m4 > foo<zip>
uses your platforms default encoding. Use the encoding attribute of<zip>
if necessary. ++ + How can I do something like
+<property name="prop" + value="${${anotherprop}}"/>
(double expanding the property)? +Without any external help you can not.
+With <script/>, which needs external libraries, you can do
++<script language="javascript"> + propname = project.getProperty("anotherprop"); + project.setNewProperty("prop", propname); +</script> ++With AntContrib (external task library) you can do
+ <propertycopy name="prop" from="${anotherprop}"/>
.Why does Ant always recompile all my Java files? @@ -924,23 +943,23 @@ shell-prompt> m4 foo.m4 > foo
I have a target I want to skip if a property is set, - so I have
unless="property"
as an attribute - of the target, but all the targets this target + so I haveunless="property"
as an attribute + of the target, but all the targets this target depends on are still executed. Why?The list of dependencies is generated by Ant before any of the - targets are run. This allows dependent targets, such as an -
+ targets are run. This allows dependent targets, such as an +init
target, to set properties that can control the - execution of the targets higher in the dependency graph. This - is a good thing.init
target, to set properties that can control the + execution of the targets higher in the dependency graph. This + is a good thing.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:
- Put the same condition on each of the dependent targets.
- +- Execute the steps using
@@ -962,10 +981,10 @@ shell-prompt> m4 foo.m4 > foo elements only apply to the file list produced by the<antcall>
, instead of specifying them inside thedepends
attribute.<include>
elements.To get the files you want, focus on just the -
+<include>
patterns that would be necessary - to get them. If you find you need to trim the list that the -<include>
elements produce, then use -<exclude>
elements.<include>
patterns that would be necessary + to get them. If you find you need to trim the list that the +<include>
elements produce, then use +<exclude>
elements.-
ant
failed to build my program via javac @@ -1002,7 +1021,7 @@ shell-prompt> m4 foo.m4 > foo Is Ant supported by my IDE/Editor?See the section +
See the section on IDE integration on our External Tools and Tasks page.
@@ -1019,10 +1038,10 @@ shell-prompt> m4 foo.m4 > foo
.antrc
(contributed by Ville Skyttä).# 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" +fiAlternatively, you can add the following snippet to your
.emacs
to make Emacs understand Ant's @@ -1030,10 +1049,10 @@ fi(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))@@ -1049,16 +1068,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; };
@@ -1072,7 +1091,7 @@ while(<STDIN>) {
<taskdef>
it won't know about it. See
this
@@ -1162,7 +1181,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 JavaMail.
+ on JavaMail.
The source is:
import java.io.*; @@ -1204,13 +1223,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); @@ -1221,7 +1240,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); @@ -1229,10 +1248,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); @@ -1268,7 +1287,7 @@ 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) { @@ -1300,7 +1319,7 @@ build.succeeded.email.subject=Nightly build succeeded! ant -listener BuildMonitor -logfile build.log
Make sure that mail.jar
from JavaMail and
- activation.jar
from the
+ activation.jar
from the
Java
Beans Activation Framework are in your CLASSPATH
.
diff --git a/xdocs/faq.xml b/xdocs/faq.xml
index 8f16f7dfc..c38eaa0c0 100644
--- a/xdocs/faq.xml
+++ b/xdocs/faq.xml
@@ -11,7 +11,7 @@
The latest version can always be found at Ant's homepage
+ The latest version can always be found at Ant's homepage
http://ant.apache.org/faq.html. The page you are looking it is generated from
+ The page you are looking it is generated from
this
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. If you don't know how to create a patch, see the patches
section of this
page. We use
+ We use
Anakia
to render the HTML version from the original XML file. According to Ant's original author, James Duncan
Davidson, the name is an acronym for "Another Neat
Tool". Later explanations go along the lines of "ants
+
+ 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 @@
and try to translate it into This will not do what you expect. The output redirection is
performed by your shell, not the command itself, so this
should read: To see how this works, assume you have three properties:
Because testing for a literal prop1
, prop2
, and prop3
.
- You want to test that prop1
and prop2
+ You want to test that prop1
and prop2
are set, and that prop3
is not. If the condition
holds true you want to echo "yes".${property}
string
isn't all that readable or easy to understand,
- post-1.4.1 Ant introduces the <isset>
element
- to the <condition>
task.<isset>
element
+ to the <condition>
task.
Here is the previous example done using
<isset>
:
You need to tell the XML parser which character encoding your build file uses, this is done inside the XML - declaration.
+ declarationBy 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.
+ +<property name="prop"
+ value="${${anotherprop}}"/>
(double expanding the property)?Without any external help you can not.
+With <script/>, which needs external libraries, you can do
+With AntContrib (external task library) you can do
+ <propertycopy name="prop" from="${anotherprop}"/>
.
Here's what you probably did:
-You need to switch off the default exclusions, and it will work:
-For a complete listing of the patterns that are excluded by default, see the user manual.
@@ -617,34 +635,34 @@ shell-prompt> m4 foo.m4 > foounless="property"
as an attribute
- of the target, but all the targets this target
+ so I have unless="property"
as an attribute
+ of the target, but all the targets this target
depends on are still executed. Why?The list of dependencies is generated by Ant before any of the
- targets are run. This allows dependent targets, such as an
- init
target, to set properties that can control the
- execution of the targets higher in the dependency graph. This
- is a good thing.
init
target, to set properties that can control the
+ execution of the targets higher in the dependency graph. This
+ is a good thing.
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:
<antcall>
,
instead of specifying them inside the depends
attribute.<fileset>
, I've put in an
<exclude>
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
<include>
elements.
- To get the files you want, focus on just the
- <include>
patterns that would be necessary
- to get them. If you find you need to trim the list that the
- <include>
elements produce, then use
- <exclude>
elements.
To get the files you want, focus on just the
+ <include>
patterns that would be necessary
+ to get them. If you find you need to trim the list that the
+ <include>
elements produce, then use
+ <exclude>
elements.
ant
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
See the section
+ See the section
on IDE integration on our External Tools and Tasks page.
Alternatively, you can add the following snippet to your
@@ -753,10 +771,10 @@ fi
<taskdef>
it won't know about it. See
this
@@ -911,7 +929,7 @@ while(With a monitor.properties
like this:
monitor.properties
should be placed right next
to your compiled BuildMonitor.class
. To use it,
invoke Ant like:
-
+
Make sure that mail.jar
from JavaMail and
- activation.jar
from the
+ activation.jar
from the
Java
Beans Activation Framework are in your CLASSPATH
.
These tasks don't ignore your classpath setting, you are facing a common problem with delegating classloaders.
@@ -1318,4 +1336,4 @@ mv /tmp/foo $ANT_HOME/bin/antRun