Move gradle version check to global build info plugin (#57255)

The gradle version check currently exists in BuildPlugin. However, there
is no reason to check this within every project. Instead, this commit
moves the check to the global build info, which is only applied to the
root project. Additionally, this commit removes the check from buildSrc
because it is not really necessary. The check exists really just for
external plugin authors since we use the gradle wrapper for our own
build.
This commit is contained in:
Ryan Ernst 2020-05-27 17:27:44 -07:00 committed by Ryan Ernst
parent fdb8573413
commit 97353297dc
No known key found for this signature in database
GPG Key ID: 5F7EA39E15F54DCE
3 changed files with 4 additions and 17 deletions

View File

@ -27,11 +27,6 @@ plugins {
group = 'org.elasticsearch.gradle' group = 'org.elasticsearch.gradle'
String minimumGradleVersion = file('src/main/resources/minimumGradleVersion').text.trim()
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
}
if (project == rootProject) { if (project == rootProject) {
// change the build dir used during build init, so that doing a clean // change the build dir used during build init, so that doing a clean
// won't wipe out the buildscript jar // won't wipe out the buildscript jar

View File

@ -66,18 +66,6 @@ class BuildPlugin implements Plugin<Project> {
+ 'elasticsearch.standalone-rest-test, and elasticsearch.build ' + 'elasticsearch.standalone-rest-test, and elasticsearch.build '
+ 'are mutually exclusive') + 'are mutually exclusive')
} }
String minimumGradleVersion = null
InputStream is = getClass().getResourceAsStream("/minimumGradleVersion")
try {
minimumGradleVersion = IOUtils.toString(is, StandardCharsets.UTF_8.toString())
} finally {
is.close()
}
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion.trim())) {
throw new GradleException(
"Gradle ${minimumGradleVersion}+ is required to use elasticsearch.build plugin"
)
}
project.pluginManager.apply('elasticsearch.java') project.pluginManager.apply('elasticsearch.java')
configureLicenseAndNotice(project) configureLicenseAndNotice(project)
project.pluginManager.apply('elasticsearch.publish') project.pluginManager.apply('elasticsearch.publish')

View File

@ -66,6 +66,10 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
if (project != project.getRootProject()) { if (project != project.getRootProject()) {
throw new IllegalStateException(this.getClass().getName() + " can only be applied to the root project."); throw new IllegalStateException(this.getClass().getName() + " can only be applied to the root project.");
} }
GradleVersion minimumGradleVersion = GradleVersion.version(Util.getResourceContents("/minimumGradleVersion"));
if (GradleVersion.current().compareTo(minimumGradleVersion) < 0) {
throw new GradleException("Gradle " + minimumGradleVersion.getVersion() + "+ is required");
}
JavaVersion minimumCompilerVersion = JavaVersion.toVersion(Util.getResourceContents("/minimumCompilerVersion")); JavaVersion minimumCompilerVersion = JavaVersion.toVersion(Util.getResourceContents("/minimumCompilerVersion"));
JavaVersion minimumRuntimeVersion = JavaVersion.toVersion(Util.getResourceContents("/minimumRuntimeVersion")); JavaVersion minimumRuntimeVersion = JavaVersion.toVersion(Util.getResourceContents("/minimumRuntimeVersion"));