From 2738c783e57650fe57531a2a916a2ae6929b3a3f Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Thu, 30 Nov 2017 10:03:16 +0100 Subject: [PATCH] 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. --- .../main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy | 6 ------ .../groovy/org/elasticsearch/gradle/test/AntFixture.groovy | 1 - .../elasticsearch/gradle/test/ClusterFormationTasks.groovy | 6 +++++- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index add518822e0..c1669c0a72a 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -131,12 +131,6 @@ class BuildPlugin implements Plugin { throw new GradleException("${minGradle} or above is required to build elasticsearch") } - final GradleVersion gradle42 = GradleVersion.version('4.2') - final GradleVersion gradle43 = GradleVersion.version('4.3') - if (currentGradleVersion >= gradle42 && currentGradleVersion < gradle43) { - throw new GradleException("${currentGradleVersion} is not compatible with the elasticsearch build") - } - // enforce Java version if (javaVersionEnum < minimumJava) { throw new GradleException("Java ${minimumJava} or above is required to build Elasticsearch") diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/AntFixture.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/AntFixture.groovy index 34c3046aa2b..039bce05226 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/AntFixture.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/AntFixture.groovy @@ -69,7 +69,6 @@ public class AntFixture extends AntTask implements Fixture { * as well as a groovy AntBuilder, to enable running ant condition checks. The default wait * condition is for http on the http port. */ - @Input Closure waitCondition = { AntFixture fixture, AntBuilder ant -> File tmpFile = new File(fixture.cwd, 'wait.success') ant.get(src: "http://${fixture.addressAndPort}", diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index 72c6eef6685..f7637d23366 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -166,11 +166,13 @@ class ClusterFormationTasks { Task setup = project.tasks.create(name: taskName(prefix, node, 'clean'), type: Delete, dependsOn: dependsOn) { delete node.homeDir delete node.cwd + } + setup = project.tasks.create(name: taskName(prefix, node, 'createCwd'), type: DefaultTask, dependsOn: setup) { doLast { node.cwd.mkdirs() } + outputs.dir node.cwd } - setup = configureCheckPreviousTask(taskName(prefix, node, 'checkPrevious'), project, setup, node) setup = configureStopTask(taskName(prefix, node, 'stopPrevious'), project, setup, node) setup = configureExtractTask(taskName(prefix, node, 'extract'), project, setup, node, distribution) @@ -281,6 +283,7 @@ class ClusterFormationTasks { rpmDatabase.deleteDir() rpmExtracted.deleteDir() } + outputs.dir rpmExtracted } break; case 'deb': @@ -292,6 +295,7 @@ class ClusterFormationTasks { doFirst { debExtracted.deleteDir() } + outputs.dir debExtracted } break; default: