From 8f780ab8ac1c9f0ea66786898028b69d6b1dd7cb Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Mon, 16 Jan 2023 10:01:43 -0500 Subject: [PATCH 1/3] chore: update GRADLE_MIN_VERSION in check and test suite to 4.0 --- .../google/cloud/tools/gradle/appengine/AppEnginePlugin.java | 2 +- .../gradle/appengine/core/AppEngineCorePluginConfiguration.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/cloud/tools/gradle/appengine/AppEnginePlugin.java b/src/main/java/com/google/cloud/tools/gradle/appengine/AppEnginePlugin.java index cf6a09a5..956f7d0b 100644 --- a/src/main/java/com/google/cloud/tools/gradle/appengine/AppEnginePlugin.java +++ b/src/main/java/com/google/cloud/tools/gradle/appengine/AppEnginePlugin.java @@ -34,7 +34,7 @@ */ public class AppEnginePlugin implements Plugin { - private static final GradleVersion GRADLE_MIN_VERSION = GradleVersion.version("3.4.1"); + private static final GradleVersion GRADLE_MIN_VERSION = GradleVersion.version("4.0"); @Override public void apply(Project project) { diff --git a/src/main/java/com/google/cloud/tools/gradle/appengine/core/AppEngineCorePluginConfiguration.java b/src/main/java/com/google/cloud/tools/gradle/appengine/core/AppEngineCorePluginConfiguration.java index 09f23da6..559e6d13 100644 --- a/src/main/java/com/google/cloud/tools/gradle/appengine/core/AppEngineCorePluginConfiguration.java +++ b/src/main/java/com/google/cloud/tools/gradle/appengine/core/AppEngineCorePluginConfiguration.java @@ -32,7 +32,7 @@ */ public class AppEngineCorePluginConfiguration { - public static final GradleVersion GRADLE_MIN_VERSION = GradleVersion.version("3.4.1"); + public static final GradleVersion GRADLE_MIN_VERSION = GradleVersion.version("4.0"); public static final String LOGIN_TASK_NAME = "appengineCloudSdkLogin"; public static final String DEPLOY_TASK_NAME = "appengineDeploy"; From 47d96a6111c5d8e5048aadb6eb4963083d7fd36d Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Tue, 4 Jul 2023 13:54:12 -0400 Subject: [PATCH 2/3] refactor: define GRADLE_MIN_VERSION in utility class --- .../cloud/tools/gradle/appengine/AppEnginePlugin.java | 4 +++- .../core/AppEngineCorePluginConfiguration.java | 4 +++- .../gradle/appengine/util/GradleCompatibility.java | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/cloud/tools/gradle/appengine/AppEnginePlugin.java b/src/main/java/com/google/cloud/tools/gradle/appengine/AppEnginePlugin.java index 956f7d0b..77579702 100644 --- a/src/main/java/com/google/cloud/tools/gradle/appengine/AppEnginePlugin.java +++ b/src/main/java/com/google/cloud/tools/gradle/appengine/AppEnginePlugin.java @@ -19,6 +19,7 @@ import com.google.cloud.tools.gradle.appengine.appyaml.AppEngineAppYamlPlugin; import com.google.cloud.tools.gradle.appengine.standard.AppEngineStandardPlugin; +import com.google.cloud.tools.gradle.appengine.util.GradleCompatibility; import java.nio.file.Files; import java.nio.file.Path; import org.gradle.api.GradleException; @@ -34,7 +35,8 @@ */ public class AppEnginePlugin implements Plugin { - private static final GradleVersion GRADLE_MIN_VERSION = GradleVersion.version("4.0"); + private static final GradleVersion GRADLE_MIN_VERSION = + GradleCompatibility.getMinimumGradleVersion(); @Override public void apply(Project project) { diff --git a/src/main/java/com/google/cloud/tools/gradle/appengine/core/AppEngineCorePluginConfiguration.java b/src/main/java/com/google/cloud/tools/gradle/appengine/core/AppEngineCorePluginConfiguration.java index 559e6d13..81419cb2 100644 --- a/src/main/java/com/google/cloud/tools/gradle/appengine/core/AppEngineCorePluginConfiguration.java +++ b/src/main/java/com/google/cloud/tools/gradle/appengine/core/AppEngineCorePluginConfiguration.java @@ -18,6 +18,7 @@ package com.google.cloud.tools.gradle.appengine.core; import com.google.cloud.tools.appengine.operations.cloudsdk.CloudSdkNotFoundException; +import com.google.cloud.tools.gradle.appengine.util.GradleCompatibility; import com.google.cloud.tools.managedcloudsdk.BadCloudSdkVersionException; import com.google.cloud.tools.managedcloudsdk.ManagedCloudSdk; import com.google.cloud.tools.managedcloudsdk.UnsupportedOsException; @@ -32,7 +33,8 @@ */ public class AppEngineCorePluginConfiguration { - public static final GradleVersion GRADLE_MIN_VERSION = GradleVersion.version("4.0"); + public static final GradleVersion GRADLE_MIN_VERSION = + GradleCompatibility.getMinimumGradleVersion(); public static final String LOGIN_TASK_NAME = "appengineCloudSdkLogin"; public static final String DEPLOY_TASK_NAME = "appengineDeploy"; diff --git a/src/main/java/com/google/cloud/tools/gradle/appengine/util/GradleCompatibility.java b/src/main/java/com/google/cloud/tools/gradle/appengine/util/GradleCompatibility.java index c5f897b0..d0d18704 100644 --- a/src/main/java/com/google/cloud/tools/gradle/appengine/util/GradleCompatibility.java +++ b/src/main/java/com/google/cloud/tools/gradle/appengine/util/GradleCompatibility.java @@ -11,6 +11,16 @@ private GradleCompatibility() { // Prevent instantiation and extension. } + /** + * Method for getting the minimum version of Gradle supported by the plugin, for use in + * enforcement checks and test suite. + * + * @return the minimum compatible {@link GradleVersion}. + */ + public static GradleVersion getMinimumGradleVersion() { + return GradleVersion.version("4.0"); + } + /** * Compatibility method for getting the archive location. * From 716a7c88ef671990783e5a8d1fa5b907f832f4dd Mon Sep 17 00:00:00 2001 From: Emily Wang Date: Tue, 4 Jul 2023 14:21:08 -0400 Subject: [PATCH 3/3] refactor: consolidate definitions of GRADLE_MIN_VERSION --- .../cloud/tools/gradle/appengine/AppEnginePlugin.java | 7 ++----- .../appengine/core/AppEngineCorePluginConfiguration.java | 7 ++----- .../cloud/tools/gradle/appengine/AppEnginePluginTest.java | 6 +++--- .../appengine/appyaml/AppEngineAppYamlPluginTest.java | 6 +++--- .../appengine/standard/AppEngineStandardPluginTest.java | 6 +++--- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/google/cloud/tools/gradle/appengine/AppEnginePlugin.java b/src/main/java/com/google/cloud/tools/gradle/appengine/AppEnginePlugin.java index 77579702..66d07959 100644 --- a/src/main/java/com/google/cloud/tools/gradle/appengine/AppEnginePlugin.java +++ b/src/main/java/com/google/cloud/tools/gradle/appengine/AppEnginePlugin.java @@ -35,9 +35,6 @@ */ public class AppEnginePlugin implements Plugin { - private static final GradleVersion GRADLE_MIN_VERSION = - GradleCompatibility.getMinimumGradleVersion(); - @Override public void apply(Project project) { checkGradleVersion(); @@ -65,12 +62,12 @@ private boolean isAppEngineWebXmlBased(Project project) { } private void checkGradleVersion() { - if (GRADLE_MIN_VERSION.compareTo(GradleVersion.current()) > 0) { + if (GradleCompatibility.getMinimumGradleVersion().compareTo(GradleVersion.current()) > 0) { throw new GradleException( "Detected " + GradleVersion.current() + ", but the appengine-gradle-plugin requires " - + GRADLE_MIN_VERSION + + GradleCompatibility.getMinimumGradleVersion() + " or higher."); } } diff --git a/src/main/java/com/google/cloud/tools/gradle/appengine/core/AppEngineCorePluginConfiguration.java b/src/main/java/com/google/cloud/tools/gradle/appengine/core/AppEngineCorePluginConfiguration.java index 81419cb2..fd2b6f81 100644 --- a/src/main/java/com/google/cloud/tools/gradle/appengine/core/AppEngineCorePluginConfiguration.java +++ b/src/main/java/com/google/cloud/tools/gradle/appengine/core/AppEngineCorePluginConfiguration.java @@ -33,9 +33,6 @@ */ public class AppEngineCorePluginConfiguration { - public static final GradleVersion GRADLE_MIN_VERSION = - GradleCompatibility.getMinimumGradleVersion(); - public static final String LOGIN_TASK_NAME = "appengineCloudSdkLogin"; public static final String DEPLOY_TASK_NAME = "appengineDeploy"; public static final String DEPLOY_CRON_TASK_NAME = "appengineDeployCron"; @@ -338,12 +335,12 @@ private void createShowConfigurationTask() { } private void checkGradleVersion() { - if (GRADLE_MIN_VERSION.compareTo(GradleVersion.current()) > 0) { + if (GradleCompatibility.getMinimumGradleVersion().compareTo(GradleVersion.current()) > 0) { throw new GradleException( "Detected " + GradleVersion.current() + ", but the appengine-gradle-plugin requires " - + GRADLE_MIN_VERSION + + GradleCompatibility.getMinimumGradleVersion() + " or higher."); } } diff --git a/src/test/java/com/google/cloud/tools/gradle/appengine/AppEnginePluginTest.java b/src/test/java/com/google/cloud/tools/gradle/appengine/AppEnginePluginTest.java index 2ed22d41..2cf5c6fa 100644 --- a/src/test/java/com/google/cloud/tools/gradle/appengine/AppEnginePluginTest.java +++ b/src/test/java/com/google/cloud/tools/gradle/appengine/AppEnginePluginTest.java @@ -25,8 +25,8 @@ import static org.junit.Assume.assumeTrue; import com.google.cloud.tools.gradle.appengine.appyaml.AppEngineAppYamlPlugin; -import com.google.cloud.tools.gradle.appengine.core.AppEngineCorePluginConfiguration; import com.google.cloud.tools.gradle.appengine.standard.AppEngineStandardPlugin; +import com.google.cloud.tools.gradle.appengine.util.GradleCompatibility; import java.io.IOException; import org.gradle.api.Project; import org.gradle.testkit.runner.BuildResult; @@ -49,7 +49,7 @@ public void testCheckGradleVersion_pass() { assumeTrue(isJava8Runtime()); new TestProject(testProjectRoot.getRoot()) .applyGradleRunnerWithGradleVersion( - AppEngineCorePluginConfiguration.GRADLE_MIN_VERSION.getVersion()); + GradleCompatibility.getMinimumGradleVersion().getVersion()); // pass } @@ -65,7 +65,7 @@ public void testCheckGradleVersion_fail() throws IOException { ex.getMessage(), containsString( "Detected Gradle 2.8, but the appengine-gradle-plugin requires " - + AppEngineCorePluginConfiguration.GRADLE_MIN_VERSION + + GradleCompatibility.getMinimumGradleVersion() + " or higher.")); } } diff --git a/src/test/java/com/google/cloud/tools/gradle/appengine/appyaml/AppEngineAppYamlPluginTest.java b/src/test/java/com/google/cloud/tools/gradle/appengine/appyaml/AppEngineAppYamlPluginTest.java index b4b2dbc5..15dec626 100644 --- a/src/test/java/com/google/cloud/tools/gradle/appengine/appyaml/AppEngineAppYamlPluginTest.java +++ b/src/test/java/com/google/cloud/tools/gradle/appengine/appyaml/AppEngineAppYamlPluginTest.java @@ -26,8 +26,8 @@ import com.google.cloud.tools.gradle.appengine.BuildResultFilter; import com.google.cloud.tools.gradle.appengine.TestProject; -import com.google.cloud.tools.gradle.appengine.core.AppEngineCorePluginConfiguration; import com.google.cloud.tools.gradle.appengine.core.DeployExtension; +import com.google.cloud.tools.gradle.appengine.util.GradleCompatibility; import com.google.common.collect.ImmutableList; import java.io.File; import java.io.IOException; @@ -65,7 +65,7 @@ public void testCheckGradleVersion_pass() throws IOException { assumeTrue(isJava8Runtime()); createTestProject() .applyGradleRunnerWithGradleVersion( - AppEngineCorePluginConfiguration.GRADLE_MIN_VERSION.getVersion()); + GradleCompatibility.getMinimumGradleVersion().getVersion()); // pass } @@ -79,7 +79,7 @@ public void testCheckGradleVersion_fail() throws IOException { ex.getMessage(), containsString( "Detected Gradle 2.8, but the appengine-gradle-plugin requires " - + AppEngineCorePluginConfiguration.GRADLE_MIN_VERSION + + GradleCompatibility.getMinimumGradleVersion() + " or higher.")); } } diff --git a/src/test/java/com/google/cloud/tools/gradle/appengine/standard/AppEngineStandardPluginTest.java b/src/test/java/com/google/cloud/tools/gradle/appengine/standard/AppEngineStandardPluginTest.java index eba8be68..9983c986 100644 --- a/src/test/java/com/google/cloud/tools/gradle/appengine/standard/AppEngineStandardPluginTest.java +++ b/src/test/java/com/google/cloud/tools/gradle/appengine/standard/AppEngineStandardPluginTest.java @@ -25,8 +25,8 @@ import com.google.cloud.tools.gradle.appengine.BuildResultFilter; import com.google.cloud.tools.gradle.appengine.TestProject; -import com.google.cloud.tools.gradle.appengine.core.AppEngineCorePluginConfiguration; import com.google.cloud.tools.gradle.appengine.core.DeployExtension; +import com.google.cloud.tools.gradle.appengine.util.GradleCompatibility; import com.google.common.collect.ImmutableList; import java.io.File; import java.io.IOException; @@ -69,7 +69,7 @@ public void testCheckGradleVersion_pass() throws IOException { assumeTrue(isJava8Runtime()); createTestProject() .applyGradleRunnerWithGradleVersion( - AppEngineCorePluginConfiguration.GRADLE_MIN_VERSION.getVersion()); + GradleCompatibility.getMinimumGradleVersion().getVersion()); // pass } @@ -83,7 +83,7 @@ public void testCheckGradleVersion_fail() throws IOException { ex.getMessage(), containsString( "Detected Gradle 2.8, but the appengine-gradle-plugin requires " - + AppEngineCorePluginConfiguration.GRADLE_MIN_VERSION + + GradleCompatibility.getMinimumGradleVersion() + " or higher.")); } }