Automatically generating source and doc jars in Netbeans

后端 未结 3 1172
广开言路
广开言路 2020-12-31 09:17

Is there a way to automatically generate source and javadoc jars in Netbeans? Ideally I would like to place jars of my source and JavaDoc in the dist folder each time i buil

相关标签:
3条回答
  • 2020-12-31 09:30

    I tried the following on NetBeans IDE 7.2 and it works (assuming that the project name is MyProject)

    1. go to the MyProject directory

    2. open build.xml file in a text editor

    3. add the following lines under the line <import file="nbproject/build-impl.xml"/>:

      <target name="-post-jar" description="bundle sources and javadoc in a jar" depends="javadoc"> <jar compress="${jar.compress}" basedir="${src.dir}" jarfile="${dist.dir}/${application.title}-sources.jar"/> <jar compress="${jar.compress}" basedir="${dist.javadoc.dir}" jarfile="${dist.dir}/${application.title}-javadoc.jar"/> </target>

    4. go to nbproject folder and open the project.properties file in a text editor

    5. edit the name of the output binary file (set to the project name.jar by default): # This directory is removed when the project is cleaned: dist.dir=dist dist.jar=${dist.dir}/**MyProject-binaries**.jar

    6. save and build project.

    Hope it works with you too.

    0 讨论(0)
  • 2020-12-31 09:36

    Please try adding this to build.xml. I've tested it on NetBeans IDE 7.0

    <target name="-post-jar" description="bundle sources and javadoc in a jar" depends="javadoc">
        <jar compress="${jar.compress}" basedir="${src.dir}" jarfile="${dist.dir}/${application.title}-sources.jar"/>
        <jar compress="${jar.compress}" basedir="${test.src.dir}" jarfile="${dist.dir}/${application.title}-test.jar"/>
        <jar compress="${jar.compress}" basedir="${dist.javadoc.dir}" jarfile="${dist.dir}/${application.title}-javadoc.jar"/>
    </target>
    
    0 讨论(0)
  • 2020-12-31 09:52

    Here is what I personally add to my ant files (build.xml) :

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

    With Netbeans call these targets manually, or you can use hook targets :

    <target name="-post-jar" depends="package-sources, package-doc" />
    
    0 讨论(0)
提交回复
热议问题