Friday, June 15, 2012

Build Optimization Tip 1 - Release Preparation using zipfileset

Continuing with the focus on the importance of Build Scripts in Continuous Integration System, (Refer to previous post : http://www.thinkinginagile.com/2011/05/build-optimization-for-effective.html) we would be covering some of the Tips of Build Optimization in small snippets in Build Optimization Tips Series:
Image Courtesy of www.freedigitalphotos.net
Release Preparation


In any build scripts one of the important activities is the release/artifact preparation. It may be a simple jar/war/ear or a huge zip file which contains different set of jars/wars, configuration files, etc.

What most team do?

a) Create a release directory.
b) Create all necessary folders as per the release structure.
c) Copy all the jars, files etc to respective folders.
d) Prepare the release zip file.
e) Copy the release zip file to the actual release directory.
 
What can be done?
There is a <zipfileset> nested element for jar/zip/war etc. We can use this type to pack the required files or jars from different location.
Sample Code
<zip destfile="${dist}/manual.zip">
    <zipfileset dir="htdocs/manual" prefix="docs/user-guide"/>
    <zipfileset dir="." includes="ChangeLog27.txt" fullpath="docs/ChangeLog.txt"/>
    <zipfileset src="examples.zip" includes="**/*.html" prefix="docs/examples"/>
  </zip>

By this way we can reduce the time to copy different files to a common location.
Refer: http://ant.apache.org/manual/Types/zipfileset.html

No comments: