Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   ant mixes up file hierarchy within war file (http://www.velocityreviews.com/forums/t135649-ant-mixes-up-file-hierarchy-within-war-file.html)

Werner Butscher 07-28-2004 10:20 AM

ant mixes up file hierarchy within war file
 
Hello everyone,

I use ant for building my jar and war files. Since I added two
property files directly to the WEB-INF directory of my servlet, the
war file is not packed correctly anymore.

My directoy structure should be like this:

/META-INF
/WEB-INF
classes/
lib/
web.xml
log4j.properties
database.props

The problem is, the last two files will be packed directly at root
level instead at /WEB-INF

I tried all combinations of filesets, patternsets, revied older build
files etc but could not find the reason. The target in the current
build file looks like this:

(where build.dir is WEB-INF)

<target name="war" depends="compile">
<delete dir="${war.dir}"/>
<mkdir dir="${war.dir}"/>
<war warfile="${war.dir}/${project}.war"
webxml="${build.dir}/web.xml">
<fileset dir="${build.dir}">
<exclude name="web.xml"/>
<exclude name="**/*.bak"/>
<exclude name="**/*.class"/>
<exclude name="**/*.java"/>
<exclude name="lib/"/>
<exclude name="classes/"/>
<include name="**/*.props"/>
<include name="**/*.properties"/>
</fileset>
<classes dir="${build.dir}/classes"/>
<lib dir="${lib.dir}">
<include name="*.jar"/>
</lib>
<lib dir="${servletlibs.dir}">
<include name="*.jar"/>
</lib>
<lib dir="${cmlib.dir}">
<include name="*.jar"/>
</lib>
<lib dir="${cmclasses.dir}">
<include name="*.jar"/>
</lib>
</war>
</target>

I also checked the compile task and removed it, still the same, the
problem must be somewhere here...

Any help would be appreciated... :-}

Werner

Oscar kind 07-28-2004 03:51 PM

Re: ant mixes up file hierarchy within war file
 
Werner Butscher <publicis@infinitebizz.de> wrote:
> I use ant for building my jar and war files. Since I added two
> property files directly to the WEB-INF directory of my servlet, the
> war file is not packed correctly anymore.
>
> My directoy structure should be like this:
>
> /META-INF
> /WEB-INF
> classes/
> lib/
> web.xml
> log4j.properties
> database.props
>
> The problem is, the last two files will be packed directly at root
> level instead at /WEB-INF

[...]

> (where build.dir is WEB-INF)
>
> <target name="war" depends="compile">
> <delete dir="${war.dir}"/>
> <mkdir dir="${war.dir}"/>
> <war warfile="${war.dir}/${project}.war"
> webxml="${build.dir}/web.xml">
> <fileset dir="${build.dir}">
> <exclude name="web.xml"/>
> <exclude name="**/*.bak"/>
> <exclude name="**/*.class"/>
> <exclude name="**/*.java"/>
> <exclude name="lib/"/>
> <exclude name="classes/"/>
> <include name="**/*.props"/>
> <include name="**/*.properties"/>
> </fileset>


Instead of a fileset, use a zipfileset and specify the "prefix" attribute.
With it, you can specify the subdirectory to place the files in.

> <classes dir="${build.dir}/classes"/>
> <lib dir="${lib.dir}">
> <include name="*.jar"/>
> </lib>
> <lib dir="${servletlibs.dir}">
> <include name="*.jar"/>
> </lib>
> <lib dir="${cmlib.dir}">
> <include name="*.jar"/>
> </lib>
> <lib dir="${cmclasses.dir}">
> <include name="*.jar"/>
> </lib>
> </war>
> </target>



--
Oscar Kind http://home.hccnet.nl/okind/
Software Developer for contact information, see website

PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2

Werner Butscher 08-02-2004 10:08 AM

Re: ant mixes up file hierarchy within war file
 
great, this worked, thankyou:

<war destfile="${war.dir}/${project}.war" webxml="${build.dir}/web.xml">
<zipfileset dir="${build.dir}" prefix="WEB-INF" >
<exclude name="web.xml"/>
<exclude name="**/*.bak"/>
<exclude name="**/*.class"/>
<exclude name="**/*.java"/>
<exclude name="lib/"/>
<exclude name="classes/"/>
<include name="database.props"/>
<include name="log4j_servlet.properties"/>
</zipfileset>
<classes dir="${build.dir}/classes"/>
<lib dir="${lib.dir}">
<include name="*.jar"/>
</lib>
<lib dir="${servletlibs.dir}">
<include name="*.jar"/>
</lib>
<lib dir="${cmlib.dir}">
<include name="*.jar"/>
</lib>
<lib dir="${cmclasses.dir}">
<include name="*.jar"/>
</lib>
</war>


All times are GMT. The time now is 09:38 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.