Ekryd / sortpom

Maven plugin that helps the user sort pom.xml.
https://github.com/Ekryd/sortpom/wiki/
BSD 3-Clause "New" or "Revised" License
334 stars 178 forks source link

remove newline characters 
 #446

Open martinaldrin opened 1 week ago

martinaldrin commented 1 week ago

Hi, We uplifted sortpom-maven-plugin 2.13.1 -> 4.0.0 after that we got issues with incorrect format in our generated sources since the new version of sortpom-maven-plugin first replaces X with new lines, and next time it formats it replaces it with single spaces. How can we avoid such formatting behaviour? <echo file="${propertiesfile}" message="#Created by X&#xA;version=${testng.version}&#xA;groupId=org.testng&#xA;artifactId=testng" />

replaced by: <echo file="${propertiesfile}" message="#Created by X version=${testng.version} groupId=org.testng artifactId=testng" />


<plugin>
                <!-- Generate a TestNG maven propertiesfile.java -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <target>
                                <property name="whitespace" value=" " />
                                <property name="src.dir" value="${basedir}/target/generated-sources/properties" />
                                <property name="package.dir" value="META-INF/maven/org.testng/testng" />
                                <property name="buildtime" value="${maven.build.timestamp}" />
                                <property name="propertiesfile" value="${src.dir}/${package.dir}/pom.properties" />
                                <echo message="BUILDING : ${propertiesfile}" />
                                <echo file="${propertiesfile}" message="#Created by X&#xA;version=${testng.version}&#xA;groupId=org.testng&#xA;artifactId=testng" />
                                <echo message="BUILD ${buildtime} : ${propertiesfile}" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
Ekryd commented 3 days ago

Hi! Does the xml:space="preserve" directive change the behaviour? Otherwise ignoring sections can help (have a look in the wiki).

Btw, I hope that you are ok with using the antrun plugin? The ant build format is very old (2000 -> RIP 2004). I would recommend using echo-maven-plugin for echoing information during the build (yes, I'm biased)