Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ant: include resources in subdirectory to war file

I would like to include a set of resource files to my war file.

I know that I can specify either fileset or webinf as an inner element of my war element in build.xml, but in both of these cases, when I deploy the war file, the resource files end up in either top level directory or WEB-INF directory respectively.

I would like to place them into a subdirectory (say, WEB-INF/resources). Actually, these resource files are in a subdirectory in my source three already, I just need to include this subdirectory as is to the war file.

How is this done?

like image 476
akonsu Avatar asked Jan 23 '26 20:01

akonsu


1 Answers

You can use zipfileset with prefix attribute to add a subdirectory to zip/war file. If the resource files is in src/resource, and you want to pack them into WEB-INF/resource. Here is the example:

<target name="build">
    <war destfile="test.war">
        <fileset dir="webapps">
            <include name="**" />
        </fileset>
        <zipfileset dir="src/resource" prefix="WEB-INF/resource" />
    </war>
</target>
like image 59
Beck Yang Avatar answered Jan 25 '26 11:01

Beck Yang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!