使用 Ant 生成带有源代码的 jars [英] generate jars with source code using Ant

查看:25
本文介绍了使用 Ant 生成带有源代码的 jars的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 ant 在 Eclipse 中创建 .jar 文件.

I use ant for creating .jar files in Eclipse.

我需要为我的项目生成 jar,其中还包含源代码和类文件.我们该怎么做?

I need to generate jar for my project which also contains source code along with the class file. How do we do it?

另一个问题:什么是调试 jar 以及如何使用 ant 创建它?(在某处听说过它并试图将它们联系起来)

Another question: what is a debug jar and how to create it using ant? (have heard about it somewhere and trying to relate them both)

推荐答案

我会修改您的 jar 任务以包含多个文件集;一种用于类,一种用于源文件.

I would modify your jar task to include multiple filesets; one for the classes and one for the source files.

<jar destfile="${target.dir}/my-app.jar">
    <fileset dir="${target.dir}/classes" />
    <fileset dir="${src.dir}" includes="**/*.java"/>
</jar>

打包应该与编译分开处理.这会给你更多的灵活性.例如,您可能希望将其他文件集添加到 jar(例如属性文件),或者您可能希望将源代码打包到一个与类文件分开的 jar 文件中.

Packaging should be treated as a separate concern from compiling. This will give you more flexibility. For example, you may want to add other filesets to the jar (e.g. properties files), or you may want to package your sources in a jar file that is separate from your class files.

这篇关于使用 Ant 生成带有源代码的 jars的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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