Ant build file is a XML file so we can declare any variable as we could declare on our any programming language but we can use property element as declaring some value to parameter.
By default, Ant provides the following pre-defined properties that can be used in the build file:
Like we declaring name of tutor.
<?xml version="1.0"?> <project name="Hello World" default="info" basedir="."> <property name="tutor" value="Dinesh Rajput"/> <target name="info"> <echo>Hello World - Welcome to Apache Ant Tutorial by Tutor ${tutor}!!!</echo> </target> </project>
Running Ant on the above build file produces the following output:
We can also use external property file and use it into ANT build file. It allows you to reuse the same build file, with different property settings for different execution environment. For example, build properties file can be maintained separately for DEV, TEST, and PROD environments.
Here we are creating the property file is named build.properties and is placed along-side the build.xml file. You could create multiple build properties files based on the deployment environments – such as build.properties.dev and build.properties.test.
The following example shows a build.xml file and its associated build.properties file:
build.xml
<?xml version="1.0"?> <project name="Hello World" default="info" basedir="."> <property file="build.properties"/> <target name="info"> <echo>Hello World - Welcome to Apache Ant Tutorial by Tutor ${tutor}!!!</echo> </target> </project>
build.properties
tutor=Dinesh Rajput
Running Ant on the above build file produces the following output:
Output is similar as above.
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…