如何在使用 Netbeans 的构建过程中将文件夹包含到 dist JAR 中? [英] How can I include a folder into the dist JAR as part of the build process using Netbeans?

查看:26
本文介绍了如何在使用 Netbeans 的构建过程中将文件夹包含到 dist JAR 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Netbeans 6.9,我研究了编辑 build.xml 文件,以便我可以在生成项目的 jar 文件中包含目录和文件.

I'm using Netbeans 6.9 , and I have looked into editing the build.xml file so that I can include directories and files in the jar file that results from building the project.

所以我的问题是如何修改 build.xml 文件以将其他文件夹放入 jar 中?

我的项目有以下目录结构

I have the following directory structure for my project

项目目录/
/图像/
/src/com/...
/lib/
等等..

而且我希望由 ant 构建脚本构建的 jar 文件看起来像

And I want the jar file built by the ant build script to look like

project.jar
/com
/lib -- 这应该包括 lib 文件夹中的 jar 文件
/images -- 这应该包括 jpg 文件
/META-INF

project.jar
/com
/lib --this should include the jar files inside the lib folder
/images --this should include the jpg files
/META-INF

我需要这样做,因为我将 jar 文件作为自定义组件安装"到 Adob​​e Livecycle 中,并且所有 lib jar 文件和图像都需要包含在 jar 中.

I need to do this because I "install" the jar file into Adobe Livecycle as a custom component and all of the lib jar files and images need to be included in the jar.

此外,如果有一种方法可以在不使用 build.xml 文件的情况下执行此操作,也可以,目前我只是将文件夹/文件复制到 jar 文件中.

Also if there is a way to do this without using the build.xml file that would be fine also, currently I'm just copy the folders/files into the jar file.

推荐答案

http://ant.apache.org/manual/Tasks/copydir.html

  <copydir src="${base.path}/lib/"
           dest="${build.path}/lib"
  />

  <copydir src="${base.path}/images/"
           dest="${build.path}/images"
  />

  <copydir src="${base.path}/src/com/"
           dest="${build.path}/com"
  />
  <copydir src="${base.path}/META-INF/"
           dest="${build.path}/META-INF"
  />

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

<jar destfile="project.jar"
     basedir="${build.path}"
     includes="**/*.*"
     />

这篇关于如何在使用 Netbeans 的构建过程中将文件夹包含到 dist JAR 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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