Browse Source

Split "Using Ant section".

Add FAQ about WinZIP, file name case, <war> and WEB-INF as well as
<jar> and META-INF.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273476 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
5a40d2e005
2 changed files with 335 additions and 274 deletions
  1. +217
    -176
      docs/faq.html
  2. +118
    -98
      xdocs/faq.xml

+ 217
- 176
docs/faq.html View File

@@ -165,15 +165,12 @@
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>Using Ant</strong>
<strong>How do I ...</strong>
</font>
</td></tr>
<tr><td>
<blockquote>
<ul>
<li><a href="#always-recompiles">
Why does Ant always recompile all my Java files?
</a></li>
<li><a href="#passing-cli-args">
How do I pass parameters from the command line to my
build file?
@@ -191,17 +188,36 @@
</a></li>
<li><a href="#batch-shell-execute">
How do I execute a batch file or shell script from Ant?
</a></li>
<li><a href="#defaultexcludes">
I've used a <code>&lt;delete&gt;</code> task to delete
unwanted
SourceSafe control files (CVS files, editor backup files, etc.), but
it doesn't seem to work; the files never get deleted. What's
wrong?
</a></li>
<li><a href="#multi-conditions">
I want to execute a particular target only if
multiple conditions are true.
</a></li>
<li><a href="#encoding">
How can I include national characters like German
umlauts in my build file?
</a></li>
</ul>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>It doesn't work (as expected)</strong>
</font>
</td></tr>
<tr><td>
<blockquote>
<ul>
<li><a href="#always-recompiles">
Why does Ant always recompile all my Java files?
</a></li>
<li><a href="#defaultexcludes">
I've used a <code>&lt;delete&gt;</code> task to
delete unwanted SourceSafe control files (CVS files, editor
backup files, etc.), but it doesn't seem to work; the files
never get deleted. What's wrong?
</a></li>
<li><a href="#stop-dependency">
I have a target I want to skip if a property is set,
@@ -215,16 +231,17 @@
<code>&lt;include&gt;</code> of just the files I want, but it
isn't giving me any files at all. What's wrong?
</a></li>
<li><a href="#encoding">
How can I include national characters like German
umlauts in my build file?
</a></li>
<li><a href="#properties-not-trimmed">
<code>ant</code> failed to build my program via javac
even when I put the needed jars in an external
<code>build.properties</code> file and reference them by
<code>pathelement</code> or <code>classpath refid</code>.
</a></li>
<li><a href="#winzip-lies">
Ant creates WAR files with a lower-case
<code>web-inf</code> or JAR files with a lower-case
<code>meta-inf</code> directory.
</a></li>
</ul>
</blockquote>
@@ -613,46 +630,7 @@
</td></tr>
</table>
</a>
<a name="always-recompiles">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>
Why does Ant always recompile all my Java files?
</strong>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>In order to find out which files should be compiled, Ant
compares the timestamps of the source files to those of the
resulting <code>.class</code> files. Opening all source files
to find out which package they belong to would be very
inefficient. Instead, Ant expects you to place your
source files in a directory hierarchy that mirrors your
package hierarchy and to point Ant to the root of this
directory tree with the <code>srcdir</code> attribute.</p>
<p>Say you have <code>&lt;javac srcdir="src"
destdir="dest"/&gt;</code>. If Ant finds a file
<code>src/a/b/C.java</code>, it expects it to be in package
<code>a.b</code> so that the resulting <code>.class</code>
file is going to be <code>dest/a/b/C.class</code>.</p>
<p>If your source-tree directory structure does not match your
package structure, Ant's heuristic won't work, and
it will recompile classes that are up-to-date. Ant is not the
only tool that expects a source-tree layout like this.</p>
<p>If you have Java source files that aren't declared to
be part of any package, you can still use the <code>&lt;javac&gt;</code>
task to compile these files correctly - just set the
<code>srcdir</code> and <code>destdir</code> attributes to
the actual directory the source
files live in and the directory the class files should go into,
respectively.</p>
</blockquote>
</td></tr>
</table>
</a>
<a name="passing-cli-args">
<a name="passing-cli-args">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
@@ -986,81 +964,6 @@ shell-prompt&gt; cat &lt; foo
</blockquote>
</td></tr>
</table>
</a>
<a name="defaultexcludes">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>
I've used a <code>&lt;delete&gt;</code> task to delete
unwanted
SourceSafe control files (CVS files, editor backup files, etc.), but
it doesn't seem to work; the files never get deleted. What's
wrong?
</strong>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>This is probably happening because, by default, Ant excludes
SourceSafe control files (<code>vssver.scc</code>) and certain other
files from FileSets.</p>
<p>Here's what you probably did:</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
&lt;delete&gt;
&lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;/&gt;
&lt;/delete&gt;
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>You need to switch off the default exclusions,
and it will work:</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
&lt;delete&gt;
&lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;
defaultexcludes=&quot;no&quot;/&gt;
&lt;/delete&gt;
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<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>
</blockquote>
</td></tr>
</table>
</a>
<a name="multi-conditions">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
@@ -1231,6 +1134,164 @@ shell-prompt&gt; cat &lt; foo
</blockquote>
</td></tr>
</table>
</a>
<a name="encoding">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>
How can I include national characters like German
umlauts in my build file?
</strong>
</font>
</td></tr>
<tr><td>
<blockquote>
<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>
<p>By default the parser assumes you are using the UTF-8
encoding instead of your platform's default. For most Western
European countries you should set the encoding to
<code>ISO-8859-1</code>. To do so, make the very first line
of you build file read like</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&gt;
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
</blockquote>
</td></tr>
</table>
</a>
<a name="always-recompiles">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>
Why does Ant always recompile all my Java files?
</strong>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>In order to find out which files should be compiled, Ant
compares the timestamps of the source files to those of the
resulting <code>.class</code> files. Opening all source files
to find out which package they belong to would be very
inefficient. Instead, Ant expects you to place your
source files in a directory hierarchy that mirrors your
package hierarchy and to point Ant to the root of this
directory tree with the <code>srcdir</code> attribute.</p>
<p>Say you have <code>&lt;javac srcdir="src"
destdir="dest"/&gt;</code>. If Ant finds a file
<code>src/a/b/C.java</code>, it expects it to be in package
<code>a.b</code> so that the resulting <code>.class</code>
file is going to be <code>dest/a/b/C.class</code>.</p>
<p>If your source-tree directory structure does not match your
package structure, Ant's heuristic won't work, and
it will recompile classes that are up-to-date. Ant is not the
only tool that expects a source-tree layout like this.</p>
<p>If you have Java source files that aren't declared to
be part of any package, you can still use the <code>&lt;javac&gt;</code>
task to compile these files correctly - just set the
<code>srcdir</code> and <code>destdir</code> attributes to
the actual directory the source
files live in and the directory the class files should go into,
respectively.</p>
</blockquote>
</td></tr>
</table>
</a>
<a name="defaultexcludes">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>
I've used a <code>&lt;delete&gt;</code> task to
delete unwanted SourceSafe control files (CVS files, editor
backup files, etc.), but it doesn't seem to work; the files
never get deleted. What's wrong?
</strong>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>This is probably happening because, by default, Ant excludes
SourceSafe control files (<code>vssver.scc</code>) and certain other
files from FileSets.</p>
<p>Here's what you probably did:</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
&lt;delete&gt;
&lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;/&gt;
&lt;/delete&gt;
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>You need to switch off the default exclusions,
and it will work:</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
&lt;delete&gt;
&lt;fileset dir=&quot;${build.src}&quot; includes=&quot;**/vssver.scc&quot;
defaultexcludes=&quot;no&quot;/&gt;
&lt;/delete&gt;
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<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>
</blockquote>
</td></tr>
</table>
</a>
<a name="stop-dependency">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
@@ -1293,78 +1354,58 @@ shell-prompt&gt; cat &lt; foo
<p>To get the files you want, focus on just the
<code>&lt;include&gt;</code> patterns that would be necessary
to get them. If you find you need to trim the list that the
<code>&lt;include&gt;</code> elements
produce, then use <code>&lt;exclude&gt;</code> elements.</p>
<code>&lt;include&gt;</code> elements produce, then use
<code>&lt;exclude&gt;</code> elements.</p>
</blockquote>
</td></tr>
</table>
</a>
<a name="encoding">
<a name="properties-not-trimmed">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>
How can I include national characters like German
umlauts in my build file?
<code>ant</code> failed to build my program via javac
even when I put the needed jars in an external
<code>build.properties</code> file and reference them by
<code>pathelement</code> or <code>classpath refid</code>.
</strong>
</font>
</td></tr>
<tr><td>
<blockquote>
<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>
<p>By default the parser assumes you are using the UTF-8
encoding instead of your platform's default. For most Western
European countries you should set the encoding to
<code>ISO-8859-1</code>. To do so, make the very first line
of you build file read like</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&gt;
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>When <code>ant</code> loads properties from an external
file it dosn't touch the value of properties, trailing blanks
will not be trimmed for example.</p>
<p>If the value represents a file path, like a jar needed to
compile, the task which requires the value, javac for example
would fail to compile since it can't find the file due to
trailing spaces.</p>
</blockquote>
</td></tr>
</table>
</a>
<a name="properties-not-trimmed">
<a name="winzip-lies">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>
<code>ant</code> failed to build my program via javac
even when I put the needed jars in an external
<code>build.properties</code> file and reference them by
<code>pathelement</code> or <code>classpath refid</code>.
Ant creates WAR files with a lower-case
<code>web-inf</code> or JAR files with a lower-case
<code>meta-inf</code> directory.
</strong>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>When <code>ant</code> loads properties from an external
file it dosn't touch the value of properties, trailing blanks
will not be trimmed for example.</p>
<p>If the value represents a file path, like a jar needed to
compile, the task which requires the value, javac for example
would fail to compile since it can't find the file due to
trailing spaces.</p>
<p>No it doesn't.</p>
<p>You may have seen these lower-case directory names in
WinZIP, but WinZIP is trying to be helpful (and fails). If
WinZIP encounters a filename that is all upper-case, it
assumes it has come from an old DOS box andchanges the case to
all lower-case for you.</p>
<p>If you extract (or just check) the archive with jar, you
will see that the names have the correct case.</p>
</blockquote>
</td></tr>
</table>


