Skip to content
Björn Ekryd edited this page May 19, 2024 · 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
<backupFileExtension> .bak Name of the file extension for the backup file. -Dsort.backupFileExtension=".old"

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

<createBackupFile>false</createBackupFile>
<encoding> UTF-8 Encoding for the files. -Dsort.encoding="ASCII"

<encoding>ASCII</encoding>
<endWithNewline> true Whether to ensure that sorted pom ends with a newline. -Dsort.endWithNewline=false

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

<expandEmptyElements>false</expandEmptyElements>
<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>
<indentAttribute> none Should the xml attributes be indented. Can be either 'schemaLocation' or 'all'. 'schemaLocation' only indents the schemaLocation attribute in the project element. -Dsort.indentAttribute=all

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

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

<keepBlankLines>false</keepBlankLines>
<keepTimestamp> false Whether to keep the file timestamps of old POM file when creating new POM file. -Dsort.keepTimestamp=true

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

<lineSeparator>\n</lineSeparator>
<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>
<pomFile> pom.xml Location of the pomfile. Sidenote: Sorting other XML. -Dsort.pomFile="myPom.xml"

<pomFile>myPom.xml</pomFile>
<predefinedSortOrder> recommended_2008_06 Select from a number of predefined sort profiles if the default sort order does not match. -Dsort.predefinedSortOrder="custom_1"

<predefinedSortOrder>custom_1</predefinedSortOrder>
<quiet> false Set this to 'true' to disable plugin info output. -Dsort.quiet=true

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

<skip>true</skip>
<sortDependencies> none Comma-separated ordered list how dependencies should be sorted. Sort mechanism. Warning! -Dsort.sortDependencies=scope,artifactId

<sortDependencies>scope,artifactId</sortDependencies>
<sortDependencyExclusions> none Comma-separated ordered list how exclusions, for dependencies, should be sorted. Sort mechanism. -Dsort.sortDependencyExclusions=groupId,artifactId

<sortDependencyExclusions>groupId,artifactId</sortDependencyExclusions>
<sortDependencyManagement> <fallback> Comma-separated ordered list how dependencies in dependency management should be sorted. Sort mechanism. If not set, then fallback value is taken from sortDependencies. -Dsort.sortDependencyManagement=groupId,artifactId

<sortDependencyManagement>groupId,artifactId</sortDependencyManagement>
<sortExecutions> false Should the Maven pom execution sections be sorted by phase and then alphabetically. Warning! -Dsort.sortExecutions=true

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

<sortModules>true</sortModules>
<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>
<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>
<spaceBeforeCloseEmptyElement> false Should non-expanded empty xml elements contain space or not.
<configuration /> or <configuration/>.
-Dsort.spaceBeforeCloseEmptyElement=true

<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>

For the Sort goal only

None special.

For the Verify goal only

See SortPom used on build server

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

<verifyFail>Stop</verifyFail>
<verifyFailOn> XmlElements What kind of differences should trigger verify failure. Can be either XmlElements or Strict. Can be combined with ignoreLineSeparators -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