包括在战争中使用ANT目录 [英] Include directory in WAR using ANT

查看:144
本文介绍了包括在战争中使用ANT目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ANT一个bulding的战争文件,我想包括src目录到war文件。当我使用的文件集的元素,只有该文件夹的内容也包括在内。我想src目录被包含到WEB-INF文件夹。我不想来源复制到WEB-INF文件夹在磁盘上。蚂蚁正确包括从我的lib目录放到WEB-INF / lib中的jar文件没有在我的项目复制它们。

所以我有这样的事情:
结果
结果/ WEB-INF
结果/ WEB-INF / src目录
结果/ WEB-INF / classes中
结果/ WEB-INF / lib目录
结果/ META-INF

目标看起来是这样的:

 <目标名称=战争取决于=初始化>
    <战争destfile =DIST / web.war中webxml =的WebContent / WEB-INF / web.xml文件>
        <文件集DIR =的WebContent/>
        < lib目录=的WebContent / WEB-INF / lib目录/>
        < lib目录=lib目录/>
        <类DIR =建立/班/>
        <类DIR =配置/>
    < /战争>
< /目标与GT;


解决方案

我假设你正在尝试包括SRC是这样的:

 <文件集DIR =SRC/>

如果您使用它应该工作:

 <文件集DIR =。包括=SRC / **/>

如果您需要将一个文件或目录到一个特定的路径在战争中,你可以使用 zipfileset ,而不是和它的preFIX属性,如:

 < zipfileset DIR =。包括=SRC / **preFIX =WEB-INF/>

(另见战争任务文档的例子,其中包括zipfileset的使用)。

I am bulding 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>

解决方案

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

这篇关于包括在战争中使用ANT目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