+ 118
- 98
xdocs/faq.xml View File

@@ -179,42 +179,7 @@
</faq>
</faqsection>

<faqsection title="Using Ant">
<faq id="always-recompiles">
<question>Why does Ant always recompile all my Java files?</question>
<answer>

<p>In order to find out which files should be compiled, Ant
compares the timestamps of the source files to those of the
resulting <code>.class</code> files. Opening all source files
to find out which package they belong to would be very
inefficient. Instead, Ant expects you to place your
source files in a directory hierarchy that mirrors your
package hierarchy and to point Ant to the root of this
directory tree with the <code>srcdir</code> attribute.</p>

<p>Say you have <code>&lt;javac srcdir=&quot;src&quot;
destdir=&quot;dest&quot;/&gt;</code>. If Ant finds a file
<code>src/a/b/C.java</code>, it expects it to be in package
<code>a.b</code> so that the resulting <code>.class</code>
file is going to be <code>dest/a/b/C.class</code>.</p>

<p>If your source-tree directory structure does not match your
package structure, Ant&apos;s heuristic won&apos;t work, and
it will recompile classes that are up-to-date. Ant is not the
only tool that expects a source-tree layout like this.</p>

<p>If you have Java source files that aren&apos;t declared to
be part of any package, you can still use the <code>&lt;javac&gt;</code>
task to compile these files correctly - just set the
<code>srcdir</code> and <code>destdir</code> attributes to
the actual directory the source
files live in and the directory the class files should go into,
respectively.</p>

