This is an automated email from the ASF dual-hosted git repository. sjaranowski pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git
The following commit(s) were added to refs/heads/master by this push: new b3587ec [MENFORCER-480] BanDynamicVersions: fix `ignores` parameter (#269) b3587ec is described below commit b3587ec9bd4d69b1dfd3ce88196079f7e3003916 Author: Stephan Schroevers <stephan.schroev...@teampicnic.com> AuthorDate: Mon May 1 13:58:30 2023 +0200 [MENFORCER-480] BanDynamicVersions: fix `ignores` parameter (#269) Matching artifacts should be _excluded_ rather than included. --- .../maven/enforcer/rules/dependency/BanDynamicVersions.java | 2 +- .../src/it/projects/ban-dynamic-versions/pom.xml | 9 +++++++++ .../src/it/projects/ban-dynamic-versions/verify.groovy | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) 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 560ff0c..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)); } } diff --git a/maven-enforcer-plugin/src/it/projects/ban-dynamic-versions/pom.xml b/maven-enforcer-plugin/src/it/projects/ban-dynamic-versions/pom.xml index 71afef5..304f38b 100644 --- a/maven-enforcer-plugin/src/it/projects/ban-dynamic-versions/pom.xml +++ b/maven-enforcer-plugin/src/it/projects/ban-dynamic-versions/pom.xml @@ -45,6 +45,9 @@ <excludedScope>test</excludedScope> </excludedScopes> <allowRangesWithIdenticalBounds>true</allowRangesWithIdenticalBounds> + <ignores> + <ignore>*:menforcer134_project</ignore> + </ignores> </banDynamicVersions> </rules> </configuration> @@ -109,6 +112,12 @@ <!-- version range syntax with equal upper and lower bounds --> <version>[1.0]</version> </dependency> + <dependency> + <!-- banned SNAPSHOT, but ignored (though it's transitive dependency on menforcer134_modelbuilder is not) --> + <groupId>org.apache.maven.plugins.enforcer.its</groupId> + <artifactId>menforcer134_project</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> </dependencies> </project> diff --git a/maven-enforcer-plugin/src/it/projects/ban-dynamic-versions/verify.groovy b/maven-enforcer-plugin/src/it/projects/ban-dynamic-versions/verify.groovy index e2a4ae9..f88976b 100644 --- a/maven-enforcer-plugin/src/it/projects/ban-dynamic-versions/verify.groovy +++ b/maven-enforcer-plugin/src/it/projects/ban-dynamic-versions/verify.groovy @@ -21,5 +21,6 @@ assert buildLog.text.contains( '[ERROR] Dependency org.apache.maven.plugins.enfo assert buildLog.text.contains( '[ERROR] Dependency org.apache.maven.plugins.enforcer.its:menforcer138_io:jar:LATEST (compile) is referenced with a banned dynamic version LATEST' ) assert buildLog.text.contains( '[ERROR] Dependency org.apache.maven.plugins.enforcer.its:menforcer134_model:jar:1.0-SNAPSHOT (compile) is referenced with a banned dynamic version 1.0-SNAPSHOT' ) assert buildLog.text.contains( '[ERROR] Dependency org.apache.maven.plugins.enforcer.its:menforcer427-a:jar:1.0 (compile) via org.apache.maven.plugins.enforcer.its:menforcer427:jar:1.0 is referenced with a banned dynamic version [1.0,2)' ) +assert buildLog.text.contains( 'Dependency org.apache.maven.plugins.enforcer.its:menforcer134_modelbuilder:jar:1.0-SNAPSHOT (compile) via org.apache.maven.plugins.enforcer.its:menforcer134_project:jar:1.0-SNAPSHOT is referenced with a banned dynamic version 1.0-SNAPSHOT' ) assert buildLog.text.contains( '[ERROR] Rule 0: org.apache.maven.enforcer.rules.dependency.BanDynamicVersions failed with message' ) -assert buildLog.text.contains( 'ERROR] Found 4 dependencies with dynamic versions.' ) +assert buildLog.text.contains( 'ERROR] Found 5 dependencies with dynamic versions.' )