Level: Intermediate
ANT is a tool used when doing a project programming and must be repeated repetitive tasks such as compilation and construction. Ant is written in Java and is very similar to Make, but with the advantages of being platform and not dependent on the operating system instructions, but is configured with XML files. ANT is an open-source project of the Apache Software Foundation.OK to start using ANT, the first thing to do is download page for apache can write to google ANT and will be one of the first results, but here's the link:
http://ant. apache.org / bindownload.cgi
And if you set it then you'll see information about the version of Ant you've downloaded, but is properly configured will tell you that ant is not a recognized command.
ANT To all we have to do is create an XML configuration file which will contain instructions that is what we do. In ANT we have set a target, which is next to be executed and then the tasks that we want to do when you select that goal. Well to start, we will establish a new project, create a folder called introduccionant, and that will put two files:
HolaMundo.java (The file that we compile and run with ant) \u200b\u200bbuild.xml
(The configuration file ANT)
public class HelloWorld {public static
void main (String [] args) {
System.out.println ("Hello World");}
} build.xml
basedir = "."
default = "compile">
debug = "true"
deprecation = "false"
optimize = "false"
FailOnError = "true">
first define a project, give it a name, we put the base directory, in this case is the same and we are putting the "." and Target which by default will run is to build name.
After that we must define the target, which has compiled name (the default) and then placed the tasks we perform, in this case we just want to call javac to compile files, our target directory will be the same and also put some additional options. Also when using javac, it is imperative that we have defined where the source files that define the source directory also in this case and for simplicity is also the same.
Now all you have to do is go to a command line introduccionant go to the directory and run the command:
ant
After this the result will say that the build has been successful and those who have used NetBeans, see the console output is equal to the IDE, this is because NetBeans uses Ant to do the build of our projects. And if you go to the directory using Explorer you will see your file. Class has been created and can write in the command line:
java HelloWorld
Well with that we our first program compiled using ant, now all you have to do is add more options to our build.xml file so we can get more done using ANT.
Greetings
0 comments:
Post a Comment