ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: Questions about the <war> task
Date Tue, 10 Oct 2000 16:03:54 GMT
>>>>> "MC" == Martin Cooper <> writes:

 MC> 1) For any error relating to a missing directory that I refer to,
 MC> Ant gives me an IllegalStateException with "basedir does not
 MC> exist".

Hmm, maybe you are using an older version of <war> than I am. I cannot
find any place where the task (or a superclass of it or FileSet) would
throw an IllegalStateException.

 MC> 2) Where should basedir normally point to?

Let me just point out how <war> is intended to be used - and please
help us clarify the documentation if it isn't:

When building web applications in our team at BoST there are several
"specialists" working in different directories - even using different
repositories for some things. 

I've found myself copying the static contents from our graphics
department and the HTML guys over to the place where the JSPs have
been built, creating a WEB-INF directory there and adding the
deployment descriptor as well as JAR files far too often.

<war> is just a simple <jar> task that tries to assemble scattered
pieces without the need to copy them into the "correct" directory
structure. So instead of

<mkdir dir="scratch/WEB-INF/lib" />
<copydir src="static-html-files" dest="scratch" />
<copydir src="graphics-from-somewhere-else" dest="scratch" />
<copydir src="some-jsps" dest="scratch" />
<copyfile src="deployment.descriptor" dest="scratch/WEB-INF/web.xml" />
<copyfile src="jdbc-driver.jar" dest="scratch/WEB-INF/lib/jdbc-driver.jar" />
<copyfile src="my-servlets.jar" dest="scratch/WEB-INF/lib/my-servlets.jar" />
<jar jarfile="myapp.war" basedir="scratch" />
<deltree dir="scratch" />

I've built a single task that builds the same file structure but
doesn't need a scratch dir or copying of files at all.

Let's leave basedir aside for a moment:

<lib> will put everything found under the given directory into
WEB-INF/lib (creating subdirectories you'll never be able to access if
dir points to a deeper structure).

<classes> will put everything found under the given directory into
WEB-INF/classes - the dir attribute should point to the root of a
class hierarchy.

<fileset> will simply put everything found into the war archive
without any leading directories. I hope this clear so far.

<war basedir="mydir" ... /> 

is the same as

<war ...>
  <fileset dir="mydir" />

Every file found in mydir (or anywhere down the directory starting
from basedir) will be added to the war archive with the path to
basedir stripped. <war> doesn't even try to ensure that things are not
included more than once.

Maybe the basedir attribute of <war> should be removed - forcing the
user to specify filesets for static content - to make the intent

 MC> 3) Is there a way to specify a <fileset> that refers to a
 MC> directory that may or may not exist, without incurring an error
 MC> if it does not?

No. You could simply create empty directories using <mkdir> (which
will do nothing if the directory already exists) to achieve this.


View raw message