views:

731

answers:

2

Hello!

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 ;)
+3  A: 

Check this out:

http://java.sun.com/developer/technicalArticles/java%5Fwarehouse/single%5Fjar/

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

Mark
The resource looks useful! I'll check it out.
ivan_ivanovich_ivanoff
it was certainly a useful gem for me creating runnable demos for my blog
Mark
+2  A: 

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.

ivan_ivanovich_ivanoff