{"id":1896,"date":"2017-12-06T10:27:24","date_gmt":"2017-12-06T10:27:24","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=1896"},"modified":"2020-02-04T10:23:11","modified_gmt":"2020-02-04T10:23:11","slug":"apache-ant-interview-questions","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/apache-ant-interview-questions\/","title":{"rendered":"Apache Ant Interview Questions and Answers"},"content":{"rendered":"<p><strong>rajeshkumar created the topic: Apache ant interview questions<\/strong><br \/>\nLinks to all Apache Ant Task &#8211;<a href=\"http:\/\/ant.apache.org\/manual\/tasklist.html\" target=\"_blank\" rel=\"noopener\"> ant.apache.org\/manual\/tasklist.html <\/a><\/p>\n<p>Question 1. Write a ant build.xml and call one batch file from build.xml. batch file should create one directory.<\/p>\n<p>Question 2. Write a ant build.xml which should copy the files and folders from another and create a tar file.<\/p>\n<p>Question 3. Linux &#8211; Write a ant build.xml which should create 5 files and five folders and change the file permission to all files to 644 and folder to 755.<\/p>\n<p>Question 4. Write a two build.xml named with &#8220;build1.xml&#8221; and &#8220;build2.xml&#8221;. Each build.xml will compile one java program but build2.xml should be called from build1.xml.<\/p>\n<p>Question 5. Go through all these questions mentioned in the url below and try to find an answer and provide your answer as part of comments.<br \/>\nwww.scmgalaxy.com\/index.php?option=com_k&#8230;d-answers&amp;Itemid=120<br \/>\nRegards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @ <a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\">twitter.com\/RajeshKumarIn<\/a><\/p>\n<p><strong>sribhavani_u replied the topic: Apache ant interview questions<\/strong><br \/>\nQuestion1<br \/>\n========\n<project name=\"createdir\" basedir=\".\" default=\"batch\">\n<target name=\"batch\"><br \/>\n<exec dir=\".\" executable=\"cmd\"><br \/>\n<arg line=\"\/c createdir.bat\"><br \/>\n<\/arg><\/exec><br \/>\n<\/target>\n<\/project>\n<p>Question2<br \/>\n=========\n<project name=\"copyfiles\" basedir=\".\" default=\"tar\">\n<property name=\"src.dir\" value=\"src\">\n<property name=\"build.dir\" value=\"build\">\n<target name=\"copy\"><br \/>\n<copy todir=\"${build.dir}\"><br \/>\n<fileset dir=\"${src.dir}\"><br \/>\n<\/fileset><br \/>\n<\/copy><br \/>\n<\/target><br \/>\n<target name=\"tar\" depends=\"copy\"><br \/>\n<tar destfile=\"C:\\SRI PROJECTS\\apache-ant-1.9.0\\testwork\/tarfile.tar\" basedir=\"${build.dir}\"><br \/>\n<\/tar><\/target>\n<\/property><\/property><\/project>\n<p>Question 3<br \/>\n=========\n<project name=\"setperm\" basedir=\".\" default=\"changeperm\">\n<target name=\"createfile\"><br \/>\n<touch file=\"file1\"><br \/>\n<touch file=\"file2\"><br \/>\n<touch file=\"file3\"><br \/>\n<touch file=\"file4\"><br \/>\n<touch file=\"file5\"><br \/>\n<echo>files created<\/echo><br \/>\n<\/touch><\/touch><\/touch><\/touch><\/touch><\/target><br \/>\n<target name=\"createfolder\"><br \/>\n<mkdir dir=\"folder1\"><br \/>\n<mkdir dir=\"folder2\"><br \/>\n<mkdir dir=\"folder3\"><br \/>\n<mkdir dir=\"folder4\"><br \/>\n<mkdir dir=\"folder5\"><br \/>\n<echo>Folders created<\/echo><br \/>\n<\/mkdir><\/mkdir><\/mkdir><\/mkdir><\/mkdir><\/target><br \/>\n<target name=\"changeperm\" depends=\"createfolder,createfile\"><br \/>\n<chmod perm=\"644\" type=\"file\"><br \/>\n<fileset dir=\"\/home\/sri\/antwork\"><br \/>\n<exclude name=\"**\/*.xml\"><br \/>\n<\/exclude><\/fileset><br \/>\n<\/chmod><br \/>\n<chmod perm=\"755\" type=\"dir\"><br \/>\n<dirset dir=\"\/home\/sri\/antwork\"><br \/>\n<\/dirset><\/chmod><br \/>\n<echo>permissions changed files:644 folders:755<\/echo><br \/>\n<\/target>\n<\/project>\n<p>Question4<br \/>\n=========<br \/>\nq4build1\n<project name=\"build1\" basedir=\".\" default=\"callbuild\">\n<target name=\"clean\"><br \/>\n<delete dir=\"build\"><br \/>\n<\/delete><\/target><br \/>\n<target name=\"compile\" depends=\"clean\"><br \/>\n<mkdir dir=\"build\"><br \/>\n<javac srcdir=\".\" destdir=\"build\"><br \/>\n<include name=\"HelloWorld.java\"><br \/>\n<\/include><\/javac><br \/>\n<\/mkdir><\/target><br \/>\n<target name=\"callbuild\" depends=\"compile\"><br \/>\n<ant antfile=\"build2.xml\" inheritrefs=\"false\"><br \/>\n<\/ant><\/target>\n<\/project>\n<p>q4build2\n<project name=\"build2\" basedir=\".\" default=\"compile\">\n<target name=\"compile\"><br \/>\n<javac srcdir=\".\" destdir=\"build\"><br \/>\n<include name=\"HelloWorld2.java\"><br \/>\n<\/include><\/javac><br \/>\n<\/target>\n<\/project>\n<p><strong>nineetha replied the topic: Apache ant interview questions<\/strong><br \/>\nQUESTION 1\n<project name=\"dir\" basedir=\".\" default=\"\">\n<target name=\"creatingbatch\"><br \/>\n<exec dir=\"D:\\Projects\\bin\" executable=\"cmd\"><br \/>\n<arg line=\"\/c md.bat\"><br \/>\n<\/arg><\/exec><br \/>\n<\/target>\n<\/project>[\/b]<\/p>\n<p>QUESTION 2\n<project name=\"copyfiles\" basedir=\".\" default=\"createtar\">\n<property name=\"src.dir\" value=\"src\">\n<property name=\"bin.dir\" value=\"bin\">\n<\/property><\/property><\/project>\n<p><target name=\"copy\"><br \/>\n<copy todir=\"${src.dir}\"><br \/>\n<fileset dir=\"${bin.dir}&quot;\"><br \/>\n<\/fileset><br \/>\n<\/copy><br \/>\n<\/target><br \/>\n<target name=\"create tar\" depends=\"copy\"><br \/>\n<tar destfile=\"D:\\Projects\\build.tar\" basedir=\"D:\\Projects\\src\"><br \/>\n<\/tar><\/target><\/p>\n<p>QUESTSION 3\n<project name=\"permissions\" basedir=\".\" default=\"chmod\">\n<target name=\"create file\"><br \/>\n<touch file=\"file1\"><br \/>\n<touch file=\"file2\"><br \/>\n<touch file=\"file3\"><br \/>\n<touch file=\"file4\"><br \/>\n<touch file=\"file5\"><br \/>\n<\/touch><\/touch><\/touch><\/touch><\/touch><\/target><br \/>\n<target name=\"create folders\"><br \/>\n<mkdir dir=\"dir1\"><br \/>\n<mkdir dir=\"dir2\"><br \/>\n<mkdir dir=\"dir3\"><br \/>\n<mkdir dir=\"dir4\"><br \/>\n<mkdir dir=\"dir5\"><br \/>\n<\/mkdir><\/mkdir><\/mkdir><\/mkdir><\/mkdir><\/target><br \/>\n<target name=\"chmod\" depends=\"create file,create folders\"><br \/>\n<exec executable=\"chmod\" type=\"file\"><br \/>\n<arg value=\"644\"><br \/>\n<arg value=\"D:\\Projects\"><br \/>\n<\/arg><\/arg><\/exec><br \/>\n<target name=\"chmod_files\" depends=\"create folders\"><br \/>\n<exec executable=\"chmod\" type=\"dir\"><br \/>\n<arg value=\"755\"><br \/>\n<arg value=\"D:\\Projects\"><br \/>\n<\/arg><\/arg><\/exec><br \/>\n<\/target><br \/>\n<\/target><\/project>\n<p>QUESTION 4\n<project name=\"call\" basedir=\".\" default=\"subant1\">\ntarget<name=\"subant1\"><br \/>\n<subant target=\"subant2\"><br \/>\n<fileset dir=\".\" includes=\"helloworld\/build.xml\">&#8221;<br \/>\n<javac srcdir=\"${src}\" destdir=\"{bin}\"><br \/>\n<\/javac><\/fileset><\/subant><br \/>\n<\/name=\"subant1\"><\/project>\n<project name=\"call2\" basedir=\".\">\n<target name=\"subant2\"><br \/>\n<subant taget=\"subant2\"><br \/>\n<javac srcdir=\"{src}\" destdir=\"{bin}\"><br \/>\n<fileset dir=\".\" includes=\"*\/build.xml\"><br \/>\n<fileset dir=\".\" includes=\"welcome\/build.xml\"><br \/>\n<\/fileset><\/fileset><\/javac><\/subant><br \/>\n<\/target><\/project>\n<p><strong>rajeshkumar replied the topic: Apache ant interview questions<\/strong><br \/>\nGood work. I checked last week and its nice.<br \/>\nRegards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @<a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\"> twitter.com\/RajeshKumarIn<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>rajeshkumar created the topic: Apache ant interview questions Links to all Apache Ant Task &#8211; ant.apache.org\/manual\/tasklist.html Question 1. Write a ant build.xml and call one batch file from build.xml. batch&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[12],"tags":[420],"class_list":["post-1896","post","type-post","status-publish","format-standard","hentry","category-apache-ant","tag-apache"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=1896"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1896\/revisions"}],"predecessor-version":[{"id":9983,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1896\/revisions\/9983"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=1896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=1896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=1896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}