2014-06-05 28 views
3

Netbeans中的默認ant設置將屬性build.compiler.emacs設置爲true。這是什麼意思?螞蟻文檔只是說Netbeans Ant build.compiler.emacs

啓用emacs兼容的錯誤消息。

我知道emacs是一個編輯器,但我沒有使用它。將此屬性設置爲true或false有什麼影響?

回答

3

您可能沒有注意到描述javac任務的ant documentation中的那部分位於「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> 

一個簡單的類comporting語法錯誤的編制給出了輸出:

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更有能力解析它們。

相關問題