Build and Release Course Training with Jenkins / Maven /Ant/ SVN & Git


Upcoming Training Dates | Training Agenda | Training Calender | FAQ | Why scmGalaxy Online Training

Click Here

Mode – Online based
Email –

Lab Setup Details – Prerequisites
Operating Systems – Windows 7 or Linux(RHEL 7.X or Ubantu)
JDK 1.7 or Higher
SCM Tool Clients Installed (SVN, GIT, Perforce)
Servlet container like GlassFish and Tomcat (If one wants to host Jenkins outside) – Optional

[If trainee is having any specific learning agenda to be addressed in this training apart from the table of Content as below; please email me @]

Table of Content

Continuous Integration with Jenkins

  • What is Software Configuration Management
  • What is Build and Release Engineering
  • Introduction of Version Control Management?
    • Basic usage of Subversion
    • Basic usage of git
  • Introduction of Build Management?
    • How to write ant script?
    • How to write Maven script?
    • How to write MSBuild Script?
  • Introduction of Release Management?
  • Benefit of Continuous Integration?
  • Different Continuous Integration Tools?
  • Focus on Jenkins
  • Installation and Setup of Jenkinks
  • Configure a Job to Build the Project using SVN /GIT and ANT/Maven
  • Using Build Script (Ant, Maven and MSBuild) with Jenkins
  • Authentication and Authorization in Jenkins
  • Lab and Assignment
  • Nodes Setup in Jenkins
  • Labels, Tags and Notification using Jenkins
  • Empowered with Plugins in Jenkins
  • 20 Popular Plugins and Their Usage
  • Integrating Jenkins with Junit for automated testing
  • Integrating Jenkins with HP-QC for automated testing
  • Integrating Jenkins with Cobertura for test Coverage
  • Integrating Jenkins with Sonar for static code analysis
  • Release and Deployments using Jenkins and Nexus
  • Advance Jenkins
    • Jenkins Scripting
    • Jenkins Command line
  • Reporting and Dashboard using Jenkins
  • Lab and Assignment

Build and Release Training In Bangalore | Build and Release Training in India | Build and Release Training in Hyderabad | Build and Release Training in Delhi | Build and Release Training in Pune | Build and Release Trainer In Bangalore | Build and Release Trainer in India | Build and Release Trainer in Hyderabad | Build and Release Trainer in Delhi | Build and Release Trainer in Pune

Tagged : / / / / / / / / / / / / / / / / / / / / / / / /

Apache Ant Training | Apache Ant Course | Online | Classroom | India


Course SummaryThis course introduces Ant and how to use it for test-driven Java application development. A single application of increasing complexity, followed throughout the class, shows how an application evolves and how to handle the problems of building and testing. Coverage of large-projects, Ant’s advanced features, and the details and depth of the discussion-all unavailable elsewhere is included in the course. Advanced topics include how to manage large projects, Library management, Enterprise Java Continuous integration, Deployment, writing new Ant tasks and data types.

opics Covered In This Course


  • What is Ant?
  • What makes Ant so special?
  • When to use Ant
  • When not to use Ant
  • Alternatives to Ant

A First Ant build

  • Defining the first project
  • Step zero: creating the project directory
  • Step one: verifying the tools are in place
  • Step two: writing your first Ant build file
  • Step three: running your first build
  • Step four: imposing structure
  • Step five: running our program
  • Ant command-line options
  • Examining the final build file
  • Running the build under an IDE

Understanding Ant Datatypes and Properties

  • Preliminaries
  • Introducing datatypes and properties with
  • Paths
  • Filesets
  • Selectors
  • Additional Ant datatypes
  • Properties
  • Controlling Ant with properties
  • References
  • Managing library dependencies
  • Resources: Ant?s secret data model
  • Best practices

Testing with JUnit

  • What is testing, and why do it?
  • Introducing the application
  • How to test a program
  • Introducing JUnit
  • The JUnit task:
  • Generating HTML test reports
  • Advanced techniques
  • Best practices

Packaging Projects

  • Working with files
  • Introducing mappers
  • Modifying files as you go
  • Preparing to package
  • Creating JAR files
  • Testing with JAR files
  • Creating Zip files
  • Packaging for Unix
  • Working with resources

Executing Programs

  • Running programs under Ant?an introduction
  • Running native programs
  • Advanced and
  • Bulk operations with
  • Best practices

Distributing an Application

  • Preparing for distribution
  • FTP-based distribution of a packaged application
  • Email-based distribution of a packaged application
  • Secure distribution with SSH and SCP
  • HTTP download
  • Distribution over multiple channels

Putting It All Together

  • How to write good build files
  • Building the diary library
  • Adopting Ant
  • Building an existing project under Ant

Beyond Ant?s Core Tasks

  • The many different categories of Ant tasks
  • Installing optional tasks
  • Optional tasks in action
  • Software configuration management under Ant
  • Using third-party tasks
  • The Ant-contrib tasks
  • Code auditing with Checkstyle

