Ant build process - when does compilation actually happen
Joined: Jun 20, 2012
Hi, I've got a project that I'm trying to deploy and I'm having some issues. My question is when does compilation happen in the build.xml file? My ant build is finishing successfully but there are no files in my projecthome/bin folder. I know that when the build process finishes, there should be class files in the bin folder. What directive in the build.xml file tells ant to compile? How can I make ant create the .class files? I don't think that I have to call <javac> explicitly, right? Ant should generate the class files on it's own, or am I wrong?
If I'm misunderstanding something then please explain how it works. I'm new to Ant and I'm trying to build someone else's project.
Ant is a scripting language, much akin to the make tool for C/C++ development. Only the operations defined in the script will be performed. Gives you lots of power: you can do pretty much anything you want, and that is not restricted to just building Java apps. But you do have to tell it exactly what you want done.
If you want things to be done automatically based on best practices, then use Maven. It will compile your sources, run your unit tests, package up the JAR file, and even generate a number of reports, without you having to do anything other than give it some basic information about your project (mainly what you want to name it).
Technically, it's not scripting, which is why I said "programs" in quotes. Ant build.xml files (and Unix makefiles) are declarative files, not executables (scripts). But pedantry aside, the net effect is the same. Ant will only perform tasks which have been explicitly requested.