且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

源代码和 Javadoc jar 生成

更新时间:2022-01-25 01:37:25

这是我最后想出的解决方案.它使用 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.