Skip to content
Björn Ekryd edited this page Apr 2, 2017 · 52 revisions

Parameters

For both the Sort and Verify goal

(These wiki pages are narrow, so scroll to the right for an example)

Parameter Default value Description Example
<pomFile> pom.xml Location of the pomfile. Sidenote: Sorting other XML -Dsort.pomFile="myPom.xml"

<pomFile>myPom.xml</pomFile>
<encoding> UTF-8 Encoding for the files -Dsort.encoding="ASCII"

<encoding>ASCII</encoding>
<predefinedSortOrder> default_1_0_0 Select from a number of predefined sort profiles if you cannot be bothered to use a sortOrderFile and the default sort order does not match. -Dsort.predefinedSortOrder="custom_1"

<predefinedSortOrder>custom_1</predefinedSortOrder>
<sortOrderFile> none Custom sort order file read from either executing path, classpath or as URL. File example -Dsort.sortOrderFile=<br>"src/main/resources/customSortOrder.xml"

<sortOrderFile>src/main/resources/customSortOrder.xml<br></sortOrderFile> or <sortOrderFile>https://raw.githubusercontent.com/Ekryd/sortpom/master/sorter/src/main/resources/custom_1.xml<br></sortOrderFile>
<sortDependencies> none Comma-separated ordered list how dependencies should be sorted. Sort mechanism Warning -Dsort.sortDependencies=scope,artifactId

<sortDependencies>scope,artifactId</sortDependencies>
<sortPlugins> none Comma-separated ordered list how plugins should be sorted. Sort mechanism Warning -Dsort.sortPlugins=groupId,artifactId

<sortPlugins>groupId,artifactId</sortPlugins>
<sortProperties> false Should the Maven pom properties be sorted alphabetically. Affects both project/properties and project/profiles/profile/properties -Dsort.sortProperties=true

<sortProperties>true</sortProperties>
<sortModules> false Should the Maven pom sub modules be sorted alphabetically. Warning -Dsort.sortModules=true

<sortModules>true</sortModules>
<createBackupFile> true Should a backup copy be created before sorting the pom -Dsort.createBackupFile=false

<createBackupFile>false</createBackupFile>
<backupFileExtension> .bak Name of the file extension for the backup file -Dsort.backupFileExtension=".old"

<backupFileExtension>.old</backupFileExtension>
<lineSeparator> line.separator Line separator for sorted pom. Can be either \n, \r or \r\n -Dsort.lineSeparator="\n"

<lineSeparator>\n</lineSeparator>
<ignoreLineSeparators> true Ignore or not line separators when comparing original POM with sorted one. If false and both POMs are the same, except their line separators, POM will be rewritten with the specified <lineSeparator> line separators. Otherwise, it will be left as it -Dsort.ignoreLineSeparators="false"

<ignoreLineSeparators>false</ignoreLineSeparators>
<expandEmptyElements> true Should empty xml elements be expanded.<configuration></configuration>or<configuration/> -Dsort.expandEmptyElements=false

<expandEmptyElements>false</expandEmptyElements>
<keepBlankLines> false Should blank lines in the pom-file be perserved. A maximum of one line is preserved between each tag. -Dsort.keepBlankLines=true

<keepBlankLines>true</keepBlankLines>
<nrOfIndentSpace> 2 Number of space characters to use as indentation. A value of -1 indicates that a tab character should be used instead -Dsort.nrOfIndentSpace=4

<nrOfIndentSpace>4</nrOfIndentSpace>
<indentBlankLines> false Should blank lines (if preserved) have indentation. -Dsort.indentBlankLines=true

<indentBlankLines>true</indentBlankLines>
<skip> false Set this to 'true' to bypass sorting of the pom.xml completely. -Dsort.skip=true

<skip>true</skip>

For the Sort goal only

Parameter Default value Description Example
<ignoreLineSeparators> true Should newline type be ignored when determining if the pom-file is sorted or not -Dsort.ignoreLineSeparators=false

<ignoreLineSeparators>false</ignoreLineSeparators>

For the Verify goal only

Parameter Default value Description Example
<verifyFail> Sort Can be either Sort, Stop or Warn -Dsort.verifyFail="Stop"

<verifyFail>Stop</verifyFail>
<violationFilename> none Enter a filename, e.g. target/sortpom_reports/violation.xml to save a report if the verification failed. It is the responsibility of the build job to remove any previous violation file as the plugin will not clear it (just overwrite it if a new is generated). -Dsort.violationFilename="target/sortpom_reports/violation.xml"

<violationFilename>target/sortpom_reports/violation.xml</violationFilename>

Ignoring Sections

The pom.xml can be enhanced so that sections of the pom can be excluded from the sorting process. See IgnoringSections

Comments

Comments in the pom.xml are also sorted. They are bound to follow the following xml element. Comments