Summary
GenerateJdkToolchainsXmlMojo uses System.out.println(writer) to output the generated toolchains XML, bypassing Maven's logging infrastructure. This output will not respect Maven's -q (quiet) or -X (debug) flags.
Location
GenerateJdkToolchainsXmlMojo.java:72
https://github.com/apache/maven-toolchains-plugin/blob/master/src/main/java/org/apache/maven/plugins/toolchain/jdk/GenerateJdkToolchainsXmlMojo.java#L72
Code
} else {
StringWriter writer = new StringWriter();
new MavenToolchainsXpp3Writer().write(writer, toolchains);
System.out.println(writer);
}
Problem
Using System.out.println() instead of getLog().info():
- Bypasses Maven's logging system entirely
- Output appears on stdout even when
-q (quiet mode) is used
- Output is not captured in Maven's log file
- The
writer object is passed to println() instead of writer.toString(), which relies on StringWriter.toString() being called implicitly via println(Object), but this is fragile and depends on StringWriter.toString() being properly overridden (it is, but it's an indirect and non-obvious coding pattern)
Impact
Users running mvn -q generate-jdk-toolchains-xml will still see the XML output on stdout. The XML should either be written to a file (the -Dtoolchain.file path) or logged via the proper Maven logging API.
Suggested Fix
Use the Maven logger:
} else {
StringWriter writer = new StringWriter();
new MavenToolchainsXpp3Writer().write(writer, toolchains);
getLog().info(writer.toString());
}
Summary
GenerateJdkToolchainsXmlMojousesSystem.out.println(writer)to output the generated toolchains XML, bypassing Maven's logging infrastructure. This output will not respect Maven's-q(quiet) or-X(debug) flags.Location
GenerateJdkToolchainsXmlMojo.java:72https://github.com/apache/maven-toolchains-plugin/blob/master/src/main/java/org/apache/maven/plugins/toolchain/jdk/GenerateJdkToolchainsXmlMojo.java#L72
Code
Problem
Using
System.out.println()instead ofgetLog().info():-q(quiet mode) is usedwriterobject is passed toprintln()instead ofwriter.toString(), which relies onStringWriter.toString()being called implicitly viaprintln(Object), but this is fragile and depends onStringWriter.toString()being properly overridden (it is, but it's an indirect and non-obvious coding pattern)Impact
Users running
mvn -q generate-jdk-toolchains-xmlwill still see the XML output on stdout. The XML should either be written to a file (the-Dtoolchain.filepath) or logged via the proper Maven logging API.Suggested Fix
Use the Maven logger: