Skip to content

Commit

Permalink
[MENFORCER-480] BanDynamicVersions: fix ignores parameter (#269)
Browse files Browse the repository at this point in the history
Matching artifacts should be _excluded_ rather than included.
  • Loading branch information
Stephan202 committed May 1, 2023
1 parent 01a8243 commit b3587ec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private static final class ExcludeArtifactPatternsPredicate implements Predicate

@Override
public boolean test(DependencyNode depNode) {
return artifactMatcher.match(ArtifactUtils.toArtifact(depNode));
return !artifactMatcher.match(ArtifactUtils.toArtifact(depNode));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<excludedScope>test</excludedScope>
</excludedScopes>
<allowRangesWithIdenticalBounds>true</allowRangesWithIdenticalBounds>
<ignores>
<ignore>*:menforcer134_project</ignore>
</ignores>
</banDynamicVersions>
</rules>
</configuration>
Expand Down Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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.' )

0 comments on commit b3587ec

Please sign in to comment.