Working with Big Projects

  • Master builds: managing large projects
  • Controlling child project builds
  • Advanced delegation
  • Inheriting build files through
  • Applying
  • Ant?s macro facilities
  • Writing macros with

Managing Dependencies

  • Introducing Ivy
  • Installing Ivy
  • Resolving, reporting, and retrieving
  • Working across projects with Ivy

Developing for the Web

  • Developing a web application
  • Building the WAR file
  • Deployment
What You Can Expect

At the end of the course, students will be able to:

  • Understand Ant
  • Install Ant
  • Understand Ant concepts and terminologies
  • Work with embedded properties and external properties using properties files
  • Integrate ANT into their IDE
  • Use Ant in Business Applications
  • Understand Ant Tasks
  • Automate their build and testing through Ant tasks
  • Use Ant for automated deployment
  • Create Custom Ant tasks
Who Should Take This Course

This course is designed for Build Engineers and Developers working on projects that use Ant as an automated build tool.

Training Style

Lecture (50%) / Workshop (50%)

scmGalaxy is a community initiatives based on Software configuration management that helps community members to optimize their software development process, Software Development Life Cycle optimization, Agile Methodologies and improve productivity across all aspects of Java development, including Build Scripts, Testing, Issue Tracking, Continuous Integration, Code Quality and more. scmGalaxy group that helps organisations optimize their software development process. We provide consulting, training and mentoring services in Agile Development Practices such as Version Management, Continuous Integration, Build Management, Test-Driven Development, Acceptance-Test Driven Development, Build Automation, Code Quality Practices and Automated Testing.

We provide job oriented training in the area of Configuration management, Build and Release Engineering. Candidates with engineering or software background and looking to either start or change their career to Build and Release Engineering, would benefit most from this training. Instructor-led training course offered in India, Bangalore, Delhi, Pune, Mumbai and Hydrabad. Instructor is an expert in Software configuration management, Build and release engineering with more than 15 years industry experience in india.The Goal of the course make the training attendants equip with all the concepts of build and release engineering.

Contact us at

Course Objectives
To bring your team up to speed with agile development, We can also run the from Continuous Integration to Continuous Delivery with autoamted course within your premises.

Course Schedule
This course is an intensive 1-day & 2-day workshop with a mixture of teaching and lab exercises. Currently, this course is offered exclusively as an on-site course. Please contact us for more details.

This is a hands-on, practical course designed to teach specialised skills for real-world development situations. It is thus primarily aimed at a SCM Engineer, Build/Release Engineer and developer audience.

The course is modular and flexible – depending on specific student needs and requests. Through our trainings, you benefit from the wide experience and architectural expertise of our team. We bring that experience to you in an highly interactive, intensely hands-on setting.

We assume participants have a reasonable understanding of Development in any language as well as a basic understanding of the Software Development Life Cycle.

Lab Work
All our courses are above all practical in nature. We believe that the best way to learn is by doing. So the course contains approximately 80% lab work.

Learning Resources
Each registrant will receive a copy of the student notes and lab solutions, a certificate of completion, and a CD containing all the tools covered in the course and CD containing all the tools covered in the course.

Contact Us
This course is provided on-site, and can be tailored to your particular requirements. If you would like our trainings delivered at your premises, or for any additional information please contact us. Please email us at | Call – +91 700 483 5930 | Skype – scmGalaxy

Tagged : / / / / / / / / / / / / / / / / / /

Maven Vs Ant | Maven or Ant which is better ?


Maven Vs Ant

Tagged : / / / / / / / / / / /

How to put comment in Ant | Comments in Apache Ant


How to put comment in Ant | Comments in Apache Ant

Method 1:

<!– Comments are just as important in buildfiles, do not –>
<!– avoid writing them! –>
<!– Example build file for “Ant: The Definitive Guide” –>
<!– and its sample project: irssibot –>

Method 2: Echo
Writes a message to the Ant logging facilities. A message may be supplied
as nested text to this task.
Echoes a message to the current loggers and listeners which means System.out unless overridden. A level can be specified, which controls at what logging level the message is filtered at.
The task can also echo to a file, in which case the option to append rather than overwrite the file is available, and the level option is ignored


Attribute Description


message the message to echo.

No. Text may also be included in a character section within this element. If neither is included a blank line will be emitted in the output.

file the file to write the message to.


append Append to an existing file (or open a new file / overwrite an existing file)?

No – default is false.

level Control the level at which this message is reported. One of “error”, “warning”, “info”, “verbose”, “debug” (decreasing order)

No – default is “warning”.

encoding encoding to use, default is “”; the local system encoding. since Ant 1.7


Style 1:
<echo message=”Hello, world”/>

Style 2:
<echo message=”Embed a line break:${line.separator}”/>

Style 3:
<echo>Embed another:${line.separator}</echo>

Style 4:
<echo>This is a longer message stretching over
two lines.

Style 5:
This is a longer message stretching over
three lines; the first line is a blank

Style 5:
<echo message=”Deleting drive C:” level=”debug”/>
A message which only appears in -debug mode.

Style 6:
<echo level=”error”>
Imminent failure in the antimatter containment facility.
Please withdraw to safe location at least 50km away.
A message which appears even in -quiet mode.

Style 7:
<echo file=”runner.csh” append=”false”>#\!/bin/tcsh
java-1.3.1 -mx1024m ${project.entrypoint} $$*
Generate a shell script by echoing to a file. Note the use of a double $ symbol to stop Ant filtering out the single $ during variable expansion
Depending on the loglevel Ant runs, messages are print out or silently ignored:


-quiet, -q

no statement

-verbose, -v

-debug, -d

<echo message=”This is error message.” level=”error” />





<echo message=”This is warning message.” />





<echo message=”This is warning message.” level=”warning” />





<echo message=”This is info message.” level=”info” />

not logged




<echo message=”This is verbose message.” level=”verbose” />

not logged

not logged



<echo message=”This is debug message.” level=”debug” />

not logged

not logged

not logged


Method 3:

Tagged : / / / / / / / / / / / / /

How to run ant build in intellij? – IntelliJ/Ant integration Guide


IntelliJ/Ant integration
By Alvin J. Alexander,
The fact that IntelliJ is off-the-shelf ready to work with Ant is a great, great feature. It’s also simple to configure and use.
Assuming that you already know how to use Ant, and you have a build.xml file ready to go, just follow these steps to (a) configure your build script to run from within IntelliJ, and (b) run Ant:

  • Assuming you’re in an IntelliJ project, select 6: Ant Build from the slide-in menu bar (“Tool Window Bar”) on the right side of your screen.
  • Click the large plus sign icon to add your build.xml file to IntelliJ’s list of known build scripts for this project.
  • Navigate the filesystem until you find your build script (i.e., your build.xml file for this project). Select that file.
  • To run a desired Ant task, double-click the task name that you want to run. My main task is usually named deploy, so I double-click that.
  • Ant should run properly for you, and deploy your application.

It’s really that simple.
The worst problem I’ve run into so far is that when I work on projects on multiple computer systems, my build scripts rely on an environment parameter named ANT_HOST_NAME existing. So, when my build script failed the first time, I said “Oh, dummy Al, you need to set your ANT_HOST_NAME environment parameter. Once I did this and restarted IntelliJ, the Ant build process worked like a champ.
Kudos, dear IntelliJ developers. Great product feature!

Best Example of <Copy>
Type 1:
<copy todir=”${Temp}/uaw/Uaw_compilescripts” overwrite=”true” failonerror=”false”>
<fileset dir=”${SVNCheckout}/scripts/compilescripts” includes=”BuildSh,Compsh,vsamc,,script,compl2,,makefile,makepl1,script” />

Type 2:
<copy todir=”${Temp}/uaw/Uaw_compilescripts” overwrite=”true” failonerror=”false”>
<fileset dir=”${SVNCheckout}/scripts/compilescripts” includes=”BuildSh,Compsh,vsamc,,script,compl2,,makefile,makepl1,script” />

Type 3:
<copy todir=”${Temp}/uaw/Uaw_compilescripts” overwrite=”true” failonerror=”false”>
<fileset dir=”${SVNCheckout}/scripts/compilescripts”>
<include name=”BuildSh”/>
<include name=”Compsh”/>
<include name=”vsamc”/>


<copy todir=”${Temp}/uaw/Uaw_compilescripts” overwrite=”true” failonerror=”false”>
<fileset dir=”${SVNCheckout}/scripts/compilescripts”>
<includesfile name=”${List}/Uaw_compilescripts_list.txt”/>


Tagged : / / / / / / / / / /

A sample Ant build script that builds a WAR file – Guide


A sample Ant build script that builds a WAR file

<project name=”MyWebApplication” basedir=”..” default=”install”>

<!– project-specific variables –>
<property name=”” value=”myapp” />
<property name=”” value=”${}.war” />
<property name=”webapp.dir” value=”/Users/al/tomcat-6.0.16/webapps” />

<property environment=”env” />
<property name=”build.dir” value=”build” />
<property file=”${build.dir}/build.${env.HOSTNAME}” />

<property name=”lib.dir” value=”lib” />
<property name=”pages.dir” value=”pages” />
<property name=”src.dir” value=”src” />
<property name=”src.tests.dir” value=”src-tests” />
<property name=”resources.dir” value=”resources” />
<property name=”dest.dir” value=”target” />

<!– put everything in a temp folder with the right structure during the build –>
<property name=”temp.dir” value=”temp” />
<property name=”temp.dir.web-inf” value=”${temp.dir}/WEB-INF” />
<property name=”temp.dir.lib” value=”${temp.dir.web-inf}/lib” />
<property name=”temp.dir.classes” value=”${temp.dir.web-inf}/classes” />
<property name=”temp.dir.meta-inf” value=”${temp.dir}/META-INF” />

