### Build SortPom Plugin (without signing)
Source: https://github.com/ekryd/sortpom/blob/master/misc/welcome.txt
Use this command to compile and install the SortPom plugin locally without signing the JAR file.
```bash
mvn clean install
```
--------------------------------
### Example POM Dependency Structure
Source: https://github.com/ekryd/sortpom/wiki/SortDependencies
Illustrates a Maven POM structure with dependency management defining scopes and dependencies without explicit scopes. This can lead to sorting issues if not handled carefully.
```xml
junit
junit
4.10
test
org.hamcrest
hamcrest-all
1.1
test
junit
junit
```
--------------------------------
### SortPlugins Configuration Example
Source: https://github.com/ekryd/sortpom/wiki/SortPlugins
Configure the sortPlugins parameter with a comma-separated list of elements to define the sorting order for plugins. Elements like groupId and artifactId can be used.
```properties
sortPlugins=groupId,artifactId
```
--------------------------------
### Properly Bound Comment in POM
Source: https://github.com/ekryd/sortpom/wiki/Comments
This example shows a comment correctly bound to the `` element. Comments should precede the element they are intended for.
```xml
1.6
Special value
UTF-8
```
--------------------------------
### Misplaced Comment in POM
Source: https://github.com/ekryd/sortpom/wiki/Comments
This example illustrates a comment placed after an XML element, which SortPom binds to the subsequent element (``) instead of the intended one (``). Avoid placing comments after XML elements.
```xml
2.3
org.apache.maven.plugins
maven-jxr-plugin
```
--------------------------------
### Release SortPom Plugin - Prepare
Source: https://github.com/ekryd/sortpom/blob/master/misc/welcome.txt
Commands to prepare for releasing a new version of the SortPom plugin.
```bash
mvn release:clean
mvn release:prepare
```
--------------------------------
### Test GPG Signing
Source: https://github.com/ekryd/sortpom/blob/master/misc/welcome.txt
This command tests the GPG signing process before deploying the plugin.
```bash
echo "test" | gpg --clearsign
```
--------------------------------
### Set Backup File Extension
Source: https://github.com/ekryd/sortpom/wiki/Parameters
Configure the file extension for backup files created before sorting. Use the `-D` flag for command-line or XML tags for configuration.
```bash
-Dsort.backupFileExtension=".old"
```
```xml
.old
```
--------------------------------
### Release SortPom Plugin - Perform
Source: https://github.com/ekryd/sortpom/blob/master/misc/welcome.txt
Command to perform the release of the SortPom plugin after preparation.
```bash
mvn release:perform
```
--------------------------------
### Display Plugin and Dependency Updates
Source: https://github.com/ekryd/sortpom/blob/master/misc/welcome.txt
Use these commands to check for available updates for plugins and dependencies in the Maven project.
```bash
mvn versions:display-plugin-updates
mvn versions:display-dependency-updates
```
--------------------------------
### SortPom Build and Tooling Commands
Source: https://github.com/ekryd/sortpom/blob/master/AGENTS.md
These Maven commands are used for building, testing, and formatting the SortPom project. Always run `mvn fmt:format` before committing to ensure code adheres to the project's style.
```bash
mvn verify # Full build: compile, test, integration tests
```
```bash
mvn test # Unit tests only
```
```bash
mvn fmt:format # Auto-format all Java source (Spotify fmt-maven-plugin)
```
```bash
mvn fmt:check # Verify formatting without modifying files
```
--------------------------------
### Run SortPom Sort Goal with Custom Order
Source: https://github.com/ekryd/sortpom/blob/master/README.md
Execute the 'sort' goal of the SortPom plugin directly from the command line with a predefined custom sort order. This is useful for simple tests.
```bash
mvn com.github.ekryd.sortpom:sortpom-maven-plugin:4.0.0:sort -Dsort.predefinedSortOrder=custom_1
```
--------------------------------
### Control Expansion of Empty Elements
Source: https://github.com/ekryd/sortpom/wiki/Parameters
Configure whether empty XML elements should be expanded (e.g., ``) or collapsed (``). Use the `-D` flag for command-line or XML tags for configuration.
```bash
-Dsort.expandEmptyElements=false
```
```xml
false
```
--------------------------------
### Simple Maven Plugin Configuration
Source: https://github.com/ekryd/sortpom/wiki/Recommended-configuration
Add this to your pom.xml to sort your pom file automatically during compilation.
```xml
com.github.ekryd.sortpom
sortpom-maven-plugin
3.3.0
sort
```
--------------------------------
### Running SortPom with Custom Sort Order File
Source: https://github.com/ekryd/sortpom/wiki/SortPlugins
Execute the SortPom Maven plugin with a custom sort order file specified using the -Dsort.sortOrderFile parameter.
```bash
mvn sortpom:sort -Dsort.sortOrderFile=
```
--------------------------------
### Sort Plugins Parameter
Source: https://github.com/ekryd/sortpom/wiki/Parameters
Use this parameter to define a comma-separated list of how plugins should be sorted. This enables custom sorting mechanisms for plugins within the pom.xml.
```bash
-Dsort.sortPlugins=groupId,artifactId
```
```xml
groupId,artifactId
```
--------------------------------
### Sort Order File Parameter
Source: https://github.com/ekryd/sortpom/wiki/Parameters
Specify a custom sort order file to be read from the executing path, classpath, or as a URL. This allows for fine-grained control over the sorting logic.
```bash
-Dsort.sortOrderFile="src/main/resources/customSortOrder.xml"
```
```xml
src/main/resources/customSortOrder.xml
```
```xml
https://raw.githubusercontent.com/Ekryd/sortpom/master/sorter/src/main/resources/custom_1.xml
```
--------------------------------
### SortPom Maven Plugin Configuration for Build Servers
Source: https://github.com/ekryd/sortpom/wiki/SortPom-and-Build-Servers
This snippet shows how to configure the SortPom Maven plugin to use the 'verify' goal. It's recommended for build servers to prevent accidental modifications to the POM file. The configuration includes settings for encoding, sorting order, dependency sorting, and property sorting.
```xml
...
UTF-8
...
...
com.github.ekryd.sortpom
sortpom-maven-plugin
2.12.0
${project.build.sourceEncoding}
true
custom_1
scope
true
stop
verify
validate
...
```
--------------------------------
### Run Single Integration Test
Source: https://github.com/ekryd/sortpom/blob/master/maven-plugin/src/it/README_IT_TESTS.md
Execute a single integration test by specifying the test name with the 'invoker.test' property. This command also skips other tests and Javadoc generation.
```bash
mvn verify -DskipTests=true -Dmaven.javadoc.skip=true -Dinvoker.test=mojo-description
```
--------------------------------
### Integration Tests with SortPomImpl
Source: https://github.com/ekryd/sortpom/blob/master/AGENTS.md
Perform full integration testing through SortPomImpl. This utility allows configuring dependency sorting and testing input/output files.
```java
SortPomImplUtil.create()
.sortDependencies("scope,groupId,artifactId")
.testFiles("src/test/resources/MyFeature_input.xml",
"src/test/resources/MyFeature_expected.xml");
```
--------------------------------
### Configure verifyFailOn for Strict Verification
Source: https://github.com/ekryd/sortpom/wiki/VerifyFailOn
This snippet shows how to configure the sortpom-maven-plugin to use the 'strict' verifyFailOn setting. This enforces checks for sorting, indentation, and line separators, failing the build if any issues are found.
```xml
com.github.ekryd.sortpom
sortpom-maven-plugin
2.13.1
${project.build.sourceEncoding}
true
custom_1
false
stop
strict
verify
validate
```
--------------------------------
### Sort Dependencies by GroupId and ArtifactId
Source: https://github.com/ekryd/sortpom/wiki/SortDependencies
Configure the plugin to sort dependencies first by groupId and then by artifactId. The separator can be a semicolon, colon, or comma. Avoid spaces in the list.
```xml
sortDependencies=groupId,artifactId
```
--------------------------------
### Maven Settings for Plugin Group
Source: https://github.com/ekryd/sortpom/wiki/Recommended-configuration
Add this plugin group to your ~/.m2/settings.xml to simplify command-line execution of SortPom goals.
```xml
com.github.ekryd.sortpom
```
--------------------------------
### XML Sorting and Round-trip Tests
Source: https://github.com/ekryd/sortpom/blob/master/AGENTS.md
Use this utility for testing XML sorting and round-trip functionality. It allows specifying a predefined sort order and testing input against expected output files.
```java
XmlProcessorTestUtil.create()
.predefinedSortOrder("recommended_2008_06")
.testInputAndExpected("src/test/resources/MyFeature_input.xml",
"src/test/resources/MyFeature_expected.xml");
```
--------------------------------
### Manage Git Tags for Rollback
Source: https://github.com/ekryd/sortpom/blob/master/rollback.txt
Commands to list, delete, and push tag deletions for Git.
```bash
git tag
```
```bash
git tag -d
```
```bash
git push origin :refs/tags/
```
--------------------------------
### Configure Sortpom for Other XML Files
Source: https://github.com/ekryd/sortpom/wiki/SortingOtherXml
Use these parameters within your Sortpom configuration to specify the XML file to be sorted and a schema file that defines the desired sort order.
```xml
myFile.xml
sortSchemaOrder.xml
```
--------------------------------
### Set File Encoding
Source: https://github.com/ekryd/sortpom/wiki/Parameters
Specify the character encoding for processing pom files. Use the `-D` flag for command-line or XML tags for configuration.
```bash
-Dsort.encoding="ASCII"
```
```xml
ASCII
```
--------------------------------
### Sort pom.xml using Sortpom Maven Plugin
Source: https://github.com/ekryd/sortpom/wiki/Home
This command sorts the current pom.xml file using the Sortpom Maven Plugin. It also preserves blank lines and uses a custom predefined sort order.
```bash
mvn com.github.ekryd.sortpom:sortpom-maven-plugin:sort -Dsort.keepBlankLines -Dsort.predefinedSortOrder=custom_1
```
--------------------------------
### Placing a Critical Dependency at the Top
Source: https://github.com/ekryd/sortpom/wiki/IgnoringSections
Wrap a critical dependency within `` and `` directives to ensure it appears at the top of the dependencies list when `sortDependencies` is configured. This is a workaround for class loading issues and may change in future versions.
```xml
org.jmockit
jmockit
test
org.hamcrest
hamcrest
test
org.junit.jupiter
junit-jupiter-engine
test
org.mockito
mockito-junit-jupiter
test
```
--------------------------------
### Ignoring a Dependency Version
Source: https://github.com/ekryd/sortpom/wiki/IgnoringSections
Use `` and `` to prevent a specific dependency's version from being sorted. This ensures the comment stays on the same line as the version.
```xml
joda-time
joda-time
2.0
```
--------------------------------
### Advanced Maven Plugin Configuration
Source: https://github.com/ekryd/sortpom/wiki/Recommended-configuration
Configure SortPom with specific parameters for custom sorting, no backup files, and line endings. Ensure changes are committed before use, as this does not create backups.
```xml
com.github.ekryd.sortpom
sortpom-maven-plugin
3.3.0
false
custom_1
\n
true
scope,groupId,artifactId
sort
```
--------------------------------
### Disable Backup File Creation
Source: https://github.com/ekryd/sortpom/wiki/Parameters
Control whether a backup copy of the pom file is created before sorting. Use the `-D` flag for command-line or XML tags for configuration.
```bash
-Dsort.createBackupFile=false
```
```xml
false
```
--------------------------------
### Dependency Sorting with Scope
Source: https://github.com/ekryd/sortpom/wiki/SortDependencies
When 'scope' is included in the sort order, it follows a specific hierarchy: IMPORT, COMPILE (or empty), PROVIDED, SYSTEM, RUNTIME, and TEST. Since version 3.0.0, IMPORT is sorted first.
```xml
sortDependencies=scope
```
--------------------------------
### Omit Sorting Dependencies
Source: https://github.com/ekryd/sortpom/wiki/SortDependencies
Use the value 'none' to disable sorting for dependencies. This is useful when combined with other sorting rules for dependency management.
```xml
sortDependencies=none
```
--------------------------------
### Sort Modules Parameter
Source: https://github.com/ekryd/sortpom/wiki/Parameters
Configure this parameter to sort the Maven pom sub modules alphabetically. This setting is applicable through both command-line arguments and pom.xml configuration.
```bash
-Dsort.sortModules=true
```
```xml
true
```
--------------------------------
### Space Before Close Empty Element Parameter
Source: https://github.com/ekryd/sortpom/wiki/Parameters
Control whether non-expanded empty XML elements should contain a space before the closing tag. This affects the formatting of empty elements like `` vs ``.
```bash
-Dsort.spaceBeforeCloseEmptyElement=true
```
```xml
true
```
--------------------------------
### Custom Sort Order File for Report Plugins
Source: https://github.com/ekryd/sortpom/wiki/SortPlugins
Define a custom sort order file to manage the sorting of report plugins, as they are not part of the standard Maven POM specification. This snippet shows the structure required within the custom file.
```xml
```
--------------------------------
### Rollback Maven Release
Source: https://github.com/ekryd/sortpom/blob/master/rollback.txt
Use these commands to rollback a Maven release. This cleans up release artifacts and resets the Git repository.
```bash
mvn release:rollback
mvn release:clean
```
```bash
git reset HEAD^ --hard
git push origin -f
```
--------------------------------
### Sort Executions Parameter
Source: https://github.com/ekryd/sortpom/wiki/Parameters
Use this parameter to sort the Maven pom execution sections by phase and then alphabetically. It can be set via the command line or within the pom.xml.
```bash
-Dsort.sortExecutions=true
```
```xml
true
```
--------------------------------
### Omit Sorting Dependency Management
Source: https://github.com/ekryd/sortpom/wiki/SortDependencies
Set the dependency management sorting to 'none' to prevent it from being sorted. This is recommended when dependency management might interfere with normal dependency sorting.
```xml
none
```
--------------------------------
### Sort Properties Parameter
Source: https://github.com/ekryd/sortpom/wiki/Parameters
Set this parameter to true to sort the Maven pom properties alphabetically. This affects both project properties and properties within profiles.
```bash
-Dsort.sortProperties=true
```
```xml
true
```
--------------------------------
### Configure SortPom Plugin in Maven Build
Source: https://github.com/ekryd/sortpom/blob/master/README.md
Integrate the SortPom plugin into your Maven build to automatically sort pom.xml during compilation. Ensure you replace '4.0.0' with the latest version.
```xml
com.github.ekryd.sortpom
sortpom-maven-plugin
4.0.0
sort
...
```
--------------------------------
### Version 2.0.0 and Earlier Boolean Sort Argument
Source: https://github.com/ekryd/sortpom/wiki/SortDependencies
In versions 2.0.0 and earlier, a boolean argument was used for sorting: 'true' meant 'groupId,artifactId', and 'false' meant an empty list. This is no longer supported since version 3.0.0.
```xml
true means 'groupId,artifactId'
```
```xml
false means empty list.
```
--------------------------------
### Ensure Newline at End of File
Source: https://github.com/ekryd/sortpom/wiki/Parameters
Determine if the sorted pom file should end with a newline character. Use the `-D` flag for command-line or XML tags for configuration.
```bash
-Dsort.endWithNewline=false
```
```xml
false
```
--------------------------------
### SortPom Violation File Structure
Source: https://github.com/ekryd/sortpom/wiki/ViolationFile
This XML structure represents a violation detected by SortPom. It indicates the file path and the specific XML element ordering issue.
```xml
The xml element <modelVersion> should be placed before <name>
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.