Netbeans 中的默认 ant 设置将属性build.compiler.emacs
设置为true
. 这是什么意思?蚂蚁文档只是说
启用与 emacs 兼容的错误消息。
我知道 emacs 是一个编辑器,虽然我没有使用过它。将此属性设置为 true 或 false 的效果是什么?
您可能没有注意到描述 javac 任务的那部分ant 文档位于“Jikes 笔记”中。这是一个在使用jikes编译器时修改编译的结果消息格式的设置,当 Emacs 编辑器调用 ant 时(例如,在使用JDEE 环境时),编辑器可以解析结果消息并跳转到正确的位置在与消息相关的文件中。
NB 为一个非标准的编译器包含这样一个设置确实有点奇怪,而且似乎被抛弃了近十年。
给定以下 antbuild.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 更能够解析它们。