Skip to content

Commit f5bbf10

Browse files
committed
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.
1 parent 2d99858 commit f5bbf10

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

buildSrc/build.gradle

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ plugins {
2727

2828
group = 'org.elasticsearch.gradle'
2929

30-
String minimumGradleVersion = file('src/main/resources/minimumGradleVersion').text.trim()
31-
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
32-
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
33-
}
34-
3530
if (project == rootProject) {
3631
// change the build dir used during build init, so that doing a clean
3732
// won't wipe out the buildscript jar

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,6 @@ class BuildPlugin implements Plugin<Project> {
6666
+ 'elasticsearch.standalone-rest-test, and elasticsearch.build '
6767
+ 'are mutually exclusive')
6868
}
69-
String minimumGradleVersion = null
70-
InputStream is = getClass().getResourceAsStream("/minimumGradleVersion")
71-
try {
72-
minimumGradleVersion = IOUtils.toString(is, StandardCharsets.UTF_8.toString())
73-
} finally {
74-
is.close()
75-
}
76-
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion.trim())) {
77-
throw new GradleException(
78-
"Gradle ${minimumGradleVersion}+ is required to use elasticsearch.build plugin"
79-
)
80-
}
8169
project.pluginManager.apply('elasticsearch.java')
8270
configureLicenseAndNotice(project)
8371
project.pluginManager.apply('elasticsearch.publish')

buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public void apply(Project project) {
6666
if (project != project.getRootProject()) {
6767
throw new IllegalStateException(this.getClass().getName() + " can only be applied to the root project.");
6868
}
69+
GradleVersion minimumGradleVersion = GradleVersion.version(Util.getResourceContents("/minimumGradleVersion"));
70+
if (GradleVersion.current().compareTo(minimumGradleVersion) < 0) {
71+
throw new GradleException("Gradle " + minimumGradleVersion.getVersion() + "+ is required");
72+
}
6973

7074
JavaVersion minimumCompilerVersion = JavaVersion.toVersion(Util.getResourceContents("/minimumCompilerVersion"));
7175
JavaVersion minimumRuntimeVersion = JavaVersion.toVersion(Util.getResourceContents("/minimumRuntimeVersion"));

0 commit comments

Comments
 (0)