elharo opened a new issue, #172: URL: https://github.com/apache/maven-toolchains-plugin/issues/172
## 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 ```java } else { StringWriter writer = new StringWriter(); new MavenToolchainsXpp3Writer().write(writer, toolchains); System.out.println(writer); } ``` ## Problem Using `System.out.println()` instead of `getLog().info()`: 1. Bypasses Maven's logging system entirely 2. Output appears on stdout even when `-q` (quiet mode) is used 3. Output is not captured in Maven's log file 4. 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: ```java } else { StringWriter writer = new StringWriter(); new MavenToolchainsXpp3Writer().write(writer, toolchains); getLog().info(writer.toString()); } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
