如何构建我的 jar 文件,以便使用该库的用户能够在 Eclipse 中看到 javadoc [英] How can I build my jar file so that users who use the library will be able to see the javadoc in Eclipse

查看:21
本文介绍了如何构建我的 jar 文件,以便使用该库的用户能够在 Eclipse 中看到 javadoc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个供公司内部使用的小型图书馆,并且已经对其进行了大量记录.现在我正在使用以下代码构建我的 jar:

I'm working on a small library for our in-company use, and have been heavily documenting it. Now I'm building my jar with the following code:

<project name="commonutils" default="compile" basedir="."> 

    <property name="src" location="src" />

    <property name="build" location="buildDirecotry" />

    <target name="compile">
        <delete file="${ant.project.name}.jar" />
        <mkdir dir="${build}"/>
        <javac srcdir="${src}" destdir="${build}" debug="on" target="1.5">
            <classpath>
                <pathelement location="lib/build/server.zip" />
                <pathelement path="${java.class.path}/"/>
            </classpath>
        </javac>
        <jar basedir="${build}" destfile="${ant.project.name}.jar" />
        <delete dir="${build}" />
    </target>

</project>

工作正常,它使用其中的所有 src 文件构建我的 jar 文件,但是当我将 jar 文件包含在另一个项目中时,我不再有任何 javadoc 注释.使用 JDDecompiler 我看不到类文件中的注释,尽管我不确定是剥离它们的 Java 编译器还是 JD.

Which works fine, it builds my jar file with all the src files in it, but when I include the jar file in another project I no-longer have any of my javadoc comments. Using JDDecompiler I cannot see the comments in the class file, although I'm not sure if its the java compiler that's stripping them or JD.

我的问题是:如何构建我的 jar 文件,以便使用该库的用户能够在 Eclipse 中看到 javadoc.

My question is: How can I build my jar file so that users who use the library will be able to see the javadoc in Eclipse.

推荐答案

如果您将源文件包含在 jar 中(每个类和 java 文件都在同一个包目录中),它应该可以工作.

If you include the source files in the jar (each class and java file in the same package-directory) it should work.

<target name="jar.noCompile.src">  
    <jar destfile="${ant.project.name}.jar">  
      <fileset dir="${build}"/>  
      <fileset dir="${src}" includes="**/*.java"/>  
    </jar>  
</target>  

这篇关于如何构建我的 jar 文件,以便使用该库的用户能够在 Eclipse 中看到 javadoc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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