开发者

Copy Ant path to WAR's lib directory

I think this is probably a common use case. I define a set of paths:

<path id="log4j.classpath">
    <fileset dir="${log4j.home}">
        <include name="log4j-1.2.16.jar"/>
    </fileset>
</path>
<path id="junit.classpath">
    <fileset dir="${junit.home}">
        <include name="junit-4.8.2.jar"/>
    </fileset>
</path>
<path id="all.classpath">
    <path refid="log4j.classpath"/>
    <path refid="junit.classpath"/>
</path>

When I build my web service I have:

<target name="compile">
    <javac srcdir="${basedir}/src" destdir="${build.classes.dir}" debug="true">
        <开发者_JAVA百科classpath>
            <path refid="all.classpath"/>
        </classpath>
    </javac>
</target>

Now, I want to copy all the files in the path with id all.classpath into my war's lib directory. What is the best way to do this?

Currently, I have something like this:

<copy todir="${war-lib}" verbose="true">
    <fileset dir="${log4j.home}">
        <include name="log4j-1.2.16.jar" />
    </fileset>
    <fileset dir="${junit.home}">
        <include name="junit-4.8.2.jar"/>
    </fileset>
<copy>

But I don't want to have to re-define the filesets. That seems to be error-prone, and a bad design. There has got to be a better way. Please enlighten me.

EDIT: To make it interesting, I only have access to ANT 1.6


Not sure if it will work, but try this (you'll need Ant 1.7 or higher to do this):

<copy todir="${war-lib}" verbose="true">
    <path><path refid="all.classpath" /></path>
</copy>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