• Post Reply Bookmark Topic Watch Topic
  • New Topic

what is Ant?  RSS feed

 
marten kay
Ranch Hand
Posts: 188
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is somebody able to give me a description of what Ant does - without saying that it similar to Make?

As background, I have learned java programming recently, first compiling programs using command line and now netbeans. Now I am having difficulties with netbeans when refactoring etc and I suspect the problem is in the build process, but I can't for the life of me figure out what ANT actually does, and I have never used "Make", on which most explanations are based.

This is hindering my progress.

Can anybody help?

Thanks
 
Thomas Young
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figure you understand that is a build tool for java.
It builds apps based on an xml build file
From my limited understanding this build file breaks the build process down from a project into targets and each target contains tasks.

Perhaps you could let us know exactly what the problem you are facing is?

Regards,
TY.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiling , testing, and packaging a non-trivial program involves multiple steps, and each step may need a complicated command line. Furthermore, the steps may depend on each other. If A.java is newer than A.class, but B.java is older than B.class, then A.java and B.java (which depends on A.java) still need to be compiled; but if A.java is older than A.class, and B.java is older than B.class, then neither file needs to be compiled. And so on.

Furthermore, all the complicated command lines might depend on a few parameters like the directory where the source exists on the local machine, the drive letter of the CD writer, a username and password for the machine where your source code repository lives, etc.

And building a WAR file can be a nightmare; things compiled, jarred up, copied here and there, jarred again.

Ant provides a means for writing simple(ish) cross-platform scripts for automating all of this kind of stuff. There are lots of reusable chunks of scripts that you can invoke with just a little typing. Ultimately, you get your script all set up, and then just type (for example) "ant buildall" to build everything, "ant test" to test everything, or "ant deploy" to build a WAR file and push it to your server.

For single-class student programs, it's overkill. For real-life problems, it's indispensible (unless you use make instead; make does the same stuff )
 
marten kay
Ranch Hand
Posts: 188
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks both Ernest and Thomas.
Perhaps you could let us know exactly what the problem you are facing is?


I suppose my key problem is that I don't get it, (but getting there)

My current problem is that when I "rename" of a perfectly working web-app project with the Netbeans interface I suddenly get a 503. Other small changes do the same. Whenever I go back to my backup things are fine.

In the past, i have not been able to rename a class (a struts action form) to "FormAdminForm", even though changing the name to anything else works.

I suspect these are all problems in the automatic build process that is a black box to me at the moment.

Do you think this maybe the case?

Further, I intend to be sole developer for at least another six months, do I need to know Ant, or can I just get by with Netbeans.

Thanks
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Further, I intend to be sole developer for at least another six months, do I need to know Ant, or can I just get by with Netbeans.

You need to know Ant. NetBeans automatically generates the Ant script for you and you're allowed to customized it, but it can be somewhat complicated for beginner. And my advice is not to rely too much on it since not everyone uses NetBeans.
 
arulk pillai
Author
Ranch Hand
Posts: 3417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is better to know Ant. Also worth learning Maven2.
 
marten kay
Ranch Hand
Posts: 188
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks arulk

Which one should I learn first, Ant or Maven?

From where I see it
Ant is closely related to Netbeans

Maven is closely related to Struts 2.

Again, thanks to everybody
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Learn Ant first since it's a easier. Maven2 is pretty complicated, but it's worth knowing.

Both tools are supported by NetBeans.

And no, Ant isn't closed related to NetBeans and Maven2 isn't closed related to Struts2. Both of them can be used to build Java apps, but Maven2 is more than just a build tool.

Hope this helps.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might be worth your while to take a look at http://ant.apache.org/faq.html
 
marten kay
Ranch Hand
Posts: 188
Java jQuery Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Freddy and Maneesh.

I have an Ant book on order, and I am once again progressing.

As a closing comment, the ant website answers my question with
Ant is a Java-based build tool. In theory, it is kind of like Make, without Make's wrinkles and with the full portability of pure Java code.


As I haven't used 'make', and the need for a 'build' is not obviously apparent as I seriously tinker in netbeans, it is a bit difficult to get grasp the purpose of Ant. Ernest's description really helped here, as did the other comments.

Cheers
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!