Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.3.0
-
None
-
Patch
Description
The new banDynamicVersions rule takes an ignores parameter, but rather than excluding artifacts it only includes matching artifacts.
To see the issue, check out this PR and apply the following patch:
diff --git a/pom.xml b/pom.xml index b26ec1b7..6a5f1b8a 100644 --- a/pom.xml +++ b/pom.xml @@ -986,19 +986,14 @@ </banDuplicateClasses> <banDuplicatePomDependencyVersions /> <banDynamicVersions> - <!-- XXX: Drop this once the `ignores` section - below works as expected. --> - <allowSnapshots>true</allowSnapshots> <!-- XXX: It shouldn't be necessary to specify an empty `excludedScopes` parameter, but without this an NPE results. See https://issues.apache.org/jira/browse/MENFORCER-481. --> <excludedScopes /> - <!-- XXX: This doesn't work. See - https://issues.apache.org/jira/browse/MENFORCER-480. <ignores> <ignore>${project.groupId}</ignore> - </ignores> --> + </ignores> </banDynamicVersions> <dependencyConvergence /> <enforceBytecodeVersion>
Now running mvn clean package will cause a build failure. Changing the ignore pattern to foo causes the build to pass.
The following Maven Enforcer change resolves the issue:
diff --git a/enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/dependency/BanDynamicVersions.java b/enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/dependency/BanDynamicVersions.java index 7224b84..5a827c8 100644 --- a/enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/dependency/BanDynamicVersions.java +++ b/enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/dependency/BanDynamicVersions.java @@ -227,7 +227,7 @@ public final class BanDynamicVersions extends AbstractStandardEnforcerRule { @Override public boolean test(DependencyNode depNode) { - return artifactMatcher.match(ArtifactUtils.toArtifact(depNode)); + return !artifactMatcher.match(ArtifactUtils.toArtifact(depNode)); } }
Attachments
Attachments
Issue Links
- links to