<property name=”package.file” value=”${dest.dir}/${}” />

<path id=”build.class.path”>
<fileset dir=”lib”>
<include name=”**/*.jar” />

<target name=”clean”>
<fileset dir=”${dest.dir}” includes=”**/*”/>
<delete dir=”${temp.dir}” />
<delete dir=”${temp.dir.classes}” />
<delete dir=”${temp.dir.meta-inf}” />
<delete dir=”${temp.dir.web-inf}” />

<target name=”prepare” depends=”clean”>
<mkdir dir=”${dest.dir}” />
<mkdir dir=”${temp.dir}” />
<mkdir dir=”${temp.dir.lib}” />
<mkdir dir=”${temp.dir.meta-inf}” />
<mkdir dir=”${temp.dir.web-inf}” />
<mkdir dir=”${temp.dir.classes}” />

<!– COMPILE –>
<target name=”compile” depends=”prepare”>
<echo>=== COMPILE ===</echo>
<echo>Compiling ${src.dir} files …</echo>
<javac debug=”on” srcdir=”${src.dir}” destdir=”${temp.dir.classes}” includes=”**/*”>
<classpath refid=”build.class.path” />

<!– compile files on the src-tests path –>
<echo>Compiling ${src.tests.dir} files …</echo>
<javac debug=”on” srcdir=”${src.tests.dir}” destdir=”${temp.dir.classes}” includes=”com/**”>
<classpath refid=”build.class.path” />

<!– PACKAGE –>
<target name=”package” depends=”compile”>
<echo>=== PACKAGE ===</echo>

<!– copy the config files –>
<copy file=”${resources.dir}/MANIFEST.MF” tofile=”${temp.dir.meta-inf}/MANIFEST.MF” overwrite=”true” />
<copy file=”${resources.dir}/web.xml” tofile=”${temp.dir.web-inf}/web.xml” overwrite=”true” />
<copy file=”${resources.dir}/managed-beans.xml” tofile=”${temp.dir.web-inf}/managed-beans.xml” overwrite=”true” />
<copy file=”${resources.dir}/navigation-rules.xml” tofile=”${temp.dir.web-inf}/navigation-rules.xml” overwrite=”true” />

<copy todir=”${temp.dir.classes}”>
<fileset dir=”${src.dir}”>
<include name=”**/*.xml”/>
<include name=”**/*.xsl”/>

<!– with all resources in place, create the war file –>
<war destfile=”${package.file}” webxml=”${temp.dir.web-inf}/web.xml” basedir=”${temp.dir}”>
<fileset dir=”${pages.dir}”/>
<lib dir=”${lib.dir}” />
<classes dir=”${temp.dir.classes}” />

<target name=”jsps”>
<echo>=== DEPLOY JSP’S ===</echo>
<!– i’m trying to be explicit about what i put out there –>
<copy todir=”${webapp.dir}/${}”>
<fileset dir=”${pages.dir}”>
<include name=”**/*.jsp”/>
<include name=”**/*.html”/>
<include name=”**/*.css”/>
<include name=”**/*.gif”/>
<include name=”**/*.jpg”/>
<include name=”**/*.png”/>
<include name=”**/*.js”/>

<!– INSTALL –>
<target name=”install” depends=”package”>
<echo>=== INSTALL ===</echo>
<copy file=”${package.file}” tofile=”${webapp.dir}/${}” overwrite=”true” />


Tagged : / / / / / / / / / / / / / / / / /

Samples/Examples of the Ant copy task – Guide


Samples of the Ant copy task

<copy file=”${resources.dir}/MANIFEST.MF” tofile=”${temp.dir.meta-inf}/MANIFEST.MF” overwrite=”true” />
<copy file=”${resources.dir}/managed-beans.xml” tofile=”${temp.dir.web-inf}/managed-beans.xml” overwrite=”true” />
<copy file=”${resources.dir}/navigation-rules.xml” tofile=”${temp.dir.web-inf}/navigation-rules.xml” overwrite=”true” />
<copy file=”${resources.dir}/monitoring-managed-beans.xml” tofile=”${temp.dir.web-inf}/monitoring-managed-beans.xml” overwrite=”true” />
<copy file=”${resources.dir}/monitoring-navigation-rules.xml” tofile=”${temp.dir.web-inf}/monitoring-navigation-rules.xml” overwrite=”true” />
<copy file=”${resources.dir}/faces-config.xml” tofile=”${temp.dir.web-inf}/faces-config.xml” overwrite=”true” />
<copy file=”${resources.dir}/” tofile=”${temp.dir.classes}/” overwrite=”true” />
<copy file=”${resources.dir}/” tofile=”${temp.dir.classes}/” overwrite=”true” />

