UPDATE(25/06/2016):在plexus-compiler
的This issue是固定的,在這個問題給定的代碼將作爲2.8版本。
通過源代碼讀取後,這是在2.7 plexus-compiler
的一個錯誤,這是內部使用maven-compiler-plugin
3.5.1編譯Java源庫。
因此,它是這樣的碼:該maven-compiler-plugin
填充稱爲CompilerConfiguration
一個對象,並根據在POM中的給定的配置元件設置其fork
和verbose
。所述verbose
元件is correctly read and added to the compiler arguments:
if (config.isVerbose())
{
args.add("-verbose");
}
然後,有一個開關depending on whether we're forking or not。
如果我們沒有,我們最終歸結爲代碼調用javac
,其輸出is stored in the compilation result:
ok = (Integer) compile.invoke(null, new Object[]{ args, new PrintWriter(out) });
messages = parseModernStream(ok.intValue(), new BufferedReader(new StringReader(out.toString())));
終於returned with:
return new CompilerResult(success, messages);
到目前爲止,maven-compiler-plugin
將環繞這些消息並將其輸出到控制檯。由於verbose
參數已設置,我們將收到所有消息。
如果我們,然後一個可執行文件(默認爲在路徑中javac
)檢索和the compiler arguments are correctly set:
for (String key : config.getCustomCompilerArgumentsAsMap().keySet())
{
if (StringUtils.isNotEmpty(key) && key.startsWith("-J"))
{
cli.addArguments(new String[]{ key });
}
}
我們可以通過調試模式下運行的Maven證實了這一點與-X
,我們將看到消息:
[DEBUG] Excutable:
[DEBUG] "C:\Program Files\Java\jdk1.8.0_74\bin\javac.exe"
[DEBUG] Command line options:
[DEBUG] -d ... -classpath ... -sourcepath ... -s ... -g -target 1.8 -source 1.8 -verbose
最後注意-verbose
。
然後,這是錯誤。標準輸出將被存儲內的out
可變
CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
正確用作編譯方法的參數
,but completely ignored afterwards:
returnCode = CommandLineUtils.executeCommandLine(cli, out, err);
messages = parseModernStream(returnCode, new BufferedReader(new StringReader(err.getOutput())));
通知如何消息,這將稍後形成插件輸出的內容,僅填充錯誤而不填充標準輸出。所以簡單地說:標準輸出在詳細模式下被正確設置,但是它被忽略並且不被轉換成正確的編譯結果。
我沒有看到解決方法(除了不分叉)。我在他們的GitHub中創建了issue 20來跟蹤這個。
可以確認這一點。奇怪的是,我找不到這方面的錯誤報告。最接近的似乎是https://issues.apache.org/jira/browse/MCOMPILER-81,但它是自動關閉= /。 – Tunaki
@Tunaki我在其他開發者的同意下每年進行一次自動關閉以清理JIRA。至少三年未被觸及的門票不會再被觸及,無論他們是否重要。 –
@ Michael-O我正在寫一個答案,它看起來像一個叢編譯器內部的錯誤。 – Tunaki