Friday, September 18, 2009

Update build zip distribution with additional files

Inspired by a discussion on the NetBeans Developer Forum, (dev@openide.netbeans.org), and seen multiple struggeling with this, I would like to capture how to add some files or directories to the ZIP distro file on build

Suppose you have a directory in your sandbox you would like to add to the distro. This could be source code from an OpenSource project you have edited and hence have to make public, or some other directories. You may already have choosen to add the target build-launchers to copy those to the build directory like:

<target name="build-launchers" depends="suite.build-launchers">
<copy todir="${build.launcher.dir}">
<fileset dir="MyExtraDirectory"/>
</copy>
</target>

You can hereafter add the target which will add this directory to the zip file build simply by leveraging ant commands


<!-- Customized build-zip target to copy reports to the distribution -->
<target name="build-zip" depends=quot;suite.build-zip">
<!-- Update the just created ZIP with additional directories/data -->
<echo message="Adding MyExtraDirectory ..."/>
<zip destfile="${dist.dir}/${app.name}.zip" update="true">
<zipfileset dir="${build.launcher.dir}/MyExtraDirectory/" prefix="${app.name}/MyExtraDirectory"/>
</zip>
</target>


Done.

No comments:

Post a Comment