<copy todir=”${temp.dir.classes}”>
<fileset dir=”${src.dir}”>
<include name=”**/*.xml”/>
<include name=”**/*.xsl”/>
<include name=”**/*.properties”/>

<copy todir=”${dist}”>
<fileset dir=”${src}”

This copies all files in directories called images that are located in the directory tree defined by ${src} to the destination directory defined by ${dist}, but excludes all *.gif files from the copy.

<copy todir=”${dist}”>
<fileset dir=”${src}”>
<include name=”**/images/*”/>
<exclude name=”**/*.gif”/>

The same as the example above, but expressed using nested elements.

<delete dir=”${dist}”>
<include name=”**/images/*”/>
<exclude name=”**/*.gif”/>

Deleting the original set of files, the delete task can act as an implicit fileset.

Flatten directories when performing an Ant copy
Here’s a code snippet from an Ant build script where I begin with a hierarchical structure of jar files in my development environment, then flatten out all my lib subdirectories into one directory in my production environment when I copy all the jar files to my production library directory:

<!– build a temporary lib dir, and flatten out the jars into one folder –>

<copy todir=”${temp.dir.lib}” flatten=”true”>
<fileset dir=”${lib.dir}”>
<exclude name=”${cob.lib.dir}” />
<exclude name=”junit*” />
<include name=”**/*.jar”/>
<include name=”**/*.zip”/>


Tagged : / / / / / / / / /

Flow Diagram and GUI tools for Apache Ant


Nurflugel AntScript Visualizer


Ant Script Visualizer is a program I’ve written to make visualizing how your Ant targets and scripts are related to one another.

Ever take a look at an Ant build script and, although perfectly readable, not really “see” all the dependencies between targets?

What targets depend on a certain taskdef? Or a macrodef? Do macrodefs rely on other macrodefs? And all those imported Ant scripts – where do they fit in? This program was designed to show that, by importing your Ant scripts and creating graphic file representations of them. Say what?

OK, here’s an example of the output for the build file used for this program:

# Parses build files for the following task usages:

* target
* ant
* antcall
* depends
* property
* import
* taskdef
* macrodef

# Groups results by build file subgraphs (default), or optionally, all items together in one graph
# Ability to filter/show included obects by target, imported files, ant calls, taskdefs, and macrodefs
# Output formats: PNG (default for PC), PDF (default for OS X, not available otherwise), SVG.



Grand is a tool to create visual representation of ant target dependencies. It differs from tools like Vizant or AntGraph  by a totally different approach, relying on the Ant API rather than parsing directly the XML files. This enables Grand to provide some nifty features such as the support of the ant 1.6.x tasks like import or subant.




Vizant is an Apache Ant task to create Graphviz DOT source code from an Ant buildfile. The image created from the DOT source code shows the targets dependency.

Tagged : / / / / / / / / / / / / / / /

How to Integrate Subversion Into Your Ant Build ? – Step by step guide


SVNAnt is an Ant task allowing you to interact with Subversion within the convenience of your Ant build script. No more writing custom scripts to get the revision of your repository to tag your release jars. Nor do you have to make command line calls to checkout your latest and greatest as part of your continuous integration process. With SVNAnt, you have the familiarity of the Ant syntax and the flexibility you need for interacting with Subversion.
SVNAnt is a full-featured Subversion client capable of using the native Java bindings or command-line wrappering depending on which is available. Beyond how it works, SVNAnt allows you to do all svn subcommands but the following:

blame cleanup help list
lock log merge propedit
proplist resolved unlocked  

If the svn subcommand is not listed here, you can use it in your Ant build file. Before we continue start using SVNAnt, we have to install it and configure Ant to use it.
Now that we know what SVNAnt is and what its features are, lets install SVNAnt so that you can begin to use SVNAnt to access Subversion within your Ant build cycle.

Step 1. (Download, Compile and Extract)
This step will download, compile, and “install” the latest version of SVNAnt.
1.1 Using Subversion, checkout the SVNAnt project located here:
1.2 From the command line, while inside of the location where you checked out SVNAnt to, run “ant makeDistrib”
1.3 Extract the .zip file created in the build directory of your SVNAnt source to a location of your choosing

Step 2. (Modify your build.xml)
The next step is to tell Ant how to find your SVNAnt task by adding the following to your build.xml file:
<path id= “svnant.classpath” >
<include name= “*.jar” />

<typedef resource=”org/tigris/subversion/svnant/svnantlib.xml” classpathref=”svnant.classpath” />
That should be it. I know that it appears to be too good to be true so lets verify this.

Step 3. (Verify installation)
Building upon Step 2, lets create a new ant task that will use the wcVersion feature of SVNAnt to get some information about your repository from a local working copy:
<target name=”testSVNAnt”>
<wcVersion path= “PATH/TO/YOUR/WORKINGCOPY” />

<echo message= “Subversion repository url: ${repository.url}” />
(Note: In the event that you need to pass credentials to Subversion, look here.)
The output should be something similar to this:
$ ant testSVNAnt

Buildfile: build.xml

[svn] <WcVersion> started …
[svn]  finished.
[echo] Subversion repository url:

Total time: 43 seconds

