Search This Blog

Showing posts with label fail build. Show all posts
Showing posts with label fail build. Show all posts

Thursday, May 29, 2014

Fail an ANT build if a property is not set

Any number of properties can be used in ANT build.xml. They can be environment variables or variables set in a properties file.

There is an ability to check if required properties are set or not i.e. included or not in the properties file. Also we can match them to a regular expression to see of they are empty or matching as per the requirement. If they do not match the requirement, the build can be made to fail. There is a fail task provided by the ant library to fail the build. Add this as first task before adding any cutom tasks.

Including Properties File

You can include a properties file or environmental variables in build.xml in the below way
    <property file="build.properties"/>
    <property environment="env"/>