如何使用 Ant 在 jar 中包含数据文本文件? [英] How can I include data text files in a jar using Ant?

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

问题描述

在我的 src 文件夹中有另一个名为 data 的文件夹,其中包含文件 data1.txt 和 data2.txt.应用程序在初始化时从这些文件加载​​图形,因此我想将这些文件包含在我的最终 jar 中.我使用 Ant 生成 jar 文件.

In my src folder there is another folder called data which contains files data1.txt and data2.txt. The application loads a graph from these files in the initialization, so I want to include these files in my final jar. I use Ant to produce the jar file.

推荐答案

Example from http://ant.apache.org/manual/Tasks/jar.html :

Example from http://ant.apache.org/manual/Tasks/jar.html :

  <jar destfile="${dist}/lib/app.jar">
    <fileset dir="${build}/classes"/>
    <fileset dir="${src}/resources"/>
  </jar>

所以基本上你会希望以与上面包含资源"相同的方式包含数据文件.

So basically you would want to include the data-files in the same way as "resources" are included above.

来自 任务的文档:

可以优化被 jar 的文件集.这可以通过包含、包含文件、排除、排除文件和默认排除属性来完成.

It is possible to refine the set of files that are being jarred. This can be done with the includes, includesfile, excludes, excludesfile and defaultexcludes attributes.

这篇关于如何使用 Ant 在 jar 中包含数据文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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