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