Pat yourself on the back. You have successfully installed SVNAnt and you are ready to implement Subversion into your Ant build cycle. Instead of us going through each available feature for SVNAnt, please view the SVNAnt Documentation. Now lets talk about why you may want to use SVNAnt to allow for Subversion interaction inside of your Ant build cycle.

Tagged : / / / / / / / / / / / / / / / /

Apache Ant – A Complete TASK Reference


Apache Ant Task: zip


Creates a zipfile.

The basedir attribute is the reference directory from where to zip.

Note that file permissions will not be stored in the resulting zipfile.

It is possible to refine the set of files that are being zipped. This can be done with the includes, includesfile, excludes, excludesfile and defaultexcludes attributes. With the includes or includesfile attribute you specify the files you want to have included by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on directory based tasks, on how the inclusion/exclusion of files works, and how to write patterns.

This task forms an implicit FileSet and supports all attributes of (dir becomes basedir) as well as the nested , and elements.

Or, you may place within it nested file sets, or references to file sets. In this case basedir is optional; the implicit file set is only used if basedir is set. You may use any mixture of the implicit file set (with basedir set, and optional attributes like includes and optional subelements like ); explicit nested elements so long as at least one fileset total is specified. The ZIP file will only reflect the relative paths of files within each fileset. The Zip task and its derivatives know a special form of a fileset named zipfileset that has additional attributes (described below).

The Zip task also supports the merging of multiple zip files into the zip file. This is possible through either the src attribute of any nested filesets or by using the special nested fileset zipgroupfileset.

The update parameter controls what happens if the ZIP file already exists. When set to yes, the ZIP file is updated with the files specified. (New files are added; old files are replaced with the new versions.) When set to no (the default) the ZIP file is overwritten if any of the files that would be added to the archive are newer than the entries inside the archive. Please note that ZIP files store file modification times with a granularity of two seconds. If a file is less than two seconds newer than the entry in the archive, Ant will not consider it newer.

The whenempty parameter controls what happens when no files match. If skip (the default), the ZIP is not created and a warning is issued. If fail, the ZIP is not created and the build is halted with an error. If create, an empty ZIP file (explicitly zero entries) is created, which should be recognized as such by compliant ZIP manipulation tools.

This task will now use the platform’s default character encoding for filenames – this is consistent with the command line ZIP tools, but causes problems if you try to open them from within Java and your filenames contain non US-ASCII characters. Use the encoding attribute and set it to UTF8 to create zip files that can safely be read by Java.

Starting with Ant 1.5.2, can store Unix permissions inside the archive (see description of the filemode and dirmode attributes for ). Unfortunately there is no portable way to store these permissions. Ant uses the algorithm used by Info-Zip’s implementation of the zip and unzip commands – these are the default versions of zip and unzip for many Unix and Unix-like systems.

Please note that the zip format allows multiple files of the same fully-qualified name to exist within a single archive. This has been documented as causing various problems for unsuspecting users. If you wish to avoid this behavior you must set the duplicate attribute to a value other than its default, “add”.


Attribute Description Required
destfile the zip-file to create. Exactly one of the two.
zipfile the deprecated old name of destfile. No
basedir the directory from which to zip the files. No
compress Not only store data but also compress them, defaults to true. Unless you set the keepcompression attribute to false, this will apply to the entire archive, not only the files you’ve added while updating. No
keepcompression For entries coming from existing archives (like nested zipfilesets or while updating the archive), keep the compression as it has been originally instead of using the compress attribute. Defaults false. Since Ant 1.6 No
encoding The character encoding to use for filenames inside the zip file. For a list of possible values see Defaults to the platform’s default character encoding. No
filesonly Store only file entries, defaults to false No
includes comma- or space-separated list of patterns of files that must be included. All files are included when omitted. No
includesfile the name of a file. Each line of this file is taken to be an include pattern No
excludes comma- or space-separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted. No
excludesfile the name of a file. Each line of this file is taken to be an exclude pattern No
defaultexcludes indicates whether default excludes should be used or not (“yes”/”no”). Default excludes are used when omitted. No
update indicates whether to update or overwrite the destination file if it already exists. Default is “false”. No
whenempty behavior when no files match. Valid values are “fail”, “skip”, and “create”. Default is “skip” No
duplicate behavior when a duplicate file is found. Valid values are “add”, “preserve”, and “fail”. The default value is “add”. No
roundup Whether the file modification times will be rounded up to the next even number of seconds.
Zip archives store file modification times with a granularity of two seconds, so the times will either be rounded up or down. If you round down, the archive will always seem out-of-date when you rerun the task, so the default is to round up. Rounding up may lead to a different type of problems like JSPs inside a web archive that seem to be slightly more recent than precompiled pages, rendering precompilation useless.
Defaults to true. Since Ant 1.6.2
comment Comment to store in the archive. Since Ant 1.6.3 No
level Non-default level at which file compression should be performed. Valid values range from 0 (no compression/fastest) to 9 (maximum compression/slowest). Since Ant 1.7 No



