Netbeans Ant构建.compiler.emacs

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

启用emacs兼容的错误信息。

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

1个回答

3
您可能没有注意到ant文档中描述javac任务的部分在“Jikes注释”中。这是一种设置,可以在使用jikes编译器时修改编译结果消息的格式,以便当Emacs编辑器(例如,在使用JDEE环境时)调用ant时,编辑器可以解析结果消息并跳转到与消息相关的文件中的正确位置。
确实有点奇怪,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 能够更好地解析它们。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接