Skip to content

Recommended configuration

Björn Ekryd edited this page Apr 10, 2015 · 12 revisions

Recommended configuration

Simple Example

Maven users can add this plugin with the following addition to their pom.xml file. This will make sure that you pom file is sorted every time you compile the project.

...
<build>
  <plugins>
    <plugin>
      <groupId>com.github.ekryd.sortpom</groupId>
      <artifactId>sortpom-maven-plugin</artifactId>
      <version>2.4.0</version>
      <executions>
        <execution>
          <goals>
            <goal>sort</goal>
          </goals>
          <phase>verify</phase>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
...

Advanced configuration

The plugin comes with many parameters and this is how I would configure the plugin in a new project. It still sort the pom-file each time your project is compiled.

...
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    ...
  </properties>

...
  <build>
    <plugins>
      <plugin>
        <groupId>com.github.ekryd.sortpom</groupId>
        <artifactId>sortpom-maven-plugin</artifactId>
        <version>2.4.0</version>
        <configuration>
          <predefinedSortOrder>custom_1</predefinedSortOrder>
          <lineSeparator>\n</lineSeparator>
          <encoding>${project.build.sourceEncoding}</encoding>
          <sortProperties>true</sortProperties>
          <keepBlankLines>true</keepBlankLines>
          <sortDependencies>scope</sortDependencies>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>sort</goal>
            </goals>
            <phase>verify</phase>
          </execution>
        </executions>
      </plugin>

        ...
    </plugins>
   
    ...
</build>
...

A more detailed description of the parameters.

Clone this wiki locally