Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

chore: update GRADLE_MIN_VERSION in check and test suite to 4.0 #453

Merged
merged 5 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,8 +35,6 @@
*/
public class AppEnginePlugin implements Plugin<Project> {

private static final GradleVersion GRADLE_MIN_VERSION = GradleVersion.version("3.4.1");

@Override
public void apply(Project project) {
checkGradleVersion();
Expand Down Expand Up @@ -63,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.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,8 +33,6 @@
*/
public class AppEngineCorePluginConfiguration {

public static final GradleVersion GRADLE_MIN_VERSION = GradleVersion.version("3.4.1");

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";
Expand Down Expand Up @@ -336,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.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -49,7 +49,7 @@ public void testCheckGradleVersion_pass() {
assumeTrue(isJava8Runtime());
new TestProject(testProjectRoot.getRoot())
.applyGradleRunnerWithGradleVersion(
AppEngineCorePluginConfiguration.GRADLE_MIN_VERSION.getVersion());
GradleCompatibility.getMinimumGradleVersion().getVersion());
// pass
}

Expand All @@ -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."));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -65,7 +65,7 @@ public void testCheckGradleVersion_pass() throws IOException {
assumeTrue(isJava8Runtime());
createTestProject()
.applyGradleRunnerWithGradleVersion(
AppEngineCorePluginConfiguration.GRADLE_MIN_VERSION.getVersion());
GradleCompatibility.getMinimumGradleVersion().getVersion());
// pass
}

Expand All @@ -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."));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,7 +69,7 @@ public void testCheckGradleVersion_pass() throws IOException {
assumeTrue(isJava8Runtime());
createTestProject()
.applyGradleRunnerWithGradleVersion(
AppEngineCorePluginConfiguration.GRADLE_MIN_VERSION.getVersion());
GradleCompatibility.getMinimumGradleVersion().getVersion());
// pass
}

Expand All @@ -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."));
}
}
Expand Down