Skip to content

Commit 3045eb5

Browse files
authored
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 9584b34 commit 3045eb5

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
@@ -28,11 +28,6 @@ plugins {
2828

2929
group = 'org.elasticsearch.gradle'
3030

31-
String minimumGradleVersion = file('src/main/resources/minimumGradleVersion').text.trim()
32-
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
33-
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
34-
}
35-
3631
if (project == rootProject) {
3732
// change the build dir used during build init, so that doing a clean
3833
// 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
@@ -63,18 +63,6 @@ class BuildPlugin implements Plugin<Project> {
6363
+ 'elasticsearch.standalone-rest-test, and elasticsearch.build '
6464
+ 'are mutually exclusive')
6565
}
66-
String minimumGradleVersion = null
67-
InputStream is = getClass().getResourceAsStream("/minimumGradleVersion")
68-
try {
69-
minimumGradleVersion = IOUtils.toString(is, StandardCharsets.UTF_8.toString())
70-
} finally {
71-
is.close()
72-
}
73-
if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion.trim())) {
74-
throw new GradleException(
75-
"Gradle ${minimumGradleVersion}+ is required to use elasticsearch.build plugin"
76-
)
77-
}
7866
project.pluginManager.apply('elasticsearch.java')
7967
configureLicenseAndNotice(project)
8068
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)