在 Eclipse 和增量性中向项目添加构建器 [英] Adding Builders to Project in Eclipse and Incremental-ness

查看:23
本文介绍了在 Eclipse 和增量性中向项目添加构建器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Java 项目,选择标准 Java Builder 作为它的唯一构建器.此外,构建配置为自动构建.

I have a Java project, with the standard Java Builder selected as it's sole builder. Also, the build is configured to build automatically.

我想了解的是当我向该项目添加 ant 构建时产生的构建环境(project -> properties ->builders).我所期望的是,每次我对 Java 源代码进行更改时,Java Builder 和我的 ant 构建都会运行,但我的 ant 构建似乎没有运行.

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.

当我第一次添加 ant 构建时,它会运行,即我在控制台中看到输出.但是,当我对源文件进行更改时,它不会再次运行,即我在控制台中看不到输出.我知道 Java Builder 仍在运行,因为我的更改已进入 Eclipses 代码感知,即我可以从其他类等中引用这些更改.

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.

注意,如果我手动调用构建,即通过 Project ->Build All,蚂蚁构建运行,即我再次在控制台中看到输出.

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.

那么,为什么我添加的 ant 构建不能与自动构建一起运行?请注意,我不一定期望它能够执行增量工作,因为它不是为此而设计的,但是我认为它会在 Java Builder 启动时启动?我错过了什么吗?

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?

推荐答案

ant 构建器,或任何其他与此相关的构建器,有几种构建项目的方法.当在 Eclipse 中进行构建时,会调用所有活动构建器的 build(int kind, Map args, IProgressMonitor monitor) 方法,但是,有不同种类的构建,任何构建器在 build 方法中检查.构建的种类是:

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.

这篇关于在 Eclipse 和增量性中向项目添加构建器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