How can I include a folder into the dist JAR as part of the build process using Netbeans?

浪子不回头ぞ 提交于 2019-12-04 04:02:33

问题


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.

So my question is How do I modify the build.xml file to put other folders in the jar?

I have the following directory structure for my project

ProjectDir/
/images/
/src/com/...
/lib/
and so on..

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

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

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.

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.


回答1:


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="**/*.*"
     />



回答2:


In case someone see this, copydir is deprecated now, use:

<target name="-post-compile">
    <copy todir="${dist.dir}/ace">
        <fileset dir="src/ace"/>
    </copy>
</target>


来源:https://stackoverflow.com/questions/3497019/how-can-i-include-a-folder-into-the-dist-jar-as-part-of-the-build-process-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!