ANT Interview Questions and Answers
Intermediate / 1 to 5 years experienced level questions & answers
Ques 1. How to set property file in Ant script?
<!-- Import properties from build.properties -->
<property name="build.properties" value="${basedir}/conf/build.properties" />
<fail message="Missing build.properties file: please use -Dbuild.properties=/path/to/file">
<condition>
<not>
<available file="${build.properties}" type="file" />
</not>
</condition>
</fail>
<property file="${build.properties}" />
Ques 2. Explain how to import .jar files?
<path id="classpath.base">
<pathelement location="${glassfish.home}/lib/javaee.jar" />
<fileset dir="${lib.dir}">
<include name="log4j-1.2.15.jar" />
<include name="el-impl-1.0.jar" />
</fileset>
</path>
Ques 3. Explain how to use clean in Ant script?
<target name="clean" depends="-clean" />
<target name="-clean">
<delete dir="${build.dir}/*" />
<delete dir="${build.dir}/classes" />
<delete dir="${build.dir}/test-classes" />
<delete dir="${build.dir}/release" />
<delete file="${build.dir}/*.jar" />
<delete file="${build.dir}/VERSION.txt" />
</target>
Most helpful rated by users:
- What is ANT?
- Explain ANT functionality.
- Explain using ANT and give an small example.
- How to set Classpath in Ant script?
- How to set property file in Ant script?