如何在特定位置通过 Ant 在 Jar 中包含文件 [英] How to include file in Jar through Ant at specific location

查看:23
本文介绍了如何在特定位置通过 Ant 在 Jar 中包含文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个蚂蚁罐子任务:

I've got an ant jar task:

<target name="jar">
    <jar destfile="${generated.jars.dir}/hello-${environment}.jar">
        <fileset dir="${generated.classes.dir}"/>
        <fileset dir="${environment.dir}/${environment}" includes="config.xml"/>
    </jar>
</target>

如何强制将 config.xml 文件推送到 jar 中的特定目录,而不是在根级别,例如/database/config.xml 或类似内容...

How can I force the config.xml file to be pushed to a specific directory in the jar rather than at the root level, say in /database/config.xml or something like that...

PS:这样做的原因是我可以有hello-local.jar、hello-dev.jar、hello-qa.jar等

PS: The reason for doing this is that I can have a hello-local.jar, hello-dev.jar, hello-qa.jar, etc.

推荐答案

使用 zipfileset 像这样:

Use a zipfileset like this:

<jar destfile="${generated.jars.dir}/hello-${environment}.jar">
    <fileset dir="${generated.classes.dir}"/>
    <zipfileset dir="${environment.dir}/${environment}" 
                includes="config.xml"
                fullpath="database/config.xml"/>
</jar>

这篇关于如何在特定位置通过 Ant 在 Jar 中包含文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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