tags:

views:

30

answers:

2

Hey everyone,

I have an ANT build that I need to setup so on deployment of the .war a certain file will be placed in a specific location. Currently my ant builds the war as follows...

<target name="war" depends="jar">

    <war destfile="${deploy}/file.war" webxml="${web-inf}/web.xml">

        <fileset dir="${WebRoot}">
            <include name="**/*.vm" />
            <include name="**/*.js" />
            <include name="**/*.jsp" />
            <include name="**/*.html" />
            <include name="**/*.css" />
            <include name="**/*.gif" />
            <include name="**/*.jpg" />
            <include name="**/*.png" />
            <include name="**/*.tld" />
            <include name="**/applicationContext*.xml" />
            <include name="**/jpivot/**" />
            <include name="**/wcf/**" />
            <include name="**/platform/**" />
            <include name="**/Reports/**" />
        </fileset>

        <lib dir="${web-inf.lib}" />

    </war>

</target>

The file I need is called Scriptlet.class and it needs to be in WebRoot/WEB-INF/classes/

I've tried several things to get this to work and have yet to find one that works... if anyone can point me in the right direction I'd appreciate it!

+1  A: 

You can use the nested <classes> element to specify a FileSet to appear in WEB-INF/classes. Take a look at the manual's page on the <war> task.

matt b
So... <classes dir="blah/blah"> the dir in this tag would point to the folder where my file is originally located?
Shaded
should point to the location of your compiled output (the .class files) - try it and see if it works?
matt b
I gotcha, +1 for trying to teach me!
Shaded
+2  A: 

Use the classes element to put a file in WEB-INF/classes :

<target name="war" depends="jar">
    <war destfile="${deploy}/file.war" webxml="${web-inf}/web.xml">
        <classes dir="${web-inf.classes}">
          <include name="**/Scriptlet.class"/>
        </classes>
        <fileset dir="${WebRoot}">
            <include name="**/*.vm" />
            <include name="**/*.js" />
            <include name="**/*.jsp" />
            <include name="**/*.html" />
            <include name="**/*.css" />
            <include name="**/*.gif" />
            <include name="**/*.jpg" />
            <include name="**/*.png" />
            <include name="**/*.tld" />
            <include name="**/applicationContext*.xml" />
            <include name="**/jpivot/**" />
            <include name="**/wcf/**" />
            <include name="**/platform/**" />
            <include name="**/Reports/**" />
        </fileset>
        <lib dir="${web-inf.lib}" />
    </war>
</target>
madgnome
Awesome! that's exactly what I needed +1
Shaded