mavenmaven-3maven-enforcer-plugin

Make maven-enforcer-plugin dependency convergence rule ignore minor version of artifact


I want to introduce maven-enforcer-plugin in my maven project but don't want to compare the bug fix versions while evaluating the rules.

Ex.: groupId-artifactId-X.Y.A and groupId-artifactId-X-Y-B should not be treated as rule failure.

The current plugin configuration looks like following

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M3</version>
                <executions>
                    <execution>
                        <id>enforce-versions</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireJavaVersion>
                                    <version>1.8</version>
                                </requireJavaVersion>
                                <banDuplicatePomDependencyVersions/>
                                <dependencyConvergence/>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

If an artifact, let's say aws-java-sdk is being pulled in as transitive dependency from two different directly listed dependencies, the plugin should NOT raise an error if the versions of aws-java-sdk only differ for minor version like 1.21.667 and 1.21.700. It should only raise an error if feature/major versions are different like 1.21.667 and 1.17.111


Solution

  • That is not possible with the current rule.

    You need to write your own enforcer rule for that.