sortpom: Invalid sorting on line break in artifactId value

Settings:

      <plugin>
        <groupId>com.github.ekryd.sortpom</groupId>
        <artifactId>sortpom-maven-plugin</artifactId>
        <version>2.13.1</version>
        <configuration>
          <keepBlankLines>true</keepBlankLines>
          <createBackupFile>false</createBackupFile>
          <expandEmptyElements>false</expandEmptyElements>
          <sortModules>true</sortModules>
          <sortDependencies>scope,groupId,artifactId</sortDependencies>
          <sortProperties>true</sortProperties>
          <sortPlugins>groupId,artifactId</sortPlugins>
          <spaceBeforeCloseEmptyElement>false</spaceBeforeCloseEmptyElement>
        </configuration>
      </plugin>

Before sorting:

    <dependency>
      <groupId>foo.bar</groupId>
      <artifactId>baz</artifactId>
    </dependency>

    <dependency>
      <groupId>foo.bar</groupId>
      <artifactId>
        foo.bar.veryLongArtifactId
      </artifactId>
    </dependency>

After first sorting:

    <dependency>
      <groupId>foo.bar</groupId>
      <artifactId>foo.bar.veryLongArtifactId
      </artifactId>
    </dependency>

    <dependency>
      <groupId>foo.bar</groupId>
      <artifactId>baz</artifactId>
    </dependency>

On restart:

    <dependency>
      <groupId>foo.bar</groupId>
      <artifactId>baz</artifactId>
    </dependency>

    <dependency>
      <groupId>foo.bar</groupId>
      <artifactId>foo.bar.veryLongArtifactId
      </artifactId>
    </dependency>

But after formatting:

    <dependency>
      <groupId>foo.bar</groupId>
      <artifactId>
        foo.bar.veryLongArtifactId
      </artifactId>
    </dependency>

    <dependency>
      <groupId>foo.bar</groupId>
      <artifactId>baz</artifactId>
    </dependency>

Does not change on subsequent launches.

But baz I expect first.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Released SortPom version 2.14.1 with the bug fix. Enjoy!!

So it is the google style plugin that reinserts the line breaks. No way around that unless you have shorter artifactIds.

But the other issue is a bug. Good job finding it! The dependencies should be sorted correctly on the first pass, I’ll get to it and try to solve it

Cut off the same part, yes that’s brilliant 😄 , thanks!