Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
634 views
in Technique[技术] by (71.8m points)

ant - Adding Builders to Project in Eclipse and Incremental-ness

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...