Netbeans Ant build.compiler.emacs

标签 netbeans emacs ant jikes

Netbeans 中的默认 ant 设置将属性 build.compiler.emacs 设置为 true。这是什么意思? ant 文档只是说

Enable emacs-compatible error messages.

我知道emacs是一个编辑器,虽然我没有使用过它。将此属性设置为 true 或 false 会产生什么效果?

最佳答案

您可能没有注意到 ant documentation 的那部分描述 javac 任务的内容在“Jikes Notes”中。这是一个在使用 jikes 时修改编译结果消息格式的设置。编译器的方式是,当 Emacs 编辑器调用 ant 时(例如,使用 JDEE environment 时),编辑器可以解析结果消息并跳转到与消息相关的文件中的正确位置。

NB 为一个非标准编译器提供这样的设置确实有点奇怪,而且似乎已经被放弃了近十年。

给定以下 ant build.xml 文件

<project name="mini" basedir="." default="compile">
  <property name="build.compiler.emacs" value="off"/>
  <property name="build.compiler" value="jikes"/><!-- invoke jikes instead of javac-->
  <target name="compile">
    <javac srcdir="." destdir="" classpath="." includeantruntime="false">
    </javac>
  </target>
</project>

编译一个存在语法错误的简单类会给出以下输出:

Buildfile: /Users/seb/projets/java/ant/build.xml

compile:
    [javac] Compiling 1 source file to /Users/seb/projets/java/ant
    [javac] 
    [javac] Found 1 semantic error compiling "Hello.java":
    [javac] 
    [javac]      5.                 System.out.println("Hello, World!"+foo);
    [javac]                                                            ^-^
    [javac] *** Semantic Error: No accessible field named "foo" was found in type "Hello".

BUILD FAILED
/Users/seb/projets/java/ant/build.xml:5: Compile failed; see the compiler error output for details.

Total time: 1 second

当您通过将 build.compiler.emacs 属性更改为 on 获得此输出时:

Buildfile: /Users/seb/projets/java/ant/build.xml

compile:
    [javac] Compiling 1 source file to /Users/seb/projets/java/ant
    [javac] Hello.java:5:52:5:54: Semantic Error: No accessible field named "foo" was found in type "Hello".

BUILD FAILED
/Users/seb/projets/java/ant/build.xml:5: Compile failed; see the compiler error output for details.

Total time: 1 second

在后一个版本中,消息不那么花哨,Emacs 解析它们的能力更强。

关于Netbeans Ant build.compiler.emacs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24059886/

相关文章:

emacs 使用 auto-complete-clang 自动完成,显示无效的成员函数

batch-file - 如何使用批处理文件执行 ant?

java - 输入三个数字,并使用嵌套 if 按降序排列

java - 为什么 NetBeans IDE 专门使用 import 语句?

debugging - 为什么我的 emacs 发出声音(文件末尾有噪音)?

search - "1 of n"Emacs 搜索结果

ant - 如何让 xslt 缩进 xml(来自 Ant)?

apache - 未能创建任务或类型 if

java - Netbeans 中不可编辑的 actionPerformed block

eclipse - 哪个是最好的 RCP 平台