This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git

commit 1af99a06d31c588cb5e62b1ac10ad72b6964e68e
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Thu Nov 5 02:16:45 2026 +0000

    Assert the help mojo source separators and explain the empty extractor
    
    The reproducibility test generated twice through one code path and passed 
without the MPLUGIN-363 normalisation. The goal prefix now carries CR, LF and 
CRLF, which only the normalisation turns into the platform separator.
---
 .../plugin/HelpGeneratorMojoExecuteTest.java       | 27 ++++++++++++++--------
 .../descriptor-packaging-jar/plugin-config.xml     |  2 +-
 .../unit/descriptor-scope/plugin-config.xml        |  2 +-
 .../unit/descriptor-skip/plugin-config.xml         |  2 +-
 .../plugin-config.xml                              |  2 +-
 5 files changed, 22 insertions(+), 13 deletions(-)

diff --git 
a/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/HelpGeneratorMojoExecuteTest.java
 
b/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/HelpGeneratorMojoExecuteTest.java
index bc82f9dc..6245314d 100644
--- 
a/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/HelpGeneratorMojoExecuteTest.java
+++ 
b/maven-plugin-plugin/src/test/java/org/apache/maven/plugin/plugin/HelpGeneratorMojoExecuteTest.java
@@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
 
 import static 
org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 @MojoTest
@@ -45,23 +45,32 @@ class HelpGeneratorMojoExecuteTest {
     @Inject
     private MavenProject project;
 
-    /** MPLUGIN-363: generating the help mojo again must not change a single 
byte of it. */
+    /**
+     * MPLUGIN-363: every line separator of the generated help mojo is the one 
of the platform, whatever the
+     * separators of the template or of the values written into it are. The 
goal prefix is written into a comment of
+     * the source, so it carries all three separator styles here.
+     */
     @Test
     @InjectMojo(goal = "helpmojo", pom = "plugin-config.xml")
     @Basedir("/unit/help-reproducible")
-    void helpMojoSourceIsReproducible(HelpGeneratorMojo mojo) throws Exception 
{
+    void helpMojoSourceUsesOnlyThePlatformLineSeparator(HelpGeneratorMojo 
mojo) throws Exception {
         project.setGroupId("org.apache.maven.its.plugin");
         project.setArtifactId("help");
         project.setVersion("1.0-SNAPSHOT");
         project.setPackaging("maven-plugin");
+        setVariableValueToObject(mojo, "goalPrefix", 
"one\r\ntwo\rthree\nfour");
 
-        Path first = generate(mojo, "run1");
-        Path second = generate(mojo, "run2");
+        Path generated = generate(mojo, "run1");
 
-        String firstSource = new String(Files.readAllBytes(first), 
StandardCharsets.UTF_8);
-        assertTrue(firstSource.contains("package 
org.apache.maven.its.plugin.help;"), firstSource);
-        assertTrue(firstSource.contains("prefix"), firstSource);
-        assertEquals(firstSource, new String(Files.readAllBytes(second), 
StandardCharsets.UTF_8));
+        String source = new String(Files.readAllBytes(generated), 
StandardCharsets.UTF_8);
+        assertTrue(source.contains("package 
org.apache.maven.its.plugin.help;"), source);
+        assertTrue(
+                source.contains("one" + System.lineSeparator() + "two" + 
System.lineSeparator() + "three"
+                        + System.lineSeparator() + "four"),
+                source);
+        String withoutSeparators = source.replace(System.lineSeparator(), "");
+        assertFalse(withoutSeparators.contains("\r"), "stray carriage return 
in the generated source");
+        assertFalse(withoutSeparators.contains("\n"), "stray line feed in the 
generated source");
     }
 
     private Path generate(HelpGeneratorMojo mojo, String directoryName) throws 
Exception {
diff --git 
a/maven-plugin-plugin/src/test/resources/unit/descriptor-packaging-jar/plugin-config.xml
 
b/maven-plugin-plugin/src/test/resources/unit/descriptor-packaging-jar/plugin-config.xml
index 0bc4b2c7..dfdc00b0 100644
--- 
a/maven-plugin-plugin/src/test/resources/unit/descriptor-packaging-jar/plugin-config.xml
+++ 
b/maven-plugin-plugin/src/test/resources/unit/descriptor-packaging-jar/plugin-config.xml
@@ -27,7 +27,7 @@ under the License.
         <configuration>
           <goalPrefix>prefix</goalPrefix>
           <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
-          <!-- no extractors: the test only needs the descriptor file to be 
written -->
+          <!-- the empty element selects no extractor, because the scanner 
drops empty names: the test only needs the descriptor file to be written -->
           <extractors>
             <extractor/>
           </extractors>
diff --git 
a/maven-plugin-plugin/src/test/resources/unit/descriptor-scope/plugin-config.xml
 
b/maven-plugin-plugin/src/test/resources/unit/descriptor-scope/plugin-config.xml
index 655c6038..8d1a1dd2 100644
--- 
a/maven-plugin-plugin/src/test/resources/unit/descriptor-scope/plugin-config.xml
+++ 
b/maven-plugin-plugin/src/test/resources/unit/descriptor-scope/plugin-config.xml
@@ -27,7 +27,7 @@ under the License.
         <configuration>
           <goalPrefix>prefix</goalPrefix>
           <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
-          <!-- no extractors: the test only needs the descriptor file to be 
written -->
+          <!-- the empty element selects no extractor, because the scanner 
drops empty names: the test only needs the descriptor file to be written -->
           <extractors>
             <extractor/>
           </extractors>
diff --git 
a/maven-plugin-plugin/src/test/resources/unit/descriptor-skip/plugin-config.xml 
b/maven-plugin-plugin/src/test/resources/unit/descriptor-skip/plugin-config.xml
index 6b895049..208ead63 100644
--- 
a/maven-plugin-plugin/src/test/resources/unit/descriptor-skip/plugin-config.xml
+++ 
b/maven-plugin-plugin/src/test/resources/unit/descriptor-skip/plugin-config.xml
@@ -27,7 +27,7 @@ under the License.
         <configuration>
           <goalPrefix>prefix</goalPrefix>
           <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
-          <!-- no extractors: a run that is not skipped just writes an empty 
plugin.xml -->
+          <!-- the empty element selects no extractor, because the scanner 
drops empty names: a run that is not skipped just writes an empty plugin.xml -->
           <extractors>
             <extractor/>
           </extractors>
diff --git 
a/maven-plugin-plugin/src/test/resources/unit/descriptor-unsupported-packaging/plugin-config.xml
 
b/maven-plugin-plugin/src/test/resources/unit/descriptor-unsupported-packaging/plugin-config.xml
index be8678e1..f1293e2b 100644
--- 
a/maven-plugin-plugin/src/test/resources/unit/descriptor-unsupported-packaging/plugin-config.xml
+++ 
b/maven-plugin-plugin/src/test/resources/unit/descriptor-unsupported-packaging/plugin-config.xml
@@ -27,7 +27,7 @@ under the License.
         <configuration>
           <goalPrefix>prefix</goalPrefix>
           <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
-          <!-- no extractors: a run that is not skipped just writes an empty 
plugin.xml -->
+          <!-- the empty element selects no extractor, because the scanner 
drops empty names: a run that is not skipped just writes an empty plugin.xml -->
           <extractors>
             <extractor/>
           </extractors>

Reply via email to