You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2020/11/20 10:09:26 UTC
[james-project] 03/16: JAMES-2124 Enforces strict dependency
ordering in pom files
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 66ed1439c69f06e4aca25d9b15edf22a77694f2f
Author: Jean Helou <jh...@codamens.fr>
AuthorDate: Wed Nov 18 09:31:49 2020 +0100
JAMES-2124 Enforces strict dependency ordering in pom files
This commit adds the sortpom-maven-plugin to the compile phase of the
build. By default the plugin is configured to fail if it detects an
incorrect dependency order in a pom.
Because sorting xml by hand is fairly painful, this commit also adds a
profile -PsortPom. When used this profile will change the plugin's
configuration to sort dependencies in place. This will **modify** the
pom files where ordering was incorrect.
---
mpt/app/pom.xml | 22 ++++++++++++++++-
pom.xml | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 94 insertions(+), 1 deletion(-)
diff --git a/mpt/app/pom.xml b/mpt/app/pom.xml
index 701e817..5054953 100644
--- a/mpt/app/pom.xml
+++ b/mpt/app/pom.xml
@@ -56,6 +56,10 @@ interfaces to the MPT library.</description>
<build>
<plugins>
+ <?SORTPOM IGNORE?>
+ <!-- We need to run a specific execution of sortpom after the shade plugin has
+ generated the dependency reduced file and execution order is defined by order of
+ declaration -->
<!-- Uber Jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -79,7 +83,23 @@ interfaces to the MPT library.</description>
</execution>
</executions>
</plugin>
-
+ <plugin>
+ <groupId>com.github.ekryd.sortpom</groupId>
+ <artifactId>sortpom-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>sort-reduced-pom</id>
+ <goals>
+ <goal>sort</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <pomFile>dependency-reduced-pom.xml</pomFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <?SORTPOM RESUME?>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
diff --git a/pom.xml b/pom.xml
index a054465..e9282ca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2741,6 +2741,48 @@
<version>1.0</version>
</plugin>
<plugin>
+ <groupId>com.github.ekryd.sortpom</groupId>
+ <artifactId>sortpom-maven-plugin</artifactId>
+ <version>2.12.0</version>
+ <configuration>
+ <createBackupFile>false</createBackupFile>
+ <expandEmptyElements>false</expandEmptyElements>
+ <keepBlankLines>true</keepBlankLines>
+ <nrOfIndentSpace>4</nrOfIndentSpace>
+ <sortDependencies>groupId,artifactId</sortDependencies>
+ <sortModules>true</sortModules>
+ <predefinedSortOrder>recommended_2008_06</predefinedSortOrder>
+ </configuration>
+ <executions>
+ <execution>
+ <id>strict-pom-ordering</id>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ <phase>validate</phase>
+ <configuration>
+ <verifyFail>Stop</verifyFail>
+ </configuration>
+ </execution>
+ <execution>
+ <!--
+ Use -PsortPom to switch from verify and
+ fail to sort in place. Note that sort in place
+ will rewrite the pom files and may introduce
+ non-semantic changes in the xml:
+ - attribute ordering,
+ - empty tag format,
+ - whitespace
+ -->
+ <id>fix-pom-ordering</id>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.7</version>
@@ -3203,6 +3245,10 @@
</pluginManagement>
<plugins>
<plugin>
+ <groupId>com.github.ekryd.sortpom</groupId>
+ <artifactId>sortpom-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
@@ -3391,6 +3437,33 @@
</build>
</profile>
<profile>
+ <id>sortPom</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.github.ekryd.sortpom</groupId>
+ <artifactId>sortpom-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>strict-pom-ordering</id>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ <phase>none</phase>
+ </execution>
+ <execution>
+ <id>fix-pom-ordering</id>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ <phase>validate</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
<id>partial-build</id>
<build>
<plugins>
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org