lunes, 21 de septiembre de 2015

Ant II - Run Java using Ant

In previous post I explain of Ant.Review the post http://marisolchambiarrosquipa.blogspot.com/2015/09/ant-part1.html
 
We are going to follow the next steps to run a java class using Ant

1. Create a simple Java class in Eclipse








2.Write an Ant script that compiles and runs the Ant script
    2.1 Create an Xml file















    2.2 Write an Ant scripts












3.Open up a command prompt(CMD) and run the Ant script














lunes, 7 de septiembre de 2015

Ant Part1

Apache Ant is a Java-based build tool from Apache Software Foundation. Apache Ant’s build files are written in XML and they take advantage of being open standard, portable, and easy to understand.
Ant’s build file called build.xml should reside in the base directory of the project. However there is no restriction on the file name or its location. You are free to use other file names or save the build file in some other location

Requirement

  1. Download lasted version of Ant in this page http://ant.apache.org/bindownload.cgi#current Release of Ant
  2. Edit and Add environment variables on machine
  3. Build a basic ant script and run from command prompt
  4. Execute the script from command prompt
1. Download lasted version of Ant

2. Edit and Add environment variables on machine

Extract files that we download






4. Build a basic ant script and run from command prompt



The Xml element project 
Name :The Name of the project. (Optional)
Default The default target for the build script. A project may contain any number of targets. This attribute specifies which target should be considered as the default. (Mandatory)
The target elements has the following attributes
Name: The name of the target(Required)
Depends: Comma separated list of all targets that this target depends on(optional)
Description: A short description of the target(optional)
if Allows the execution of a target based on the trueness of a conditional attribute(optional)
Unless Adds the target to the dependency list of the specified extension point.An extension  point is similar to a target, but it does nor have any tasks(optional)
The echo task in the above example is a trivial task that prints a message.


Create the file Build.xml



4. Execute the script from command prompt