</answer>
</faq>

<faqsection title="How do I ...">
<faq id="passing-cli-args">
<question>How do I pass parameters from the command line to my
build file?</question>
@@ -363,44 +328,6 @@ shell-prompt> cat < foo
</answer>
</faq>

<faq id="defaultexcludes">

<question>I&apos;ve used a <code>&lt;delete&gt;</code> task to delete
unwanted
SourceSafe control files (CVS files, editor backup files, etc.), but
it doesn&apos;t seem to work; the files never get deleted. What&apos;s
wrong?</question>

<answer>
<p>This is probably happening because, by default, Ant excludes
SourceSafe control files (<code>vssver.scc</code>) and certain other
files from FileSets.</p>

<p>Here&apos;s what you probably did:</p>


<source><![CDATA[
<delete>
<fileset dir="${build.src}" includes="**/vssver.scc"/>
</delete>
]]></source>

<p>You need to switch off the default exclusions,
and it will work:</p>
<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>

</answer>
</faq>

<faq id="multi-conditions">
<question>I want to execute a particular target only if
multiple conditions are true.</question>
@@ -523,6 +450,102 @@ shell-prompt> cat < foo
</answer>
</faq>
<faq id="encoding">
<question>How can I include national characters like German
umlauts in my build file?</question>

<answer>
<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>

