Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ant war task to include files in WEB-INF directory

I'm using ant to build my web-app. I'm sure this is simple but I can't figure out how to tell ant to create a specific folder in the WEB-INF directory and copy files to it.

My ant war task looks like this:

<target name="warItUp" depends="compile">
    <war destfile="MyApp.war" webxml="${home.dir}\WEB-INF\web.xml">

        <classes dir="${classes.dir}"/>
        <classes file="${src.dir}/hibernate.cfg.xml"/>
        <classes dir="${src.dir}" includes="**/*.hbm.xml"/>

        <!-- Include the PDF files -->
        <fileset dir="${home.dir}/PDFs">
            <include name="**/*.pdf"/>
        </fileset>

        <!-- Include the JSP files -->
        <fileset dir="${home.dir}/JSPs">
            <include name="**/*.jsp"/>
        </fileset>

        <!-- Include the images -->
        <fileset dir="${home.dir}/images">
            <include name="**/*"/>
        </fileset>          
    </war>

All the fileset elements work i.e. they include the pdf, jsp and image files in the root directory of the war file.

But if I want to create a sub-directory in the WEB-INF directory of the war file and include files in it how do I specify that? e.g. say I wanted to include WEB-INF/TagLibraryDescriptors/MyTagLib.tld in the war file or if I wanted to create a WEB-INF/JSP folder in my war file and copy all JSP files to it.

Thanks.

like image 509
CodeClimber Avatar asked Feb 02 '11 11:02

CodeClimber


1 Answers

OP here, thanks for all the responses. I found another solution - there is a webinf element that can be included in the war task.

This will copy files from the source JSPs folder into the WEB-INF folder in the war file:

<webinf dir="${home.dir}/JSPs" 
includes="**/*.jsp">
</webinf>

whereas this will copy files from the source JSPs folder into the WEB-INF/JSPs folder (my preferred choice):

<webinf dir="${home.dir}" 
includes="/JSPs/**/*.jsp">
</webinf>

I think I'll stick with this solution but thanks for the responses.

like image 54
CodeClimber Avatar answered Sep 28 '22 04:09

CodeClimber