2006-09-11 04:19:00 +00:00
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
2001-02-13 12:32:01 +00:00
< html >
< head >
< meta http-equiv = "Content-Language" content = "en-us" >
2005-04-29 18:58:16 +00:00
< link rel = "stylesheet" type = "text/css" href = "../stylesheets/style.css" >
2002-02-03 22:00:42 +00:00
< title > WAR Task< / title >
2001-02-13 12:32:01 +00:00
< / head >
< body >
< h2 > < a name = "war" > War< / a > < / h2 >
< h3 > Description< / h3 >
< p > An extension of the < a href = "jar.html" > Jar< / a > task with special
treatment for files that should end up in the
< code > WEB-INF/lib< / code > , < code > WEB-INF/classes< / code > or
< code > WEB-INF< / code > directories of the Web Application Archive.< / p >
2006-07-28 11:21:47 +00:00
< p > (The War task is a shortcut for specifying the particular layout of a WAR file.
2001-02-13 12:32:01 +00:00
The same thing can be accomplished by using the < i > prefix< / i > and < i > fullpath< / i >
attributes of zipfilesets in a Zip or Jar task.)< / p >
< p > The extended zipfileset element from the zip task (with attributes < i > prefix< / i > , < i > fullpath< / i > , and < i > src< / i > ) is available in the War task.< / p >
2004-11-22 22:53:50 +00:00
< p > < b > Please note that the zip format allows multiple files of the same
fully-qualified name to exist within a single archive. This has been
documented as causing various problems for unsuspecting users. If you wish
to avoid this behavior you must set the < code > duplicate< / code > attribute
to a value other than its default, < code > " add" < / code > .< / b > < / p >
2001-02-13 12:32:01 +00:00
< h3 > Parameters< / h3 >
< table border = "1" cellpadding = "2" cellspacing = "0" >
< tr >
< td valign = "top" > < b > Attribute< / b > < / td >
< td valign = "top" > < b > Description< / b > < / td >
< td align = "center" valign = "top" > < b > Required< / b > < / td >
< / tr >
< tr >
2002-01-07 06:22:11 +00:00
< td valign = "top" > destfile< / td >
< td valign = "top" > the WAR file to create.< / td >
2003-04-17 13:09:19 +00:00
< td align = "center" valign = "top" rowspan = "2" > Exactly one of the two.< / td >
2001-02-13 12:32:01 +00:00
< / tr >
2002-06-22 23:38:38 +00:00
< tr >
< td valign = "top" > warfile< / td >
< td valign = "top" > < i > Deprecated< i > name of the file to create
-use < tt > destfile< / tt > instead.< / td >
2006-07-28 11:21:47 +00:00
< / tr >
2001-02-13 12:32:01 +00:00
< tr >
< td valign = "top" > webxml< / td >
< td valign = "top" > The deployment descriptor to use (WEB-INF/web.xml).< / td >
2001-12-11 14:55:45 +00:00
< td valign = "top" align = "center" > Yes, unless update is set to true< / td >
2001-02-13 12:32:01 +00:00
< / tr >
< tr >
< td valign = "top" > basedir< / td >
< td valign = "top" > the directory from which to jar the files.< / td >
< td valign = "top" align = "center" > No< / td >
< / tr >
< tr >
< td valign = "top" > compress< / td >
2003-08-05 16:13:02 +00:00
< td valign = "top" > Not only store data but also compress them,
defaults to true. Unless you set the < em > keepcompression< / em >
attribute to false, this will apply to the entire archive, not
only the files you've added while updating.< / td >
< td align = "center" valign = "top" > No< / td >
< / tr >
< tr >
< td valign = "top" > keepcompression< / td >
< td valign = "top" > For entries coming from existing archives (like
nested < em > zipfileset< / em > s or while updating the archive), keep
the compression as it has been originally instead of using the
< em > compress< / em > attribute. Defaults false. < em > Since Ant
1.6< / em > < / td >
2001-02-13 12:32:01 +00:00
< td align = "center" valign = "top" > No< / td >
< / tr >
2001-07-05 13:10:26 +00:00
< tr >
< td valign = "top" > encoding< / td >
< td valign = "top" > The character encoding to use for filenames
inside the archive. Defaults to UTF8. < strong > It is not
recommended to change this value as the created archive will most
likely be unreadable for Java otherwise.< / strong > < / td >
< td align = "center" valign = "top" > No< / td >
< / tr >
2001-07-12 07:36:50 +00:00
< tr >
< td valign = "top" > filesonly< / td >
< td valign = "top" > Store only file entries, defaults to false< / td >
< td align = "center" valign = "top" > No< / td >
< / tr >
2001-02-13 12:32:01 +00:00
< tr >
< td valign = "top" > includes< / td >
2002-06-22 23:38:38 +00:00
< td valign = "top" > comma- or space-separated list of patterns of files that must be
2001-02-13 12:32:01 +00:00
included. All files are included when omitted.< / td >
< td valign = "top" align = "center" > No< / td >
< / tr >
< tr >
< td valign = "top" > includesfile< / td >
< td valign = "top" > the name of a file. Each line of this file is
taken to be an include pattern< / td >
< td valign = "top" align = "center" > No< / td >
< / tr >
< tr >
< td valign = "top" > excludes< / td >
2002-06-22 23:38:38 +00:00
< td valign = "top" > comma- or space-separated list of patterns of files that must be
2001-02-13 12:32:01 +00:00
excluded. No files (except default excludes) are excluded when omitted.< / td >
< td valign = "top" align = "center" > No< / td >
< / tr >
< tr >
< td valign = "top" > excludesfile< / td >
< td valign = "top" > the name of a file. Each line of this file is
taken to be an exclude pattern< / td >
< td valign = "top" align = "center" > No< / td >
< / tr >
< tr >
< td valign = "top" > defaultexcludes< / td >
< td valign = "top" > indicates whether default excludes should be used or not
(" yes" /" no" ). Default excludes are used when omitted.< / td >
< td valign = "top" align = "center" > No< / td >
< / tr >
< tr >
< td valign = "top" > manifest< / td >
< td valign = "top" > the manifest file to use.< / td >
< td valign = "top" align = "center" > No< / td >
< / tr >
2001-08-30 13:23:14 +00:00
< tr >
< td valign = "top" > update< / td >
< td valign = "top" > indicates whether to update or overwrite
2003-04-11 13:31:18 +00:00
the destination file if it already exists. Default is " false" .< / td >
2001-08-30 13:23:14 +00:00
< td valign = "top" align = "center" > No< / td >
< / tr >
2002-07-30 10:38:56 +00:00
< tr >
< td valign = "top" > duplicate< / td >
< td valign = "top" > behavior when a duplicate file is found. Valid values are " add" , " preserve" , and " fail" . The default value is " add" . < / td >
< td valign = "top" align = "center" > No< / td >
< / tr >
2004-02-27 14:17:41 +00:00
< tr >
< td valign = "top" > roundup< / td >
< td valign = "top" > Whether the file modification times will be
rounded up to the next even number of seconds.< br >
Zip archives store file modification times with a granularity of
two seconds, so the times will either be rounded up or down. If
you round down, the archive will always seem out-of-date when you
rerun the task, so the default is to round up. Rounding up may
lead to a different type of problems like JSPs inside a web
archive that seem to be slightly more recent than precompiled
pages, rendering precompilation useless.< br >
2004-05-25 11:48:20 +00:00
Defaults to true. < em > Since Ant 1.6.2< / em > < / td >
2004-02-27 14:17:41 +00:00
< td align = "center" valign = "top" > No< / td >
< / tr >
2005-02-02 23:55:51 +00:00
< tr >
< td valign = "top" > level< / td >
< td valign = "top" > Non-default level at which file compression should be
performed. Valid values range from 0 (no compression/fastest) to 9
(maximum compression/slowest). < em > Since Ant 1.7< / em > < / td >
< td valign = "top" align = "center" > No< / td >
< / tr >
2001-02-13 12:32:01 +00:00
< / table >
< h3 > Nested elements< / h3 >
< h4 > lib< / h4 >
< p > The nested < code > lib< / code > element specifies a < a
href="../CoreTypes/fileset.html">FileSet< / a > . All files included in this fileset will
end up in the < code > WEB-INF/lib< / code > directory of the war file.< / p >
< h4 > classes< / h4 >
< p > The nested < code > classes< / code > element specifies a < a
href="../CoreTypes/fileset.html">FileSet< / a > . All files included in this fileset will
end up in the < code > WEB-INF/classes< / code > directory of the war file.< / p >
< h4 > webinf< / h4 >
< p > The nested < code > webinf< / code > element specifies a < a
href="../CoreTypes/fileset.html">FileSet< / a > . All files included in this fileset will
end up in the < code > WEB-INF< / code > directory of the war file. If this
fileset includes a file named < code > web.xml< / code > , the file is
ignored and you will get a warning.< / p >
2001-04-04 13:35:05 +00:00
< h4 > metainf< / h4 >
< p > The nested < code > metainf< / code > element specifies a < a
href="../CoreTypes/fileset.html">FileSet< / a > . All files included in this fileset will
end up in the < code > META-INF< / code > directory of the war file. If this
fileset includes a file named < code > MANIFEST.MF< / code > , the file is
ignored and you will get a warning.< / p >
2001-02-13 12:32:01 +00:00
< h3 > Examples< / h3 >
< p > Assume the following structure in the project's base directory:< / p >
< pre >
thirdparty/libs/jdbc1.jar
thirdparty/libs/jdbc2.jar
build/main/com/myco/myapp/Servlet.class
src/metadata/myapp.xml
src/html/myapp/index.html
src/jsp/myapp/front.jsp
src/graphics/images/gifs/small/logo.gif
src/graphics/images/gifs/large/logo.gif
< / pre >
then the war file < code > myapp.war< / code > created with
< pre >
2002-01-07 06:22:11 +00:00
< war destfile=" myapp.war" webxml=" src/metadata/myapp.xml" >
2001-02-13 12:32:01 +00:00
< fileset dir=" src/html/myapp" />
< fileset dir=" src/jsp/myapp" />
< lib dir=" thirdparty/libs" >
< exclude name=" jdbc1.jar" />
< /lib>
< classes dir=" build/main" />
2006-07-28 11:21:47 +00:00
< zipfileset dir=" src/graphics/images/gifs"
2001-02-13 12:32:01 +00:00
prefix=" images" />
< /war>
< / pre >
will consist of
< pre >
WEB-INF/web.xml
WEB-INF/lib/jdbc2.jar
WEB-INF/classes/com/myco/myapp/Servlet.class
META-INF/MANIFEST.MF
index.html
front.jsp
images/small/logo.gif
images/large/logo.gif
< / pre >
using Ant's default manifest file. The content of
< code > WEB-INF/web.xml< / code > is identical to
< code > src/metadata/myapp.xml< / code > .
2002-10-31 07:23:50 +00:00
2006-07-28 11:21:47 +00:00
< p > We regulary receive bug reports that this task is creating the WEB-INF
2002-10-31 07:23:50 +00:00
directory, and thus it is our fault your webapp doesn't work. The cause
of these complaints lies in WinZip, which turns an all upper-case
directory into an all lower case one in a fit of helpfulness. Please check that
jar xvf yourwebapp.war shows the same behaviour before filing another
2006-07-28 11:21:47 +00:00
report.< br / >
Winzip has an option allowing all uppercase names (which is off by default!). It can be enabled by:
Menu "Options" -> "Configuration", "View" property/tab page, then "General" group box has an option called "Allow all uppercase file names".
< / p >
2002-10-31 07:23:50 +00:00
2006-09-11 04:33:25 +00:00
2001-02-13 12:32:01 +00:00
< / body >
< / html >