What Is Ant?: 2. Why Do You Call It Ant?
What Is Ant?: 2. Why Do You Call It Ant?
What Is Ant?: 2. Why Do You Call It Ant?
Ans: Ant is an open source code .It is Java-based build tool sponsored by Apache
Software Foundation. It is a program for putting all the pieces of a program together.
A simple definition might state that Ant is a Java-based build tool from Apache
Software Foundation. Ant is kind of like Make.
Ans: The ant is acronym of \Another Neat Tool\ according to James Duncan
Davidson. Ants are very small and can carry heavy weight. So as Job of Apache ant.
Its name is called ANT.
Ans: A built tool is software which is used to build project, directory structure, copy
necessary files to that directory ,compile files ,create jars, set path and class-path
,Build the documentation ,Validate the source code, deploy, debug, and run, clear
the workspace.
ANS: Ant is a build tool that is java based. A build tool performs the following tasks:
Open:
Ant is an open source project available under the Apache license. Therefore, its
source code can be downloaded and modified.
Additionally, Ant uses XML build files which make its development easy.
Cross Platform:
Use of XML along with Java makes Ant makes it the perfect solution for developing
programs designed to run or be built across a range of different operating systems.
Extensible:
New tasks are used to extend the capabilities of the build process, while build
listeners are used to help hook into the build process to add extra error tracking
functionality.
Integration:
As Ant is extensible and open, it can be integrated with any editor or development
environment easily.
Ans: ANT tool is extended by using java classes. The configuration files are XML-
based. Each task of building directory tree is executed by using the object that
implements the Task interface.
ANT provides the cross-platform deployment that can run on any platform.
2. Ant can be used in a small personal project as well as ant can be used in a large,
multi-team software project.
4. Ant syntax used XML format .We need only specifies our task only on build.xml
file.
5. Ant is easy to use .eliminating the full-time make file engineer common on large
Make-based software projects.
7. How many ways we can set properties into build ant file?
We can use the combinations of all above in our build files .But only one should be
used at a time.
Ans: A project can have a set of properties .A property has name and value .The
name is case sensitive and Properties are immutable this mean once set property its
will not change. Properties may be used in the value of task attributes.
Ans: Dependencies are do something when complete it. In ant we are using
dependencies by using an attribute depends .In this attribute we have pass values
for which the target depends .This mean we first need to execute the target which is
passed into this attribute.
Ans: We can prepare a project by making a build.xml as a build file and using
following tag. Inside this tag we have defined standard targets (such as build, clean
etc), etc.
Ans: The most important difference between Ant and Make is that Ant uses XML to
describe the build process and its dependencies, whereas Make uses its Makefile
format. By default the ant XML file is named build.xml.
Ans: Ivy is a popular dependency manager .IVY is basically focused on flexibility and
simplicity.
The latest version of Ivy is 2.1.0.
14. How we can set path PATH and CLASSPATH into an ant build file?
Additionally, Ant uses XML build files which make its development easy.
Cross Platform.
Use of XML along with Java makes Ant makes it the perfect solution for developing programs
designed to run or be built across a range of different operating systems.
Extensible.
New tasks are used to extend the capabilities of the build process, while build listeners are
used to help hook into the build process to add extra error tracking functionality.
As Ant is extensible and open, it can be integrated with any editor or development
environment easily.
For example, we want the application HelloWorld to be used with ant. The Java source files
are in a subdirectory called Dirhelloworld, and the .class files are to put into a sub directory
called Helloworldclassfiles.
C :\\> ant
Buildfile: build.xml
and see the results in the extra files and directory created:
c:\\>dir Dirhelloworld
c:\\>dir Helloworldclassfiles
All the .java files are in Dirhelloworld directory and all the corresponding .class are in
Helloworldclassfiles directory.
Ques 10. Explain how to test classes for JUnit using Ant script?
Ans. <target name=\"test\" depends=\"-copytestresources, compile\">
<mkdir dir=\"${build.dir}/junit-reports\" />
<junit printsummary=\"false\"
fork=\"on\"
haltonfailure=\"false\"
failureproperty=\"test.failure\">
<classpath refid=\"classpath.junit\" />
<formatter type=\"plain\" />
<batchtest todir=\"${build.dir}/junit-reports\">
<fileset dir=\"${build.dir}/test-classes\" includes=\"**/*Test.class\" />
</batchtest>
</junit>
<junitreport tofile=\"target/junit-reports/TEST.xml\">
<fileset dir=\"${target}/junit-reports\" includes=\"TEST-*.xml\" />
<report format=\"frames\" todir=\"${target}/junit-reports\" />
</junitreport>
</target>
Capabilities of ANT:
ANT tool is extended by using java classes. The configuration files are XML-based. Each task of
building directory tree is executed by using the object that implements the Task interface.
ANT provides the cross-platform deployment that can run on any platform.
Explain how to start to use Ant and provide a "Hello World" ANT
script.
Before starting to use ANT, we should be clear about the project name and the .java files and
most importantly, the path where the .class files are to be placed.
For example, we want the application HelloWorld to be used with ant. The Java source files are
in a subdirectory called Dirhelloworld, and the .class files are to put into a sub directory called
Helloworldclassfiles.
C :\> ant
Buildfile: build.xml
and see the results in the extra files and directory created:
c:\>dir Dirhelloworld
c:\>dir Helloworldclassfiles
All the .java files are in Dirhelloworld directory and all the corresponding .class are in
Helloworldclassfiles directory.
1. By echoing at the place to debug. The problem is easily known. This is similar to printf()
function in C and System.out.println() in Java.
2. By using project.log (message) in the java script or the customized ant task.
3. By running ANT with verbose / -debug options. These options provide more information on
what is the process going and at which location.
<taskdef resource=net/sf/antcontrib/antcontrib.properties/>
http://www.tipstoremember.com/ant-interview-question-and-answers/
http://www.withoutbook.com/Technology.php?tech=49&page=2&subject=ANT%20Interview
%20Questions%20and%20Answers
http://www.careerride.com/Ant-Interview-Questions.aspx