diff --git a/pom.xml b/pom.xml
index a9d0fc5..9201119 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,6 +16,7 @@
${skipTests}
+ junit.version,kept-for-compat.version
7.22.0
6.0.3
diff --git a/src/main/java/com/solubris/enforcer/UnusedPropertyRule.java b/src/main/java/com/solubris/enforcer/UnusedPropertyRule.java
index 1474c88..d428f72 100644
--- a/src/main/java/com/solubris/enforcer/UnusedPropertyRule.java
+++ b/src/main/java/com/solubris/enforcer/UnusedPropertyRule.java
@@ -7,10 +7,12 @@
import javax.inject.Inject;
import javax.inject.Named;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Set;
import java.util.concurrent.atomic.LongAdder;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -28,6 +30,7 @@
@Named("unusedPropertyRule")
public class UnusedPropertyRule extends AbstractEnforcerRule {
private static final Pattern PROPERTY_PATTERN = Pattern.compile("\\$\\{([^}]+)\\}");
+ protected static final String SUPPRESSIONS_PROPERTY = "unusedPropertyRule.suppressions";
private final Model originalModel;
private final Model effectiveModel;
@@ -66,8 +69,12 @@ protected Stream scanProperties() {
// .filter(artifact -> !isExcluded(artifact.getVersion()))
.collect(groupingBy(ArtifactV2::getVersion, toList()));
+ String property = originalModel.getProperties().getProperty(SUPPRESSIONS_PROPERTY);
+ Set suppressed = parseSuppressedPropertyList(property);
+
return originalModel.getProperties().entrySet().stream()
.filter(UnusedPropertyRule::isVersionProperty) // only check properties that look like versions
+ .filter(e -> !suppressed.contains(e.getKey().toString()))
.map(e -> {
String propName = e.getKey().toString();
String propValue = e.getValue() != null ? e.getValue().toString() : "";
@@ -76,6 +83,14 @@ protected Stream scanProperties() {
}).filter(Objects::nonNull);
}
+ private static Set parseSuppressedPropertyList(String raw) {
+ if (raw == null || raw.isBlank()) return Collections.emptySet();
+ return Arrays.stream(raw.split("[,\\s]+"))
+ .map(String::trim)
+ .filter(s -> !s.isEmpty())
+ .collect(Collectors.toSet());
+ }
+
private static boolean isVersionProperty(Map.Entry