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.
This commit is contained in:
parent
64ca0fe9bb
commit
2738c783e5
|
@ -131,12 +131,6 @@ class BuildPlugin implements Plugin<Project> {
|
|||
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")
|
||||
|
|
|
@ -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}",
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue