From 5fb72f3c216863e820893055e52be700c0f8fa49 Mon Sep 17 00:00:00 2001 From: Fabian Windheuser Date: Wed, 18 Aug 2021 12:55:27 +0200 Subject: [PATCH] Re-add null check for exclude rule (#1883) Re-add null check for exclude rule --- changelog/@unreleased/pr-1883.v2.yml | 5 +++++ .../plugins/BaselineExactDependencies.java | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 changelog/@unreleased/pr-1883.v2.yml 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. */