Netbeans Platform Ant based build system trick

February 18th, 2008 | by Tonny Kohar |

If you build an application on top of Netbeans Platform, you probably already know that it is using Apache Ant as the build system. Thanks to this flexibility of Netbeans Platform (ant based build system), this system allow us to do various trick to automate stuff. For example

This time the trick is how to override build-zip ant target to add your own files eg: license file, properties or configuration files, etc

Basically it is just

  1. zip as specified by the build-zip target
  2. unzip the result of build zip
  3. do your stuff eg: copy, move, delete, etc
  4. zip again
<!-- step (1) see depend suite.build-zip -->
<target name="build-zip" depends="suite.build-zip">
  <property name="nbdist.dir" value="dist"/>
  <property name="release.dir" value="${nbdist.dir}/${app.name}"/>
 
  <!-- step (2) unzip the result  -->
  <unzip src="${nbdist.dir}/${app.name}.zip" dest="${nbdist.dir}"/>
 
  <!-- step (3) do your copying stuff here, check the ant doc for copy, move, etc file -->
 
  <!-- step (4) zip again -->
  <zip destfile="${nbdist.dir}/${app.name}-updated.zip">
      <zipfileset dir="${release.dir}" prefix="${app.name}"/>
  </zip>
 
  <echo message=" "/>
  <echo message="cleaning and finalizing release" />
  <delete dir="${release.dir}"/>
</target>

Tags: , ,

  1. 3 Responses to “Netbeans Platform Ant based build system trick”

  2. By Rich Unger on Feb 19, 2008 | Reply

    You can “update” a zip without unzipping it, I believe.

  3. By James Branam on Feb 21, 2008 | Reply

    Hi Tonny,

    This sounds like a great Tips & Tricks entry for community docs.

  4. By Tonny Kohar on Feb 22, 2008 | Reply

    @James

    I just add this trick into Netbeans Community docs
    http://wiki.netbeans.org/NbPlatformBuildTrick

You must be logged in to post a comment.