Netbeans - 使用 Ant 将资源文件添加到 jar 文件 [英] Netbeans - adding resource files to jar file with Ant

查看:28
本文介绍了Netbeans - 使用 Ant 将资源文件添加到 jar 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在使用 Netbeans 6.9 的 Java 项目中将一些资源文件(基于非代码文本的文件)添加到 jar 文件中,我希望使用 Ant.我原以为这会相当简单……但经过大量搜索后,我找不到如何去做……!任何指向正确方向的指针?

I want add some resource files (non-code text-based files) to the jar file in a Java project using Netbeans 6.9, I'd expect using Ant. I had thought that this would be reasonably simple...but after quite a bit of searching I can't find how to do it..! Any pointers in the right direction?

推荐答案

我想我一直在寻找的答案如下:

The answer I think I was looking for is as follows:

在 build.xml 文件中(根据垃圾神的回答),您可以使用 ant 构建脚本中已有的钩子添加以下内容:

In the build.xml file (as per trashgod's answer) you can use the hooks already in the ant build script to add the following:

<target name="-post-jar">
    <echo>Adding files to jar...</echo>
    <jar destfile="dist/jarFileName.jar" update="true">
        <fileset dir="${basedir}">
            <include name="files/*"/>
        </fileset>
    </jar>
</target>

这会将 files 目录及其下的任何文件直接添加到 jar 文件中.

This adds the files directory and any files under it directly to the jar file.

这篇关于Netbeans - 使用 Ant 将资源文件添加到 jar 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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