From 60638c3c4847093fc1c2a9d015558b57c73ef7cc Mon Sep 17 00:00:00 2001 From: iamdanfox Date: Thu, 3 Dec 2020 15:57:03 +0000 Subject: [PATCH] Don't impose a gradle 6.7 requirement (#1579) --- .../tasks/CheckExplicitSourceCompatibilityTask.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckExplicitSourceCompatibilityTask.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckExplicitSourceCompatibilityTask.java index 0753ab675..a43424c0c 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckExplicitSourceCompatibilityTask.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/tasks/CheckExplicitSourceCompatibilityTask.java @@ -33,6 +33,7 @@ import org.gradle.api.specs.Spec; import org.gradle.api.tasks.TaskAction; import org.gradle.api.tasks.options.Option; +import org.gradle.util.GradleVersion; /** * By default, Gradle will infer sourceCompat based on whatever JVM is currently being used to evaluate the @@ -56,6 +57,12 @@ public CheckExplicitSourceCompatibilityTask(ObjectFactory objectFactory) { onlyIf(new Spec() { @Override public boolean isSatisfiedBy(Task element) { + if (GradleVersion.current().compareTo(GradleVersion.version("6.7")) < 0) { + // We're cheekily using this 'getRawSourceCompatibility' method which was only added in Gradle 6.7 + // https://github.com/gradle/gradle/commit/8e55abb151e7d933c8348b32b6163fb535254a08. + return false; + } + // sometimes people apply the 'java' plugin to projects that doesn't actually have any java code in it // (e.g. the root project), so if they're not publishing anything, then we don't bother enforcing the // sourceCompat thing. Also they might apply the publishing plugin just to get the 'publish' task.