如何在 ant jar 文件中包含目录结构? [英] How to include directory structure in an ant jar file?

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

问题描述

我有点像蚂蚁新手,我无法正确制作罐子.例如,假设我想用我的 StringUtil 类制作一个 jar.使用下面的ant指令,我可以创建jar,但问题是目录结构丢失了.它只是将 StringUtil.class 放在 jar 的基本目录中.如何更正此 ant 指令,使 StringUtil.class 位于 jar 中的 com/test 目录中?

I am a bit of an ant newbie, and I'm having trouble making a jar correctly. As an example, say I want to make a jar with my StringUtil class. Using the following ant directive, I can create the jar, but the problem is that the directory structure is lost. It simply puts StringUtil.class in the base directory of the jar. How can I correct this ant directive so that StringUtil.class is inside the com/test directory in the jar?

<jar destfile="myjar.jar" >
  <fileset file="${build}/com/test/StringUtil.class"/>
</jar>

谢谢!

推荐答案

您需要告诉 Ant 从基目录构建 jar,然后告诉它只包含所需的文件.像这样:

You need to tell Ant to build the jar from the base directory, then tell it to include only the desired file. Like so:

<jar destfile="myjar.jar" >
  <fileset dir="${build}" includes="com/test/StringUtil.class"/>
</jar>

这是 标签.

Here's the doc for <fileset> tags.

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

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