源代码和 Javadoc jar 生成 [英] Source and Javadoc jar generation

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

问题描述

我觉得我的问题很简单.然而令人惊讶的是,我找不到任何简单的解决方案.

I think my question is easy. However it is surprising that I couldn't find any easy solution.

我正在 Netbeans 上开发一个开源 Java 库项目,和许多其他项目一样,我想将它发布为 binary.jar、source.jar 和 javadoc.jar.

I'm developing an open source Java library project on Netbeans and like many others I want to release it as binary.jar, source.jar and javadoc.jar.

有没有办法在 Netbeans 上自动生成它们?我知道 maven 可以做到.但是学习曲线似乎太长了.

Is there a way to generate them automatically on Netbeans? I know maven can do it. But the learning curve seems too long.

有一个类似的问题,但唯一的答案不起作用:在 Netbeans 中自动生成源和文档 jar

There is a similar question but the only answer didn't work: Automatically generating source and doc jars in Netbeans

推荐答案

这是我最后想出的解决方案.它使用 Ant 并生成 javadoc 和源 jar.然后它将二进制 jar、javadoc、source.jar、许可和自述文件归档到一个准备发布的 zip 文件中.

Here is the solution I came up with at the end. It uses Ant and generates javadoc and source jar. Then it archives binary jar, javadoc, source.jar, licence and readme file in to a zip file that is ready to release.

 <target name="-pre-init">
    <property file="version.properties"/>
    <property name="dist.jar" value="dist/${ant.project.name}-${project.version}.jar"/>
</target>

<target description="bundle sources in a jar" name="package-sources">
    <jar basedir="src" destfile="build/release/${ant.project.name}-${project.version}-sources.jar"/>
</target>


<target name="package_for_release" depends="jar,javadoc, package-sources">
    <mkdir dir="build/release"/>
    <copy file="${dist.jar}" todir="build/release/"/>
    <copy file="licence.txt" todir="build/release/"/>
    <copy file="beni_oku.txt" todir="build/release/"/>
    <mkdir dir="build/release/doc"/>
    <copy todir="build/release/doc">
        <fileset dir="dist/javadoc" includes="**"/>
    </copy>

    <zip basedir="build/release/" includes="**" destfile="dist/${ant.project.name}-${project.version}.zip"/>
</target>

在 NetBeans 中打开 build.xml,然后右键单击 -> 运行目标 -> [其他目标] -> package_for_release

Open build.xml in NetBeans than right click - > run target -> [other targets] -> package_for_release

脚本从属性文件中获取版本号.我从 这里.

Script gets the version number from a properties file. I got this solution from here.

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

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