I have a Java project, with the standard Java Builder selected as it's sole builder. Also, the build is configured to build automatically.
What I would like to understand is the resulting build circumstances when I add an ant build to this project (project -> properties -> builders
). What I would expect, is that everytime I make a change to my Java source, both the Java Builder and my ant build will run, but it doesn't seem that my ant build runs.
When I first add the ant build, it runs, i.e I see the output in the console. However, when I then make changes to my source files, it doesn't run again, i.e. I don't see output in the console. I know that the Java Builder is still running due to the fact that my changes have entered into Eclipses code awareness, i.e. I can reference those changes from other classes, etc.
Note, if I manually invoke the build, i.e. via Project -> Build All
, the ant build runs, i.e. I see the output in the console again.
So, why doesn't the ant build I've added run with the automatic building? Note, I wouldn't necessarily expect it to be able to do incremental work, since it's not made for that, but I would have thought it would fire off when the Java Builder fires off? Am I missing something?
The ant builder, or any other builder for that matter, have several methods for building a project. When a build occurs in the Eclipse, the build(int kind, Map<String, String> args, IProgressMonitor monitor)
method of all the active builders is called, but, there are different kinds of build, that any builder checks for in the build
method. The kinds of build are:
FULL_BUILD
AUTO_BUILD
INCREMENTAL_BUILD
CLEAN_BUILD
Here is an example syntax of build:
protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
if (kind == FULL_BUILD) {
fullBuild(monitor);
} else {
IResourceDelta delta = getDelta(getProject());
if (delta == null) {
fullBuild(monitor);
} else {
incrementalBuild(delta, monitor);
}
}
return null;
}
As you can see, a builder can decide to react to a certain kind of build, and even act differently for different build kinds, so, my guess is, the ant builder is implemented so that it only reacts to full build, and not incremental build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With