Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a parameter to control the sort order of dependencies in dependency management. #214

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions maven-plugin/src/it/mojo-description/expected.log
Original file line number Diff line number Diff line change
@@ -116,6 +116,15 @@ sortpom:sort
Comma-separated ordered list how exclusions, for dependencies, should be
sorted. Example: groupId,artifactId The list can be separated by ',;:'

sortDependencyManagement
User property: sort.sortDependencyManagement
Comma-separated ordered list how dependencies in dependency management
should be sorted. Example: scope,groupId,artifactId. If scope is
specified in the list then the scope ranking is COMPILE, PROVIDED,
SYSTEM, RUNTIME, IMPORT and TEST. The list can be separated by ',;:'. It
would take precedence if present and would fallback to sortDependencies if
not present.

sortExecutions (Default: false)
User property: sort.sortExecutions
Should the Maven pom execution sections be sorted by phase and then
@@ -228,6 +237,15 @@ sortpom:verify
Comma-separated ordered list how exclusions, for dependencies, should be
sorted. Example: groupId,artifactId The list can be separated by ',;:'

sortDependencyManagement
User property: sort.sortDependencyManagement
Comma-separated ordered list how dependencies in dependency management
should be sorted. Example: scope,groupId,artifactId. If scope is
specified in the list then the scope ranking is COMPILE, PROVIDED,
SYSTEM, RUNTIME, IMPORT and TEST. The list can be separated by ',;:'. It
would take precedence if present and would fallback sortDependencies if
not present.

sortExecutions (Default: false)
User property: sort.sortExecutions
Should the Maven pom execution sections be sorted by phase and then
10 changes: 10 additions & 0 deletions maven-plugin/src/main/java/sortpom/AbstractParentMojo.java
Original file line number Diff line number Diff line change
@@ -94,6 +94,16 @@ abstract class AbstractParentMojo extends AbstractMojo {
@Parameter(property = "sort.sortDependencyExclusions")
String sortDependencyExclusions;

/**
* Comma-separated ordered list how dependencies in dependency management should be sorted.
* Example: scope,groupId,artifactId. If scope is specified in the list then the scope ranking is
* COMPILE, PROVIDED, SYSTEM, RUNTIME, IMPORT and TEST. The list can be separated by ",;:". It
* would take precedence if present and would fallback to {@link #sortDependencies} if not
* present.
*/
@Parameter(property = "sort.sortDependencyManagement")
String sortDependencyManagement;

/**
* Comma-separated ordered list how plugins should be sorted. Example: groupId,artifactId The list
* can be separated by ",;:"
1 change: 1 addition & 0 deletions maven-plugin/src/main/java/sortpom/SortMojo.java
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ public void setup() throws MojoFailureException {
.setSortEntities(
sortDependencies,
sortDependencyExclusions,
sortDependencyManagement,
sortPlugins,
sortProperties,
sortModules,
1 change: 1 addition & 0 deletions maven-plugin/src/main/java/sortpom/VerifyMojo.java
Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@ public void setup() throws MojoFailureException {
.setSortEntities(
sortDependencies,
sortDependencyExclusions,
sortDependencyManagement,
sortPlugins,
sortProperties,
sortModules,
7 changes: 7 additions & 0 deletions sorter/src/main/java/sortpom/parameter/PluginParameters.java
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ public class PluginParameters {
public final String customSortOrderFile;
public final DependencySortOrder sortDependencies;
public final DependencySortOrder sortDependencyExclusions;
public final DependencySortOrder sortDependencyManagement;
public final DependencySortOrder sortPlugins;
public final boolean sortProperties;
public final boolean sortModules;
@@ -46,6 +47,7 @@ private PluginParameters(
String customSortOrderFile,
DependencySortOrder sortDependencies,
DependencySortOrder sortDependencyExclusions,
DependencySortOrder sortDependencyManagement,
DependencySortOrder sortPlugins,
boolean sortProperties,
boolean sortModules,
@@ -67,6 +69,7 @@ private PluginParameters(
this.customSortOrderFile = customSortOrderFile;
this.sortDependencies = sortDependencies;
this.sortDependencyExclusions = sortDependencyExclusions;
this.sortDependencyManagement = sortDependencyManagement;
this.sortPlugins = sortPlugins;
this.sortProperties = sortProperties;
this.sortModules = sortModules;
@@ -102,6 +105,7 @@ public static class Builder {
private String customSortOrderFile;
private DependencySortOrder sortDependencies;
private DependencySortOrder sortDependencyExclusions;
private DependencySortOrder sortDependencyManagement;
private DependencySortOrder sortPlugins;
private boolean sortProperties;
private boolean sortModules;
@@ -173,12 +177,14 @@ public Builder setSortOrder(
public Builder setSortEntities(
final String sortDependencies,
final String sortDependencyExclusions,
final String sortDependencyManagement,
final String sortPlugins,
final boolean sortProperties,
final boolean sortModules,
boolean sortExecutions) {
this.sortDependencies = new DependencySortOrder(sortDependencies);
this.sortDependencyExclusions = new DependencySortOrder(sortDependencyExclusions);
this.sortDependencyManagement = new DependencySortOrder(sortDependencyManagement);
this.sortPlugins = new DependencySortOrder(sortPlugins);
this.sortProperties = sortProperties;
this.sortModules = sortModules;
@@ -218,6 +224,7 @@ public PluginParameters build() {
customSortOrderFile,
sortDependencies,
sortDependencyExclusions,
sortDependencyManagement,
sortPlugins,
sortProperties,
sortModules,
14 changes: 12 additions & 2 deletions sorter/src/main/java/sortpom/wrapper/ElementWrapperCreator.java
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
public class ElementWrapperCreator {
private DependencySortOrder sortDependencies;
private DependencySortOrder sortDependencyExclusions;
private DependencySortOrder sortDependencyManagement;
private DependencySortOrder sortPlugins;
private boolean sortProperties;
private boolean sortModules;
@@ -27,6 +28,7 @@ public class ElementWrapperCreator {
public void setup(PluginParameters pluginParameters) {
this.sortDependencies = pluginParameters.sortDependencies;
this.sortDependencyExclusions = pluginParameters.sortDependencyExclusions;
this.sortDependencyManagement = pluginParameters.sortDependencyManagement;
this.sortPlugins = pluginParameters.sortPlugins;
this.sortProperties = pluginParameters.sortProperties;
this.sortModules = pluginParameters.sortModules;
@@ -39,7 +41,11 @@ Wrapper<Element> createWrapper(Element element) {
if (isDependencyElement(element)) {
DependencySortedWrapper dependencySortedWrapper =
new DependencySortedWrapper(element, elementNameSortOrderMap.getSortOrder(element));
dependencySortedWrapper.setSortOrder(sortDependencies);
if (!sortDependencyManagement.isNoSorting() && isDependencyElementInManagement(element)) {
dependencySortedWrapper.setSortOrder(sortDependencyManagement);
} else {
dependencySortedWrapper.setSortOrder(sortDependencies);
}
return dependencySortedWrapper;
}
if (isExclusionElement(element)) {
@@ -68,8 +74,12 @@ Wrapper<Element> createWrapper(Element element) {
return new UnsortedWrapper<>(element);
}

private boolean isDependencyElementInManagement(final Element element) {
return isElementParentName(element.getParent(), "dependencyManagement");
}

private boolean isDependencyElement(final Element element) {
if (sortDependencies.isNoSorting()) {
if (sortDependencies.isNoSorting() && sortDependencyManagement.isNoSorting()) {
return false;
}
return isElementName(element, "dependency") && isElementParentName(element, "dependencies");
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package sortpom.sort;

import org.junit.jupiter.api.*;
import sortpom.util.*;

class SortDepManagementExclusionsTest {

@Test
final void sortGroupIdForExclusionsShouldWork() throws Exception {
SortPomImplUtil.create()
.customSortOrderFile("custom_1.xml")
.sortDependencyExclusions("groupId")
.lineSeparator("\n")
.nrOfIndentSpace(2)
.testFiles(
"/SortDepManagementExclusions_input.xml",
"/SortDepManagementExclusions_group_expected.xml");
}

@Test
final void sortArtifactIdForExclusionsShouldWork() throws Exception {
SortPomImplUtil.create()
.customSortOrderFile("custom_1.xml")
.sortDependencyExclusions("artifactId")
.lineSeparator("\n")
.nrOfIndentSpace(2)
.testFiles(
"/SortDepManagementExclusions_input.xml",
"/SortDepManagementExclusions_artifact_expected.xml");
}

@Test
final void sortGroupIdAndArtifactIdForExclusionsShouldWork() throws Exception {
SortPomImplUtil.create()
.customSortOrderFile("custom_1.xml")
.sortDependencyExclusions("groupId,artifactId")
.lineSeparator("\n")
.nrOfIndentSpace(2)
.testFiles(
"/SortDepManagementExclusions_input.xml",
"/SortDepManagementExclusions_group_artifact_expected.xml");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package sortpom.sort;

import org.junit.jupiter.api.*;
import sortpom.util.*;

public class SortDependencyManagementTests {

@Test
final void scopeInSortDependencyManagementShouldSortByScope() throws Exception {
SortPomImplUtil.create()
.customSortOrderFile("custom_1.xml")
.sortDependencyManagement("scope,GROUPID,artifactId")
.lineSeparator("\r\n")
.testFiles(
"/SortDepManagement_input_simpleWithScope.xml",
"/SortDepManagement_expected_simpleWithScope2.xml");
}

@Test
final void defaultDependencyManagementShouldWork() throws Exception {
SortPomImplUtil.create()
.customSortOrderFile("custom_1.xml")
.sortDependencies("scope,GROUPID,artifactId")
.lineSeparator("\r\n")
.testFiles(
"/SortDepManagement_input_simpleWithScope.xml",
"/SortDepManagement_expected_simpleWithScope2.xml");
}

@Test
final void differentOrderBetweenDepAndDepManagement() throws Exception {
SortPomImplUtil.create()
.customSortOrderFile("custom_1.xml")
.sortDependencies("scope,GROUPID,artifactId")
.sortDependencyManagement("GROUPID,artifactId")
.lineSeparator("\r\n")
.testFiles(
"/SortDepManagement_input_withDependencies.xml",
"/SortDepManagement_expected_withDependencies.xml");
}
}
7 changes: 7 additions & 0 deletions sorter/src/test/java/sortpom/util/SortPomImplUtil.java
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ public class SortPomImplUtil {
private String customSortOrderFile;
private String sortDependencies = "";
private String sortDependencyExclusions = "";
private String sortDependencyManagement = "";
private String sortPlugins = "";
private boolean sortProperties = false;
private boolean sortModules = false;
@@ -183,6 +184,11 @@ public SortPomImplUtil sortDependencyExclusions(String sortOrder) {
return this;
}

public SortPomImplUtil sortDependencyManagement(String sortOrder) {
sortDependencyManagement = sortOrder;
return this;
}

public SortPomImplUtil sortPlugins(String sortOrder) {
sortPlugins = sortOrder;
return this;
@@ -278,6 +284,7 @@ private PluginParameters getPluginParameters() {
.setSortEntities(
sortDependencies,
sortDependencyExclusions,
sortDependencyManagement,
sortPlugins,
sortProperties,
sortModules,
15 changes: 14 additions & 1 deletion sorter/src/test/java/sortpom/util/XmlProcessorTestUtil.java
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ public class XmlProcessorTestUtil {
private boolean spaceBeforeCloseEmptyElement = true;
private boolean sortModules = false;
private String sortDependencies;
private String sortDependencyManagement;
private String sortPlugins;
private boolean sortProperties = false;

@@ -83,7 +84,14 @@ private void setup(String inputFileName) throws Exception {
lineSeparator, expandEmptyElements, spaceBeforeCloseEmptyElement, keepBlankLines)
.setIndent(2, indentBlankLines, false)
.setSortOrder(predefinedSortOrder + ".xml", null)
.setSortEntities(sortDependencies, "", sortPlugins, sortProperties, sortModules, false)
.setSortEntities(
sortDependencies,
"",
sortDependencyManagement,
sortPlugins,
sortProperties,
sortModules,
false)
.build();
final String xml = IOUtils.toString(new FileInputStream(inputFileName), StandardCharsets.UTF_8);

@@ -159,6 +167,11 @@ public XmlProcessorTestUtil sortDependencies(String sortDependencies) {
return this;
}

public XmlProcessorTestUtil sortDependencyManagement(String sortDependencyManagement) {
this.sortDependencyManagement = sortDependencyManagement;
return this;
}

public XmlProcessorTestUtil sortPlugins(String sortPlugins) {
this.sortPlugins = sortPlugins;
return this;
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ private String getToStringOnCustomSortOrderFile()
.setSortEntities(
"scope,groupId,artifactId",
"groupId,artifactId",
"scope,groupId,artifactId",
"groupId,artifactId",
true,
true,
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ private String getToStringOnRootElementWrapper() throws IOException, DocumentExc
.setSortEntities(
"scope,groupId,artifactId",
"groupId,artifactId",
"scope,groupId,artifactId",
"groupId,artifactId",
true,
true,
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.ekryd.sortpom.its</groupId>
<artifactId>sort-dependencies</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>SortPom Plugin :: ITs :: Sort dependencies</name>
<description>Test sorting dependencies</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-sorter</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>eclipse.sisu.plexus</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-sorter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<exclusions>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>eclipse.sisu.plexus</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-maven-plugin</artifactId>
<version>2.14.0</version>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>eclipse.sisu.plexus</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.ekryd.sortpom.its</groupId>
<artifactId>sort-dependencies</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>SortPom Plugin :: ITs :: Sort dependencies</name>
<description>Test sorting dependencies</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-sorter</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>eclipse.sisu.plexus</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-sorter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>eclipse.sisu.plexus</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-maven-plugin</artifactId>
<version>2.14.0</version>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>eclipse.sisu.plexus</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.ekryd.sortpom.its</groupId>
<artifactId>sort-dependencies</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>SortPom Plugin :: ITs :: Sort dependencies</name>
<description>Test sorting dependencies</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-sorter</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>eclipse.sisu.plexus</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-sorter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>eclipse.sisu.plexus</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-maven-plugin</artifactId>
<version>2.14.0</version>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>eclipse.sisu.plexus</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
139 changes: 139 additions & 0 deletions sorter/src/test/resources/SortDepManagementExclusions_input.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.ekryd.sortpom.its</groupId>
<artifactId>sort-dependencies</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>SortPom Plugin :: ITs :: Sort dependencies</name>
<description>Test sorting dependencies</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-sorter</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>eclipse.sisu.plexus</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-sorter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<exclusions>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>eclipse.sisu.plexus</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-maven-plugin</artifactId>
<version>2.14.0</version>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.sisu</groupId>
<artifactId>eclipse.sisu.plexus</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.3.8.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<artifactId>a</artifactId>
</dependency>
<dependency>
<artifactId>b</artifactId>
<scope></scope>
</dependency>
<dependency>
<artifactId>c</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<scope>provided</scope>
</dependency>
<dependency>
<scope>system</scope>
</dependency>
<dependency>
<scope>runTIME</scope>
</dependency>
<dependency>
<scope>test</scope>
</dependency>
<!-- This is cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cheesymock</groupId>
<artifactId>cheesymock</artifactId>
<version>1.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<!-- Junit! -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<scope>gurka</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<dependencyManagement>
<dependencies>
<dependency>
<scope>gurka</scope>
</dependency>
<dependency>
<artifactId>a</artifactId>
</dependency>
<dependency>
<artifactId>b</artifactId>
<scope></scope>
</dependency>
<dependency>
<artifactId>c</artifactId>
<scope>compile</scope>
</dependency>
<!-- This is cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>cheesymock</groupId>
<artifactId>cheesymock</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
<!-- Junit! -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.3.8.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<scope>import</scope>
</dependency>
<dependency>
<artifactId>a</artifactId>
</dependency>
<dependency>
<artifactId>b</artifactId>
<scope></scope>
</dependency>
<dependency>
<artifactId>c</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
</dependency>
<dependency>
<scope>provided</scope>
</dependency>
<dependency>
<scope>system</scope>
</dependency>
<dependency>
<scope>runTIME</scope>
</dependency>
<dependency>
<scope>test</scope>
</dependency>
<!-- This is cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cheesymock</groupId>
<artifactId>cheesymock</artifactId>
<scope>test</scope>
</dependency>
<!-- Junit! -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<scope>gurka</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<dependencyManagement>
<dependencies>
<dependency>
<scope>gurka</scope>
</dependency>
<dependency>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.3.8.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<scope>runTIME</scope>
</dependency>
<dependency>
<scope>system</scope>
</dependency>
<dependency>
<scope>provided</scope>
</dependency>
<dependency>
<artifactId>c</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<artifactId>b</artifactId>
<scope/>
</dependency>
<dependency>
<artifactId>a</artifactId>
</dependency>
<!-- Junit! -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
<!-- This is cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>cheesymock</groupId>
<artifactId>cheesymock</artifactId>
<version>1.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
107 changes: 107 additions & 0 deletions sorter/src/test/resources/SortDepManagement_input_withDependencies.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<dependencies>
<dependency>
<scope>gurka</scope>
</dependency>
<dependency>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<scope>import</scope>
</dependency>
<dependency>
<scope>runTIME</scope>
</dependency>
<dependency>
<scope>system</scope>
</dependency>
<dependency>
<scope>provided</scope>
</dependency>
<dependency>
<artifactId>c</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<artifactId>b</artifactId>
<scope/>
</dependency>
<dependency>
<artifactId>a</artifactId>
</dependency>
<!-- Junit! -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- This is cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
</dependency>
<dependency>
<groupId>cheesymock</groupId>
<artifactId>cheesymock</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.3.8.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<artifactId>c</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<artifactId>b</artifactId>
<scope/>
</dependency>
<dependency>
<artifactId>a</artifactId>
</dependency>
<!-- Junit! -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
</dependency>
<!-- This is cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>cheesymock</groupId>
<artifactId>cheesymock</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
<dependency>
<scope>gurka</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>