【问题标题】:Netbeans Ant build.compiler.emacsNetbeans Ant build.compiler.emacs
【发布时间】:2014-06-05 12:10:41
【问题描述】:

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

启用与 emacs 兼容的错误消息。

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

【问题讨论】:

    标签: netbeans emacs ant jikes


    【解决方案1】:

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

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

    给定以下蚂蚁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 更能够解析它们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-21
      • 2017-12-28
      • 1970-01-01
      • 1970-01-01
      • 2013-06-14
      • 1970-01-01
      • 2014-11-19
      • 2019-06-15
      相关资源
      最近更新 更多