You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2025/09/29 12:02:09 UTC

Re: [PR] Improve enforcer rule error messages [maven-enforcer]

elharo commented on code in PR #343:
URL: https://github.com/apache/maven-enforcer/pull/343#discussion_r2387689904


##########
enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/files/AbstractRequireFiles.java:
##########
@@ -93,21 +93,36 @@ private void fail(List<File> failures) throws EnforcerRuleException {
 
         StringBuilder buf = new StringBuilder();
         if (message != null) {
-            buf.append(message + System.lineSeparator());
+            buf.append(message + '\n');

Review Comment:
   Are you sure about cmd on Windows 10+? I don't have a Windows system handy to test but I asked Gemini and it claims:
   
   The Windows Command Prompt (`cmd.exe`) shell is typically configured to interpret a single Line Feed character (`\n` or ASCII 0x0A) **as a full line break**, even though the native Windows line-ending convention is Carriage Return followed by Line Feed (`\r\n` or ASCII 0x0D 0x0A).
   
   Therefore, when a Java program sends a string containing only `\n` characters to the `cmd` console (via `System.out.print` or `System.err.print`):
   
   1.  **The text will display on new lines correctly.** The console window handles the single `\n` and translates it for proper display, moving the cursor to the beginning of the next line.
   2.  **No display issues like "stair-stepping" will occur.** The cursor will not get "stuck" at the end of the previous line without returning to the left margin.
   
   ### The Key Distinction
   
   The behavior depends on **where** the output is being sent:
   
   | Destination | Line Ending Behavior | Result for `\n` Only |
   | :--- | :--- | :--- |
   | **Console/Shell** (`cmd.exe` window) | The console driver interprets the `\n` and correctly advances the cursor to the start of the next line. | **Correct Multiline Display** |
   | **Plain Text File** (using redirection like `> file.txt`) | The stream is often treated as raw bytes, and the file system retains the single `\n` (Unix-style). | **Single Line Feed is preserved.** Text editors like **Notepad** (pre-Windows 10) may show the output as a single, long line or with empty boxes for the missing `\r`. Modern editors (VS Code, Notepad++, and newer Windows Notepad) will display it correctly. |
   
   **In summary, when printing directly to the `cmd` window, the Java `\n` will result in a clean, new line.**
   



-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org