Include directory in WAR using Ant

元气小坏坏 提交于 2019-12-22 09:49:56

问题


I am building a war file using ANT and I want to include the src directory into the war file. When I use the fileset element, only the content of that folder is included. I want the src directory to be included into the WEB-INF folder. I don't want to copy the sources to the WEB-INF folder on disk. Ant properly includes the jars from my lib directory into WEB-INF/lib without copying them in my project.

So I will have something like this:

/WEB-INF
/WEB-INF/src
/WEB-INF/classes
/WEB-INF/lib
/META-INF

The target looks like this:

<target name="war" depends="init">
    <war destfile="dist/web.war" webxml="WebContent/WEB-INF/web.xml">
        <fileset dir="WebContent"/>
        <lib dir="WebContent/WEB-INF/lib"/>
        <lib dir="lib"/>
        <classes dir="build/classes"/>
        <classes dir="config"/>
    </war>
</target>

回答1:


I assume you were trying to include src something like this:

<fileset dir="src"/>

It should work if you use this:

<fileset dir="." includes="src/**"/>

If you need to put a file or dir to a specific path in the war, you can use zipfileset instead and its prefix attribute, e.g.

<zipfileset dir="." includes="src/**" prefix="WEB-INF"/>

(See also examples in the war task documentation, which include usage of zipfileset).



来源:https://stackoverflow.com/questions/8785786/include-directory-in-war-using-ant

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!