Zips all files in the htdocs/manual directory into a file called in the ${dist} directory. zips all files in the htdocs/manual directory into a file called in the ${dist} directory. If doesn’t exist, it is created; otherwise it is updated with the new/changed files.




Zips all files in the htdocs/manual directory. Files in the directory mydocs, or files with the name todo.html are excluded. Zips all files in the htdocs/manual directory. Only html files under the directory api are zipped, and files with the name todo.html are excluded.

excludes=”mydocs/**, **/todo.html”



Zips all files in the htdocs/manual directory, and also adds the file ChangeLog.txt in the current directory. ChangeLog.txt will be added to the top of the ZIP file, just as if it had been located at htdocs/manual/ChangeLog.txt. zips all files in the htdocs/manual directory into the docs/user-guide directory in the archive, adds the file ChangeLog27.txt in the current directory as docs/ChangeLog.txt, and includes all the html files in exampleszip under docs/examples. The archive might end up containing the files:


Code:: docs/user-guide/html/index.html


zips all files in the htdocs/manual directory into the docs/user-guide directory in the archive and includes all the files in any file that maches examples*.zip, such as all files within or Re-packages a TAR archive as a ZIP archive. If Unix file permissions have been stored as part of the TAR file, they will be retained in the resulting ZIP archive.






Apache Ant Task: Concat


Concatenates one or more resources to a single file or to the console. The destination file will be created if it does not exist. Since Ant 1.7.1, this task can be used as a Resource Collection that will return exactly one resource.


Attribute Description Required
destfile The destination file for the concatenated stream. If not specified the console will be used instead. No
append Specifies whether or not the file specified by ‘destfile’ should be appended. Defaults to “no”. No
force Specifies whether or not the file specified by ‘destfile’ should be written to even if it is newer than all source files. since Ant 1.6. Defaults to “yes”. No
encoding Specifies the encoding for the input files. Please see for a list of possible values. Defaults to the platform’s default character encoding. No
outputencoding The encoding to use when writing the output file since Ant 1.6. Defaults to the value of the encoding attribute if given or the default JVM encoding otherwise. No
fixlastline Specifies whether or not to check if each file concatenated is terminated by a new line. If this attribute is “yes” a new line will be appended to the stream if the file did not end in a new line. since Ant 1.6. Defaults to “no”. This attribute does not apply to embedded text. No
eol Specifies what the end of line character are for use by the fixlastline attribute. since Ant 1.6 Valid values for this property are:

  • cr: a single CR
  • lf: a single LF
  • crlf: the pair CRLF
  • mac: a single CR
  • unix: a single LF
  • dos: the pair CRLF

The default is platform dependent. For Unix platforms, the default is “lf”. For DOS based systems (including Windows), the default is “crlf”. For Mac OS, the default is “cr”.




Concatenate a string to a file: Concatenate a series of files to the console:

Hello, World!



Concatenate a single file, appending if the destination file exists: Concatenate a series of files, update the destination file only if is older that all the source files:






Concatenate a series of files, expanding ant properties Filter the lines containing project from build.xml and output them to report.output, prepending with a header




Lines that contain project


Concatenate a number of binary files.






Apache Ant Task: ReplaceRegExp


ReplaceRegExp is a directory based task for replacing the occurrence of a given regular expression with a substitution pattern in a selected file or set of files.The output file is only written if it differs from the existing file. This prevents spurious rebuilds based on unchanged files which have been regenerated by this task.


Attribute Description Required
file file for which the regular expression should be replaced. Yes if no nested is used
match The regular expression pattern to match in the file(s) Yes, if no nested is used
replace The substitution pattern to place in the file(s) in place of the regular expression. Yes, if no nested is used
flags The flags to use when matching the regular expression. For more information, consult the Perl5 syntax
g : Global replacement. Replace all occurrences found
i : Case Insensitive. Do not consider case in the match
m : Multiline. Treat the string as multiple lines of input, using “^” and “$” as the start or end of any line, respectively, rather than start or end of string.
s : Singleline. Treat the string as a single line of input, using “.” to match any character, including a newline, which normally, it would not match.
byline Process the file(s) one line at a time, executing the replacement on one line at a time (true/false). This is useful if you want to only replace the first occurrence of a regular expression on each line, which is not easy to do when processing the file as a whole. Defaults to false. No
encoding The encoding of the file. since Ant 1.6 No – defaults to default JVM encoding



Replaces occurrences of the property name “OldProperty” with “NewProperty” in a properties file, preserving the existing value, in the file ${src}/ This task supports a nested Regexp element to specify the regular expression. You can use this element to refer to a previously defined regular expression datatype instance.




This task supports a nested Substitution element to specify the substitution pattern. You can use this element to refer to a previously defined substitution pattern datatype instance. Replaces occurrences of the property name “OldProperty” with “NewProperty” in a properties file, preserving the existing value, in all files ending in .properties in the current directory






