Tuesday, 25 February 2014

What is Apache Ant ("Another Neat Tool") in java?(ANT Part-1)



Apache Ant ("Another Neat Tool") is a  build tool with special support for the Java programming language however it may be used for regarding everything. Ant is platform-independent. Ant is especially sensible at automating difficult repetitive tasks and so is well matched for automating standardized build processes. Ant accepts directions within the type of XML documents so is extensile and simple to take care of.So you can say it is a xml file you running by the help of Ant.

An ant build file comes within the sort of an XML document, all that's needed may be a straightforward text editor to edit the build file(s). an editor that gives XML syntax lightness is desirable. The ant installation comes with a JAXP-Compliant(Which is XML parser) ,this implies that the installation of AN external XML computer program isn't necessary

For Installation 

1)You will need to download a file apache-ant-1.7.0-bin.zip
2)Extract it 
3)Here you will get "bin" folder
4)In "bin" run the ant.bat file from cmd.


Now let us try this with a simple build.xml for this.

1)create a file in notepad or any other file editor

2)copy the below code in that

<?xml version="1.0"?>
   <project name="My First Project" default="whatsup">
       <target name="whatsup">
          <echo>Hi this is my first ant build file</echo>
       </target>
   </project>

3)Save this as build.xml file(in ant bin directory where ant.bat is present)
apache ant

4)You can run this from a DOS  command prompt by typing

  ant
Ant will search for the build file in the current directory and run the build.xml file.

5)your out put will


Buildfile: build.xml
  
  whatsup: 
     [echo] Hi this is my first ant build file!
  
  Build Successful
  Total time 0 seconds

If you have many targets which you have run or execute in series then you can use depends attribute.
The depends attribute may be enclosed within the target tag to specify that this target needs another target to be executed before being executed itself. Multiple targets may be nominal and separated with commas.

<target name="ab" depends="bc, cd,de">

<?xml version="1.0" encoding="UTF-8"?>

 <project default="3">
     <target name="1">
        <echo>Running first</echo>
     </target>
  
     <target name="2" depends="1">
        <echo>Running second</echo>
     </target>
  
     <target name="3" depends="2">
        <echo>Running third</echo>
     </target>
  </project>

Buildfile: build.xml
  
  one:
     [echo] Running first
  
  two:
     [echo] Running second
  
  three:
     [echo] Running third
  
  BUILD SUCCESSFUL
  Total time: 0 seconds


Ant Task – one thing that ant will execute like a compile, copy or replace. Most tasks have much convenient default values. See the ant manual for an entire list of tasks.

Ant Target – a hard and fast series of ant tasks in an exceedingly nominal order that may depend on alternative named targets. Targets will depend solely on alternative targets, not on projects or tasks. A target represents a specific item to be created, it can be one item sort of a jar, or a group of things, like classes.

Ant Project – a set of named targets that may run in any order looking on the time stamps of the files within the file system. every build file contains one project.


Here are a few things to note:

1.The Begin and finish tags for project (<project> and </project>) MUST Begin and end the file.

2.The tag project MUST have an attribute called default which is the targets called first.

3.There should be at least one target in each build file.

4.The Begin and finish tags for <target> and </target> must  match EXACTLY.

5.Each target should  have a name.

6.Targets will only depend  on other targets and reference them by their name(target name). it NEVER depend on projects or tasks.

7.Target depends are not mandatory.

8.To print any thing in output on console write it in <echo> and </echo> tags.

9.All task has to be in a target.


You may also like:-

Using JConsole in java And creating memory dump by it

Heap analysis by Memory Analyzer (MAT) - Eclipse java

Main causes of Out-Of-Memory Errors in java

Five main types of Memory leaks in java

How to Reduce Garbage-Collection Pause Time?

4 Mains causes of Long Garbage Collection Pause?


How Application Performance get impacted by Garbage Collection?


Java Performance Tuning options Java heap


Why Memory leak in Java ?


What is a Memory Leak in java?


What is Garbage collector in java and how it works?


What is Garbage Collector Compaction in Java?


What are Java heap Young, Old and Permanent Generations?


What is difference between Web Server and Application Server ?


What is the maximum ram for 32 bits and 64 bits computer?


Some Amazing fact about memory (petabyte,exabyte,zettabyte) And How much data exists on the Web?
http://www.casino-online.us

No comments:

Post a Comment

Hemant Kurmi - 2021 - Some Amazing Facts About Memory: Petabyte, Exabyte, and Zettabyte

Some Amazing Facts About Memory: Petabyte, Exabyte, and Zettabyte As technology advances, our ability to store and process data has grown ...