在ANT构建中添加文件(Tomcat服务器)

时间:2010-05-12 13:53:13

标签: java tomcat ant

我有一个我需要设置的ANT版本,因此在部署.war时,某个文件将被放置在特定位置。目前,我的蚂蚁建立了如下战争......

<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>

我需要的文件名为Scriptlet.class,它需要在WebRoot / WEB-INF / classes /

我已经尝试了几件事来让它发挥作用并且尚未找到一个有效的......如果有人能指出我正确的方向,我会很感激!

2 个答案:

答案 0 :(得分:2)

使用classes元素将文件放入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>

答案 1 :(得分:1)

您可以使用嵌套的<classes>元素指定要在WEB-INF/classes中显示的FileSet。看看the manual page on the <war> task