Replaces all whitespaces (blanks, tabs, etc) by one blank remaining the line separator. So with input Check that both files one.txt and two.txt are present otherwise the build will fail.



replaces all whitespaces (blanks, tabs, etc) by one blank remaining the line separator. So with input




would converted to









Apache Ant Task: Checksum


Generates checksum for files. This task can also be used to perform checksum verifications.

Note that many popular message digest functions – including MD5 and SHA-1 – have been broken recently. If you are going to use the task to create checksums used in an environment where security is important, please take some time to investigate the algorithms offered by your JCE provider. Note also that some JCE providers like the one by The Legion of the Bouncy Castle, the GNU project or the Technical University Graz offer more digest algorithms than those built-in into your JDK.

Warning: the case of the extension is that of the algorithm used. If you ask for “SHA1”, you get a .SHA1 extension; if you ask for “sha1”, you get a file ending in .sha1. The Java Crypto Engines are case-insensitive in matching algorithms, so choose a name to match your desired output extension, or set the fileext attribute.


Attribute Description Required
file The file to generate checksum for. One of either file or at least one nested (filesystem-only) resource collection.
todir The root directory where checksums should be written. No. If not specified, checksum files will be written to the same directory as the files themselves. since Ant 1.6
algorithm Specifies the algorithm to be used to compute the checksum. Defaults to “MD5”. Other popular algorithms like “SHA” may be used as well. No
provider Specifies the provider of the algorithm. No
fileext The generated checksum file’s name will be the original filename with the fileext added to it. Defaults to a “.” and the algorithm name being used. No
property This attribute can mean two different things, it depends on the presence of the verifyproperty attribute.
If you don’t set the verifyproperty attribute, property specifies the name of the property to be set with the generated checksum value.
If you set the verifyproperty attribute, property specifies the checksum you expect to be generated (the checksum itself, not a name of a property containing the checksum).
This cannot be specified when fileext is being used or when the number of files for which checksums is to be generated is greater than 1.
pattern Specifies the pattern to use as a pattern suitable for MessageFormat where {0} is replaced with the checksum and {1} with the file name. No – default is “{0}”.
format Specifies the pattern to use as one of a well-known format. Supported values are

name pattern description
CHECKSUM {0} only the checksum itself
MD5SUM {0} *{1} the format of GNU textutils md5sum
SVF MD5 ({1}) = {0} the format of BSDs md5 command
No – default is “CHECKSUM”.
totalproperty If specified, this attribute specifies the name of the property that will hold a checksum of all the checksums and file paths. The individual checksums and the relative paths to the files within the resource collections in which they are defined will be used to compute this checksum. (The file separators in the paths will be converted to ‘/’ before computation to ensure platform portability). since Ant 1.6 No
forceoverwrite Overwrite existing files even if the destination files are newer. Defaults to “no”. No
verifyproperty Specifies the name of the property to be set with “true” or “false” depending upon whether the generated checksum matches the existing checksum. When this is set, the generated checksum is not written to a file or property, but rather, the content of the file or property is used to check against the generated checksum. No
readbuffersize The size of the buffer (in bytes) to use when reading a file. Defaults to “8192” – you may get a better performance on big files if you increase this value. No



Generates a MD5 checksum for and stores the checksum in the destination file is overwritten only if is newer than itself. Generates a MD5 checksum for and stores the checksum in If already exists, it is overwritten.




Generates a MD5 checksum for and stores it in the Project Property foobarMD5. Generates a MD5 checksum for, compares it against and sets isMD5ok to either true or false, depending upon the result




Generates a SHA checksum for and stores the checksum in the destination file is overwritten only if is newer than itself. Generates a MD5 checksum for, compares it against the value of the property md5, and sets isEqual to either true or false, depending upon the result.




Works just like Example 1, but generates a .MD5 file for every file that begins with the name foo. Works like Example 4, but only sets isChecksumEqual to true, if the checksum matches – it will never be set to false. This example demonstrates use with the Condition task.





Apache Ant Task: Fail


Exits the current build (just throwing a BuildException), optionally printing additional information.The message of the Exception can be set via the message attribute or character data nested into the element.


Attribute Description Required
message A message giving further information on why the build exited No
if Only fail if a property of the given name exists in the current project No
unless Only fail if a property of the given name doesn’t exist in the current project No
status Exit using the specified status code; assuming the generated Exception is not caught, the JVM will exit with this status. Since Ant 1.6.2 No



Exit the current build with no further information given. Exit the current build and print something like the following to wherever your output goes:




build.xml:4: No message
build.xml:4: Something wrong here.
Exit the current build and print something like the following to wherever your output goes: Exit the current build and print something like the following to wherever your output goes:

Something wrong here.



build.xml:4: Something wrong here.
build.xml:2: unless=thisdoesnotexist
Using a condition to achieve the same effect Check that both files one.txt and two.txt are present otherwise the build will fail.




build.xml:2: condition satisfied



Tagged : / / / / / / / / / / / / / / /