<p>By default the parser assumes you are using the UTF-8
encoding instead of your platform's default. For most Western
European countries you should set the encoding to
<code>ISO-8859-1</code>. To do so, make the very first line
of you build file read like</p>

<source><![CDATA[
<?xml version="1.0" encoding="ISO-8859-1" ?>
]]></source>
</answer>
</faq>
</faqsection>

<faqsection title="It doesn&apos;t work (as expected)">
<faq id="always-recompiles">
<question>Why does Ant always recompile all my Java files?</question>
<answer>

<p>In order to find out which files should be compiled, Ant
compares the timestamps of the source files to those of the
resulting <code>.class</code> files. Opening all source files
to find out which package they belong to would be very
inefficient. Instead, Ant expects you to place your
source files in a directory hierarchy that mirrors your
package hierarchy and to point Ant to the root of this
directory tree with the <code>srcdir</code> attribute.</p>

<p>Say you have <code>&lt;javac srcdir=&quot;src&quot;
destdir=&quot;dest&quot;/&gt;</code>. If Ant finds a file
<code>src/a/b/C.java</code>, it expects it to be in package
<code>a.b</code> so that the resulting <code>.class</code>
file is going to be <code>dest/a/b/C.class</code>.</p>

<p>If your source-tree directory structure does not match your
package structure, Ant&apos;s heuristic won&apos;t work, and
it will recompile classes that are up-to-date. Ant is not the
only tool that expects a source-tree layout like this.</p>

<p>If you have Java source files that aren&apos;t declared to
be part of any package, you can still use the <code>&lt;javac&gt;</code>
task to compile these files correctly - just set the
<code>srcdir</code> and <code>destdir</code> attributes to
the actual directory the source
files live in and the directory the class files should go into,
respectively.</p>

</answer>
</faq>

<faq id="defaultexcludes">

<question>I&apos;ve used a <code>&lt;delete&gt;</code> task to
delete unwanted SourceSafe control files (CVS files, editor
backup files, etc.), but it doesn&apos;t seem to work; the files
never get deleted. What&apos;s wrong?</question>

<answer>
<p>This is probably happening because, by default, Ant excludes
SourceSafe control files (<code>vssver.scc</code>) and certain other
files from FileSets.</p>

<p>Here&apos;s what you probably did:</p>


<source><![CDATA[
<delete>
<fileset dir="${build.src}" includes="**/vssver.scc"/>
</delete>
]]></source>

<p>You need to switch off the default exclusions,
and it will work:</p>
<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>

</answer>
</faq>

<faq id="stop-dependency">
<question>I have a target I want to skip if a property is set,
so I have <code>unless=&quot;property&quot;</code> as an attribute
@@ -573,33 +596,11 @@ shell-prompt> cat < foo
<p>To get the files you want, focus on just the
<code>&lt;include&gt;</code> patterns that would be necessary
to get them. If you find you need to trim the list that the
<code>&lt;include&gt;</code> elements
produce, then use <code>&lt;exclude&gt;</code> elements.</p>
<code>&lt;include&gt;</code> elements produce, then use
<code>&lt;exclude&gt;</code> elements.</p>
</answer>
</faq>
<faq id="encoding">
<question>How can I include national characters like German
umlauts in my build file?</question>

<answer>
<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>

<p>By default the parser assumes you are using the UTF-8
encoding instead of your platform's default. For most Western
European countries you should set the encoding to
<code>ISO-8859-1</code>. To do so, make the very first line
of you build file read like</p>

<source><![CDATA[
<?xml version="1.0" encoding="ISO-8859-1" ?>
]]></source>
</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
@@ -618,6 +619,25 @@ shell-prompt> cat < foo
trailing spaces.</p>
</answer>
</faq>

<faq id="winzip-lies">
<question>Ant creates WAR files with a lower-case
<code>web-inf</code> or JAR files with a lower-case
<code>meta-inf</code> directory.</question>

<answer>
<p>No it doesn't.</p>

<p>You may have seen these lower-case directory names in
WinZIP, but WinZIP is trying to be helpful (and fails). If
WinZIP encounters a filename that is all upper-case, it
assumes it has come from an old DOS box andchanges the case to
all lower-case for you.</p>

<p>If you extract (or just check) the archive with jar, you
will see that the names have the correct case.</p>
</answer>
</faq>
</faqsection>

<faqsection title="Ant and IDEs/Editors">


Loading…
Cancel
Save