Skip to content

Commit 5fc9451

Browse files
committed
Fix Gradle >=4.2 compatibility (#27591)
Gradle 4.2 introduced a feature for safer handling of stale output files. Unfortunately, due to the way some of our tasks are written, this broke execution of our REST tests tasks. The reason for this is that the extract task (which extracts the ES distribution) would clean its output directory, and thereby also remove the empty cwd subdirectory which was created by the clean task. The reason why Gradle would remove the directory is that the earlier running clean task would programmatically create the empty cwd directory, but not make Gradle aware of this fact, which would result in Gradle believing that it could just safely clean the directory. This commit explicitly defines a task to create the cwd subdirectory, and marks the directory as output of the task, so that the subsequent extract task won't eagerly clean it. It thereby restores full compatibility of the build with Gradle 4.2 and above. This commit also removes the @input annotation on the waitCondition closure of AntFixture, which conflicted with the extended input/output validation of Gradle 4.3.
1 parent 8d33101 commit 5fc9451

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ class BuildPlugin implements Plugin<Project> {
131131
throw new GradleException("${minGradle} or above is required to build elasticsearch")
132132
}
133133

134-
final GradleVersion gradle42 = GradleVersion.version('4.2')
135-
final GradleVersion gradle43 = GradleVersion.version('4.3')
136-
if (currentGradleVersion >= gradle42 && currentGradleVersion < gradle43) {
137-
throw new GradleException("${currentGradleVersion} is not compatible with the elasticsearch build")
138-
}
139-
140134
// enforce Java version
141135
if (javaVersionEnum < minimumJava) {
142136
throw new GradleException("Java ${minimumJava} or above is required to build Elasticsearch")

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/AntFixture.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public class AntFixture extends AntTask implements Fixture {
6969
* as well as a groovy AntBuilder, to enable running ant condition checks. The default wait
7070
* condition is for http on the http port.
7171
*/
72-
@Input
7372
Closure waitCondition = { AntFixture fixture, AntBuilder ant ->
7473
File tmpFile = new File(fixture.cwd, 'wait.success')
7574
ant.get(src: "http://${fixture.addressAndPort}",

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,13 @@ class ClusterFormationTasks {
166166
Task setup = project.tasks.create(name: taskName(prefix, node, 'clean'), type: Delete, dependsOn: dependsOn) {
167167
delete node.homeDir
168168
delete node.cwd
169+
}
170+
setup = project.tasks.create(name: taskName(prefix, node, 'createCwd'), type: DefaultTask, dependsOn: setup) {
169171
doLast {
170172
node.cwd.mkdirs()
171173
}
174+
outputs.dir node.cwd
172175
}
173-
174176
setup = configureCheckPreviousTask(taskName(prefix, node, 'checkPrevious'), project, setup, node)
175177
setup = configureStopTask(taskName(prefix, node, 'stopPrevious'), project, setup, node)
176178
setup = configureExtractTask(taskName(prefix, node, 'extract'), project, setup, node, distribution)
@@ -281,6 +283,7 @@ class ClusterFormationTasks {
281283
rpmDatabase.deleteDir()
282284
rpmExtracted.deleteDir()
283285
}
286+
outputs.dir rpmExtracted
284287
}
285288
break;
286289
case 'deb':
@@ -292,6 +295,7 @@ class ClusterFormationTasks {
292295
doFirst {
293296
debExtracted.deleteDir()
294297
}
298+
outputs.dir debExtracted
295299
}
296300
break;
297301
default:

0 commit comments

Comments
 (0)