How to write the ant scripts

Introduction:

ant means another neat tool.
ant files are written in XML.
while running the ant it will search for whether the build.xml file is there or not.

Example1:

<?xml version = "1.0"?>
<project name = "QuickDevOps" default = "execute">
   <target name = "execute">
      <echo>Hello Guys welcome to the www.quickdevops.com</echo>
   </target>
</project>

Explanation:
  • To execute the build.xml file open the command prompt and type ant (it will search for build.xml file otherwise change the directory into the script folder.
  • If we write any XML files the basic tag is which version we are using. and every tag should be completed with opening and closing <echo>statement</echo>.
  • The next one is root tag (project) here we mention the name and default target name. Finally, it terminates with the end tag of </project>.
  • The next one is target tag here we mention (copy the files, creating directories, removing directories). In this example, I am just print the sample message.
Output:
Example

Example2:

<?xml version = "1.0"?>
<project name = "QuickDevOps" default = "execute">
   <target name = "execute" depends="Compile">
      <echo>welcome to www.quickdevops.com</echo>
   </target>
 
     <target name = "Compile" >
      <echo>Hello I am Ramjanardhan Randhi</echo>
   </target>
 
</project>

Explanation:

In this build.xml file, I am introducing the new tag (depends: means base tag or parent tag depends on another one). In above example, the default tag name is executed, but execute is depends on Compile so while running the ant file it will check the default name . it will depend on another one or not in case it depends on another one after executing the second then execute the base tag. this is the scenario. Here first execute the compile and then move to ex section.

Output:
Example2

Example 3:

<?xml version = "1.0"?>
<project name = "QuickDevOps" default="Execute">
<property name="site" value="https://wwww.quickdevops.com" />

<target name="Execute" >
<echo>Hello friends Here is my website link ${site}</echo>
</target>
</project>

Explanation: We can set the values to variables using the property tag. we can get the value from using the syntax  ${name of propeerty}.

Output:
Example3

SUBSCRIBE TO OUR NEWSLETTER

I’m the Founder of quickdevops.com. I am a Professional Blogger, Application developer, YouTuber. I’ve been blogging since 2015.I spend a lot of time learning new techniques and actively help other people learn web development through a variety of help groups and writing web development tutorials for my website and blog about advancements in web design and development.Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie or planning a trip to someplace I've never been before.

0 Response to "How to write the ant scripts"

Post a Comment