Netbeans: Creating custom build target to let sources be packaged to JAR...?

ivan_ivanovich_ivanoff picture ivan_ivanovich_ivanoff · Aug 29, 2009 · Viewed 7.7k times · Source

I ask the question more specific:

Using Netbeans, is there a possibility to create an additional custom build target, which would:

  • either package all project sources along with the binaries into a singe JAR,
  • or package all project sources without the binaries into an additional JAR?

Notes:

  • It's not an option for me to modify the text field "Exclude from JAR file:" in the project properties, because it wouldn't provide me with an additional build target ;)
  • As you can guess, it's for an open source project ;)

Answer

ivan_ivanovich_ivanoff picture ivan_ivanovich_ivanoff · Aug 29, 2009

Thank to Mark's resource hint, I reduces the example to minimum complexity:

Following is done to pack only the sources:

<!-- depends="jar" have to stay:
    without it, we haven't the variable ${application.title} -->
<target name="MY-EXPORT-SOURCES" depends="jar">
    <echo>MY TARGET: PACKAGING ${application.title} SOURCES</echo>
    <delete file="dist/${application.title}.SOURCES.zip"/>
    <zip destfile="dist/${application.title}.SOURCES.zip" basedir="src"
        includes="**/*.java"/>
</target>

To run in Netbeans, do:
build.xml rightclick -> run targets -> other targets -> MY-EXPORT-SOURCES.