[英]How do I combine multiple Jar files into one deliverable Jar?
I have been researching trying to find a way to combine multiple Jar files into on Jar as a deliverable. 我一直在研究如何找到一种方法将多个Jar文件组合到Jar上作为可交付成果。
In a directory I have an ant file named Jar_gen.xml that consists of the following code in its entirety 在一个目录中,我有一个名为Jar_gen.xml的ant文件,它完整地包含以下代码
<target name="combine-jars">
<jar destfile="out.jar">
<zipgroupfileset dir="lib" includes="*.jar"/>
</jar>
</target>
In that same directory I have another directory named lib which contains all of the Jar files I would like to flatten. 在同一目录中,我有另一个名为lib的目录,其中包含我想要展平的所有Jar文件。
I have been running the ant script with 我一直在运行ant脚本
ant -buildfile Jar_gen.xml
making sure that I am running it from the same directory that the Jar_gen.xml file is in. 确保我从Jar_gen.xml文件所在的目录运行它。
I am getting no output from my ant script and I have not idea why. 我的蚂蚁脚本没有输出,我不明白为什么。 Can someone please help me fix my script so I may flatten all of my jars and continue constructing my deliverable package.
有人可以帮我修复我的脚本,这样我就可以压扁所有的罐子并继续构建我的可交付包。
NOTE 注意
I have no main class so the Eclipse runnable Jar will not work for me 我没有主类,所以Eclipse可运行的Jar对我不起作用
I have very little experience running Ant scripts so complete answers would be very helpful. 我在运行Ant脚本方面经验很少,所以完整的答案会非常有帮助。
Is your directory structure set up correctly? 您的目录结构是否设置正确?
I created a quick test using your script and it appears to work, given that you have everything set up in a directory structure as 我使用你的脚本创建了一个快速测试,它似乎工作,因为你已经在目录结构中设置了所有内容
project_root_dir
- build.xml
- lib
- a.jar
- b.jar
and build.xml looks like: 和build.xml看起来像:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="test">
<target name="combine-jars">
<jar destfile="out.jar">
<zipgroupfileset dir="lib" includes="*.jar"/>
</jar>
</target>
</project>
when I go to the project_root_dir and run "ant combine-jars", I get an out.jar that contains the contents of both a.jar and b.jar. 当我去project_root_dir并运行“ant combine-jars”时,我得到一个包含a.jar和b.jar内容的out.jar。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.