<div dir="ltr" style="text-align: justify;">
<p>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.</p>
<p>By default, Ant provides the following pre-defined properties that can be used in the build file:</p>
<ul style="text-align: left;">
<li><b>ant.file->; </b>The full location of the build file.</li>
<li><b>ant.version</b><b>->; </b> The version of the Apache Ant installation.</li>
<li><b>basedir</b><b>->; </b> The basedir of the build, as specified in the basedir attribute of the project element.</li>
<li><b>ant.java.version</b><b>->; </b> The version of the JDK that is used by Ant.</li>
<li><b>ant.project.name<b>->; </b> </b>The name of the project, as specified in the name attribute of the project element.</li>
<li><b>ant.project.default-target</b><b>->; </b> The default target of the current project.</li>
<li><b>ant.project.invoked-targets<b>->; </b> </b>Comma separated list of the targets that were invoked in the current project.</li>
<li><b>ant.core.lib<b>->; </b> </b>The full location of the Ant jar file.</li>
<li><b>ant.home</b><b>->; </b> The home directory of Ant installation.</li>
<li><b>ant.library.dir</b><b>->; </b> The home directory for Ant library files &#8211; typically ANT_HOME/lib folder.</li>
</ul>
<div id="ads-id" align="center"></div>
<h2><b>Example-</b><br />
<b><br />
</b> <b>Declaring some property element in the xml and using it. </b></h2>
<p>Like we declaring name of <b>tutor</b>.</p>
<pre class="highlight"><;?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>; 
</pre>
<p>Running Ant on the above build file produces the following output:</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2016/10/Ant-Property_task.jpg" border="0" /></div>
<h2><b><br />
</b> <b>Using External Property into ANT Build-</b></h2>
<p>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.</p>
<p>Here we are creating the property file is named <b>build.properties</b> and is placed along-side the <b>build.xml</b> file. You could create multiple build properties files based on the deployment environments &#8211; such as <b>build.properties.dev</b> and <b>build.properties.test</b>.</p>
<p>The following example shows a <b>build.xml</b> file and its associated <b>build.properties</b> file:<br />
<b>build.xml</b></p>
<pre class="highlight"><;?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>; 
</pre>
<p><b>build.properties</b></p>
<pre class="highlight">tutor=Dinesh Rajput 
</pre>
<p>Running Ant on the above build file produces the following output:</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2016/10/Ant-Property_task.jpg" border="0" /></div>
<p>Output is similar as above.</p>
<p> ;</p>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/creating-targets-and-their-dependencies-in-ant-build-file/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/create-jar-file-using-ant-build-file/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '118'});
});
</script>
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…