Skip to content
Björn Ekryd edited this page Jan 25, 2021 · 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>
<sortExecutions> false Should the Maven pom execution sections be sorted by phase and then alphabetically. Warning! -Dsort.sortExecutions=true

<sortExecutions>true</sortExecutions>
<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 line separators when comparing current POM with sorted one. If parameter is false then comparison will take the line separators into consideration. -Dsort.ignoreLineSeparators="false"

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

<expandEmptyElements>false</expandEmptyElements>
<spaceBeforeCloseEmptyElement> true Should non-expanded empty xml elements contain space or not.
<configuration /> or <configuration/>
-Dsort.spaceBeforeCloseEmptyElement=false

<spaceBeforeCloseEmptyElement>false</spaceBeforeCloseEmptyElement>
<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>
<keepTimestamp> false Whether to keep the file timestamps of old POM file when creating new POM file. -Dsort.keepTimestamp=true

<keepTimestamp>true</keepTimestamp>
<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

None special.

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>
<verifyFailOn> xmlElements Can be either XmlElements or Strict -Dsort.verifyFailOn="Strict"

<verifyFailOn>Strict</verifyFailOn>
<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

Clone this wiki locally