Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 ;)
like image 977
ivan_ivanovich_ivanoff Avatar asked Dec 30 '22 16:12

ivan_ivanovich_ivanoff


2 Answers

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.

like image 129
ivan_ivanovich_ivanoff Avatar answered Feb 06 '23 15:02

ivan_ivanovich_ivanoff


Check this out:

http://java.sun.com/developer/technicalArticles/java_warehouse/single_jar/

Might be the trick, just change the targets names to be more appropriate for your use

like image 32
Mark Avatar answered Feb 06 '23 17:02

Mark