<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">Ant build files are just text files, so simple way to create an Ant build file go to<b> file->;new file->;Enter a name for the file->;Create</b> it. Ant&#8217;s build file, called<b> build.xml </b>should reside in the base directory of the project. However there is no restriction on the file name or its location. You are free to use other file names or save the build file in some other location.<img src="https://dineshonjava.com/wp-content/uploads/2016/10/ant-build-file.jpg" border="0" /></p>
<p>By default the Ant editor only has an association with <;b>;build.xml<;/b>; named files. So right now we are creating a file called build.xml in your application with the following contents in it.</p>
<pre class="highlight"><;?xml version="1.0"?>; 
 <;project name="Hello World" default="info" basedir=".">; 
 
 <;target name="info">; 
 <;echo>;Hello World - Welcome to Apache Ant Tutorial!!!<;/echo>; 
 <;/target>; 
 
<;/project>; 
</pre>
<div id="ads-id" align="center"></div>
<p>All build files require the <b>project </b>element and at least one <b>target </b>element. As per as our build file there is XML element <b>project </b>has three attributes as below.</p>
<ul style="text-align: left;">
<li><b>name</b>->; The name of project and it is optional.</li>
<li><b>default</b>->; The name of default target and it mandatory. The default target for the build script. A project may contain any number of targets. This attribute specifies which target should be considered as the default.</li>
<li><b>basedir</b>->; The base or root directory and it is optional.</li>
</ul>
<p>Now move to another XML element of Ant Build file build.xml is target. A target is a collection of tasks that you want to run as one unit. Targets can have dependencies on other targets. Let see below</p>
<pre class="highlight"><;target name="clean" description="cleans up the build by deleting the build,dist, web directories">; 
 ...... 
<;/target>; 
<;target name="init" depends="clean" description="Setup for build script">; 
 ...... 
<;/target>; 
<;target name="compile" depends="init" description="Compiles .java files to WAR directory">; 
 ...... 
<;/target>; 
<;target name ="makejar" description="Create a jar for the AlgoTest project" depends="compile">; 
 ...... 
<;/target>; 
</pre>
<p>As per as we have define targets in the above file have dependencies such as a <b>makejar </b>target may have a dependency on the <b>compile </b>target and <b>compile </b>target may have dependency on the <b>init </b>target and <b>init </b>target may have dependency on the <b>clean </b>target.</p>
<p><b>The target element has the following attributes:</b></p>
<ul style="text-align: left;">
<li><b>name</b>->; The name of the target ant it is mandatory.</li>
<li><b>depends</b>->; Comma separated list of all targets that this target depends on and it is optional.</li>
<li><b>description</b>->;A short description of the target and it is optional.</li>
<li><b>if</b>->;Allows the execution of a target based on the trueness of a conditional attribute and it is optional.</li>
<li><b>unless</b>->;Adds the target to the dependency list of the specified Extension Point. An Extension Point is similar to a target, but it does not have any tasks and it is optional.</li>
</ul>
<p>To run the ant build file, open up command prompt and navigate to the folder where the build.xml resides, and type ant info.</p>
<div class="separator" style="clear: both; text-align: center;"><img src="https://dineshonjava.com/wp-content/uploads/2016/10/run-ant-build-file.jpg" border="0" /></div>
<p> ;</p>
</div>
</div>
</div>
<p> ;</p>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/installing-and-configure-apache-ant/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/creating-targets-and-their-dependencies-in-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: '120'});
});
</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…