diff --git a/changelog/@unreleased/pr-1883.v2.yml b/changelog/@unreleased/pr-1883.v2.yml new file mode 100644 index 000000000..300cec30b --- /dev/null +++ b/changelog/@unreleased/pr-1883.v2.yml @@ -0,0 +1,5 @@ +type: fix +fix: + description: Re-add null check for exclude rule + links: + - https://github.com/palantir/gradle-baseline/pull/1883 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineExactDependencies.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineExactDependencies.java index 2aa1cb10a..fd8eab1c2 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineExactDependencies.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineExactDependencies.java @@ -18,6 +18,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableSet; import com.palantir.baseline.tasks.CheckImplicitDependenciesParentTask; import com.palantir.baseline.tasks.CheckImplicitDependenciesTask; @@ -231,10 +232,15 @@ private static String getCompileConfigurationName(SourceSet sourceSet) { } private static Map excludeRuleAsMap(ExcludeRule rule) { - return ImmutableMap.builder() - .put("group", rule.getGroup()) - .put("module", rule.getModule()) - .build(); + // Both 'ExcludeRule#getGroup' and 'ExcludeRule#getModule' can return null. + Builder excludeRule = ImmutableMap.builder(); + if (rule.getGroup() != null) { + excludeRule.put("group", rule.getGroup()); + } + if (rule.getModule() != null) { + excludeRule.put("module", rule.getModule()); + } + return excludeRule.build(); } /** Given a {@code com/palantir/product/Foo.class} file, what other classes does it import/reference. */