• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ant build process - when does compilation actually happen

 
Chris Cassano
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks in advance.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do have to call <javac> explicitly. Ant doesn't do things unless you tell it to. (unlike Maven which compiles by default.)
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ant build files are basically "programs" and they build things under specified orders. If you don't specify a task, it doesn't get done. An empty build.xml does nothing at all.

Maven POMs are information repositories. Maven builds everything by "magic", using the POM as a reference and inferring lots of things if they aren't explicitly defined in the POM.

Since I'm not a big fan of "magic", I resisted using Maven for a long time, but these days I use it more than I do Ant.

 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic