Skip to content

lineEnding setting is not respected for empty lines and CDATA, multiline text content is deleted #37

@bergerst

Description

@bergerst

I have a pom.xml which is structed like this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-module</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <properties>
    <xml-format-plugin.version>3.2.2</xml-format-plugin.version>

    <sonar.coverage.exclusions><![CDATA[
      src/main/java/A.java,
      src/main/java/B.java,
      src/main/java/C.java,
    ]]></sonar.coverage.exclusions>
    <sonar.exclusions><![CDATA[
      src/main/java/D.java,
      src/main/java/E.java,
    ]]></sonar.exclusions>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>au.com.acegi</groupId>
        <artifactId>xml-format-maven-plugin</artifactId>
        <version>3.2.2</version>
        <executions>
          <execution>
            <id>xml-format</id>
            <goals>
              <goal>xml-format</goal>
            </goals>
            <phase>process-sources</phase>
            <configuration>
              <indentSize>2</indentSize>
              <suppressDeclaration>true</suppressDeclaration>
              <keepBlankLines>true</keepBlankLines>
              <includes>pom.xml</includes>
              <lineEnding>CRLF</lineEnding>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Here's a screenshot of Notepad++ after the pom.xml was formatted:
image

I have several issues with the current behavior:

  1. The plugin inserts an empty line at the top
  2. The line breaks after </xml-format-plugin.version> are LFCRLF, so 1 Linux line break followed by 1 Windows line break. Both should be CRLF.
  3. The CDATA content will also have LFs instead of CRLFs.
  4. If I don't put the lines in the sonar exclusions into CDATA, the plugin will delete the text content.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions