diff --git a/build.gradle b/build.gradle index e889a7fd50e11..ad9e5d582f9a5 100644 --- a/build.gradle +++ b/build.gradle @@ -154,7 +154,7 @@ subprojects { } } -task updateCIBwcVersions() { +tasks.register("updateCIBwcVersions") { doLast { File yml = file(".ci/bwcVersions") yml.text = "" @@ -188,7 +188,7 @@ allprojects { } } -task verifyVersions { +tasks.register("verifyVersions") { doLast { if (gradle.startParameter.isOffline()) { throw new GradleException("Must run in online mode to verify versions") @@ -240,7 +240,7 @@ subprojects { ext.bwc_tests_enabled = bwc_tests_enabled } -task verifyBwcTestsEnabled { +tasks.register("verifyBwcTestsEnabled") { doLast { if (bwc_tests_enabled == false) { throw new GradleException('Bwc tests are disabled. They must be re-enabled after completing backcompat behavior backporting.') @@ -248,10 +248,10 @@ task verifyBwcTestsEnabled { } } -task branchConsistency { +tasks.register("branchConsistency") { description 'Ensures this branch is internally consistent. For example, that versions constants match released versions.' group 'Verification' - dependsOn verifyVersions, verifyBwcTestsEnabled + dependsOn ":verifyVersions", ":verifyBwcTestsEnabled" } allprojects { @@ -452,7 +452,7 @@ class Run extends DefaultTask { } } -task run(type: Run) { +tasks.register("run", Run) { dependsOn ':distribution:run' description = 'Runs elasticsearch in the foreground' group = 'Verification' @@ -531,7 +531,7 @@ allprojects { if (realTask == null) { return } - project.tasks.create(taskName) { + project.tasks.register(taskName) { doLast { println("${realTask.path} dependencies:") for (Task dep : realTask.getTaskDependencies().getDependencies(realTask)) { diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 5889f062a74c4..e8463dcb42e16 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -48,7 +48,7 @@ if (project == rootProject) { Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project.file('version.properties')) version = props.getProperty("elasticsearch") -task generateVersionProperties(type: WriteProperties) { +def generateVersionProperties = tasks.register("generateVersionProperties", WriteProperties) { outputFile = "${buildDir}/version.properties" comment = 'Generated version properties' properties(props) @@ -239,13 +239,13 @@ if (project != rootProject) { } } - task integTest(type: Test) { + tasks.register("integTest", Test) { inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE) systemProperty 'test.version_under_test', version onlyIf { org.elasticsearch.gradle.info.BuildParams.inFipsJvm == false } maxParallelForks = System.getProperty('tests.jvms', org.elasticsearch.gradle.info.BuildParams.defaultParallel.toString()) as Integer } - check.dependsOn(integTest) + check.dependsOn("integTest") // for now we hardcode the tests for our build to use the gradle jvm. tasks.withType(Test).configureEach { diff --git a/buildSrc/reaper/build.gradle b/buildSrc/reaper/build.gradle index b816aaa4f58a8..ed810b362c389 100644 --- a/buildSrc/reaper/build.gradle +++ b/buildSrc/reaper/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'java' jar { - archiveName = "${project.name}.jar" + archiveFileName = "${project.name}.jar" manifest { attributes 'Main-Class': 'org.elasticsearch.gradle.reaper.Reaper' } 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 06e276576f190..6650463a5c5cc 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/AntFixture.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/AntFixture.groovy @@ -26,6 +26,8 @@ import org.gradle.api.GradleException import org.gradle.api.Task import org.gradle.api.tasks.Exec import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.TaskProvider + /** * A fixture for integration tests which runs in a separate process launched by Ant. */ @@ -79,7 +81,7 @@ class AntFixture extends AntTask implements Fixture { return tmpFile.exists() } - private final Task stopTask + private final TaskProvider stopTask AntFixture() { stopTask = createStopTask() @@ -88,7 +90,7 @@ class AntFixture extends AntTask implements Fixture { @Override @Internal - Task getStopTask() { + TaskProvider getStopTask() { return stopTask } @@ -222,24 +224,29 @@ class AntFixture extends AntTask implements Fixture { } /** Adds a task to kill an elasticsearch node with the given pidfile */ - private Task createStopTask() { + private TaskProvider createStopTask() { final AntFixture fixture = this final Object pid = "${ -> fixture.pid }" - Exec stop = project.tasks.create(name: "${name}#stop", type: LoggedExec) - stop.onlyIf { fixture.pidFile.exists() } - stop.doFirst { - logger.info("Shutting down ${fixture.name} with pid ${pid}") - } - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - stop.executable = 'Taskkill' - stop.args('/PID', pid, '/F') - } else { - stop.executable = 'kill' - stop.args('-9', pid) - } - stop.doLast { - project.delete(fixture.pidFile) + TaskProvider stop = project.tasks.register("${name}#stop", LoggedExec) + stop.configure { + onlyIf { fixture.pidFile.exists() } + doFirst { + logger.info("Shutting down ${fixture.name} with pid ${pid}") + } + + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + executable = 'Taskkill' + args('/PID', pid, '/F') + } else { + executable = 'kill' + args('-9', pid) + } + doLast { + project.delete(fixture.pidFile) + } + } + return stop } diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/TestWithDependenciesPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/TestWithDependenciesPlugin.groovy index 35c143c1421ac..cbf3f172e620a 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/TestWithDependenciesPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/TestWithDependenciesPlugin.groovy @@ -58,10 +58,12 @@ class TestWithDependenciesPlugin implements Plugin { String outputDir = "${project.buildDir}/generated-resources/${pluginProject.name}" String camelName = pluginProject.name.replaceAll(/-(\w)/) { _, c -> c.toUpperCase(Locale.ROOT) } String taskName = "copy" + camelName[0].toUpperCase(Locale.ROOT) + camelName.substring(1) + "Metadata" - Copy copyPluginMetadata = project.tasks.create(taskName, Copy.class) - copyPluginMetadata.into(outputDir) - copyPluginMetadata.from(pluginProject.tasks.pluginProperties) - copyPluginMetadata.from(pluginProject.file('src/main/plugin-metadata')) + project.tasks.register(taskName, Copy.class) { + into(outputDir) + from(pluginProject.tasks.pluginProperties) + from(pluginProject.file('src/main/plugin-metadata')) + } + project.sourceSets.test.output.dir(outputDir, builtBy: taskName) } } diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/ExportElasticsearchBuildResourcesTaskIT.java b/buildSrc/src/test/java/org/elasticsearch/gradle/ExportElasticsearchBuildResourcesTaskIT.java index cd84920907887..7cd38e6a6f896 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/ExportElasticsearchBuildResourcesTaskIT.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/ExportElasticsearchBuildResourcesTaskIT.java @@ -32,12 +32,16 @@ public void testUpToDateWithSourcesConfigured() { BuildResult result = getGradleRunner(PROJECT_NAME).withArguments("buildResources", "-s", "-i").build(); assertTaskSuccessful(result, ":buildResources"); assertBuildFileExists(result, PROJECT_NAME, "build-tools-exported/checkstyle.xml"); - assertBuildFileExists(result, PROJECT_NAME, "build-tools-exported/checkstyle_suppressions.xml"); + + // using task avoidance api means the task configuration of the sample task is never triggered + assertBuildFileDoesNotExists(result, PROJECT_NAME, "build-tools-exported/checkstyle_suppressions.xml"); result = getGradleRunner(PROJECT_NAME).withArguments("buildResources", "-s", "-i").build(); assertTaskUpToDate(result, ":buildResources"); assertBuildFileExists(result, PROJECT_NAME, "build-tools-exported/checkstyle.xml"); - assertBuildFileExists(result, PROJECT_NAME, "build-tools-exported/checkstyle_suppressions.xml"); + + // using task avoidance api means the task configuration of the sample task is never triggered + assertBuildFileDoesNotExists(result, PROJECT_NAME, "build-tools-exported/checkstyle_suppressions.xml"); } public void testImplicitTaskDependencyCopy() { @@ -46,8 +50,10 @@ public void testImplicitTaskDependencyCopy() { assertTaskSuccessful(result, ":buildResources"); assertTaskSuccessful(result, ":sampleCopyAll"); assertBuildFileExists(result, PROJECT_NAME, "sampleCopyAll/checkstyle.xml"); - // This is a side effect of compile time reference - assertBuildFileExists(result, PROJECT_NAME, "sampleCopyAll/checkstyle_suppressions.xml"); + + // using task avoidance api means the task configuration of the sample task is never triggered + // which means buildResource is not configured to copy this file + assertBuildFileDoesNotExists(result, PROJECT_NAME, "sampleCopyAll/checkstyle_suppressions.xml"); } public void testImplicitTaskDependencyInputFileOfOther() { diff --git a/buildSrc/src/test/java/org/elasticsearch/gradle/precommit/ThirdPartyAuditTaskIT.java b/buildSrc/src/test/java/org/elasticsearch/gradle/precommit/ThirdPartyAuditTaskIT.java index f2354e0fffc34..e5a19b072537f 100644 --- a/buildSrc/src/test/java/org/elasticsearch/gradle/precommit/ThirdPartyAuditTaskIT.java +++ b/buildSrc/src/test/java/org/elasticsearch/gradle/precommit/ThirdPartyAuditTaskIT.java @@ -27,13 +27,13 @@ public class ThirdPartyAuditTaskIT extends GradleIntegrationTestCase { @Before public void setUp() throws Exception { // Build the sample jars - getGradleRunner("thirdPartyAudit").withArguments("build", "-s").build(); + getGradleRunner("thirdPartyAudit").withArguments(":sample_jars:build", "-s").build(); } public void testElasticsearchIgnored() { BuildResult result = getGradleRunner("thirdPartyAudit").withArguments( - "clean", - "empty", + ":clean", + ":empty", "-s", "-PcompileOnlyGroup=elasticsearch.gradle:broken-log4j", "-PcompileOnlyVersion=0.0.1", @@ -44,9 +44,9 @@ public void testElasticsearchIgnored() { } public void testWithEmptyRules() { - BuildResult result = getGradleRunner("thirdPartyAudit").withArguments( - "clean", - "empty", + getGradleRunner("thirdPartyAudit").withArguments( + ":clean", + ":empty", "-s", "-PcompileOnlyGroup=other.gradle:broken-log4j", "-PcompileOnlyVersion=0.0.1", @@ -57,8 +57,8 @@ public void testWithEmptyRules() { public void testViolationFoundAndCompileOnlyIgnored() { BuildResult result = getGradleRunner("thirdPartyAudit").withArguments( - "clean", - "absurd", + ":clean", + ":absurd", "-s", "-PcompileOnlyGroup=other.gradle:broken-log4j", "-PcompileOnlyVersion=0.0.1", @@ -73,8 +73,8 @@ public void testViolationFoundAndCompileOnlyIgnored() { public void testClassNotFoundAndCompileOnlyIgnored() { BuildResult result = getGradleRunner("thirdPartyAudit").withArguments( - "clean", - "absurd", + ":clean", + ":absurd", "-s", "-PcompileGroup=other.gradle:broken-log4j", "-PcompileVersion=0.0.1", @@ -94,8 +94,8 @@ public void testClassNotFoundAndCompileOnlyIgnored() { public void testJarHellWithJDK() { BuildResult result = getGradleRunner("thirdPartyAudit").withArguments( - "clean", - "absurd", + ":clean", + ":absurd", "-s", "-PcompileGroup=other.gradle:jarhellJdk", "-PcompileVersion=0.0.1", @@ -115,8 +115,8 @@ public void testJarHellWithJDK() { public void testElasticsearchIgnoredWithViolations() { BuildResult result = getGradleRunner("thirdPartyAudit").withArguments( - "clean", - "absurd", + ":clean", + ":absurd", "-s", "-PcompileOnlyGroup=elasticsearch.gradle:broken-log4j", "-PcompileOnlyVersion=0.0.1", diff --git a/buildSrc/src/testKit/distribution-download/distribution/build.gradle b/buildSrc/src/testKit/distribution-download/distribution/build.gradle index f375eb3141b46..0d618d4fbe177 100644 --- a/buildSrc/src/testKit/distribution-download/distribution/build.gradle +++ b/buildSrc/src/testKit/distribution-download/distribution/build.gradle @@ -3,10 +3,10 @@ if (distroConfig != null) { // setup the test distribution as an artifact of this project String distroType = System.getProperty('tests.distro.type') - Task buildDistro + def buildDistro File buildFile if (['rpm', 'deb'].contains(distroType)) { - buildDistro = project.tasks.create("build" + distroType.capitalize(), Copy) { + buildDistro = project.tasks.register("build" + distroType.capitalize(), Copy) { from 'files' into 'build/files' include 'fake_elasticsearch.tar.gz' @@ -21,7 +21,7 @@ if (distroConfig != null) { extension = "zip" } // copy file as is - buildDistro = project.tasks.create("buildArchive", Copy) { + buildDistro = project.tasks.register("buildArchive", Copy) { from 'files' include "fake_elasticsearch.${extension}" into 'build/files' diff --git a/buildSrc/src/testKit/distribution-download/subproj/build.gradle b/buildSrc/src/testKit/distribution-download/subproj/build.gradle index 6036faf90a6f5..4f7b1195d200f 100644 --- a/buildSrc/src/testKit/distribution-download/subproj/build.gradle +++ b/buildSrc/src/testKit/distribution-download/subproj/build.gradle @@ -36,7 +36,7 @@ elasticsearch_distributions { } } -task assertDistroFile { +tasks.register("assertDistroFile") { dependsOn elasticsearch_distributions.test_distro doLast { File distroFile = new File(elasticsearch_distributions.test_distro.toString()) @@ -50,7 +50,7 @@ task assertDistroFile { } if (['rpm', 'deb'].contains(distroType) == false) { - task assertDistroExtracted { + tasks.register("assertDistroExtracted") { dependsOn elasticsearch_distributions.test_distro.extracted, assertDistroFile doLast { File distroExtracted = new File(elasticsearch_distributions.test_distro.extracted.toString()) diff --git a/buildSrc/src/testKit/elasticsearch-build-resources/build.gradle b/buildSrc/src/testKit/elasticsearch-build-resources/build.gradle index 741729df6f085..5d94f05c796e4 100644 --- a/buildSrc/src/testKit/elasticsearch-build-resources/build.gradle +++ b/buildSrc/src/testKit/elasticsearch-build-resources/build.gradle @@ -9,13 +9,13 @@ buildResources { copy 'checkstyle.xml' } -task sampleCopyAll(type: Sync) { +tasks.register("sampleCopyAll", Sync) { /** Note: no explicit dependency. This works with tasks that use the Provider API a.k.a "Lazy Configuration" **/ from buildResources into "$buildDir/sampleCopyAll" } -task sample { +tasks.register("sample") { // This does not work, task dependencies can't be providers // dependsOn buildResources.resource('minimumRuntimeVersion') // Nor does this, despite https://github.com/gradle/gradle/issues/3811 @@ -29,7 +29,7 @@ task sample { } } -task noConfigAfterExecution { +tasks.register("noConfigAfterExecution") { dependsOn buildResources doLast { println "This should cause an error because we are refferencing " + diff --git a/buildSrc/src/testKit/elasticsearch.build/build.gradle b/buildSrc/src/testKit/elasticsearch.build/build.gradle index 1341cb9e5f6c7..821fd8a76dfa0 100644 --- a/buildSrc/src/testKit/elasticsearch.build/build.gradle +++ b/buildSrc/src/testKit/elasticsearch.build/build.gradle @@ -30,7 +30,7 @@ loggerUsageCheck.enabled = false // TODO: shouldn't be part of BuildPlugin, should be tested separately validateNebulaPom.enabled = false -task hello { +tasks.register("hello") { doFirst { println "build plugin can be applied" } diff --git a/buildSrc/src/testKit/jdk-download/build.gradle b/buildSrc/src/testKit/jdk-download/build.gradle index ff653354d9e86..aa0e7958d6db7 100644 --- a/buildSrc/src/testKit/jdk-download/build.gradle +++ b/buildSrc/src/testKit/jdk-download/build.gradle @@ -9,7 +9,7 @@ project.gradle.projectsEvaluated { repository.setUrl(fakeJdkRepo) } -task numConfigurations { +tasks.register("numConfigurations") { doLast { println "NUM CONFIGS: ${project.configurations.size()}" } diff --git a/buildSrc/src/testKit/jdk-download/subproj/build.gradle b/buildSrc/src/testKit/jdk-download/subproj/build.gradle index a19a6bead4c7b..ac94a2963a2b5 100644 --- a/buildSrc/src/testKit/jdk-download/subproj/build.gradle +++ b/buildSrc/src/testKit/jdk-download/subproj/build.gradle @@ -26,21 +26,21 @@ jdks { } } -task getLinuxJdk { +tasks.register("getLinuxJdk") { dependsOn jdks.linux doLast { println "JDK HOME: " + jdks.linux } } -task getDarwinJdk { +tasks.register("getDarwinJdk") { dependsOn jdks.darwin doLast { println "JDK HOME: " + jdks.darwin } } -task getWindowsJdk { +tasks.register("getWindowsJdk") { dependsOn jdks.windows doLast { println "JDK HOME: " + jdks.windows diff --git a/buildSrc/src/testKit/reaper/build.gradle b/buildSrc/src/testKit/reaper/build.gradle index 2ee2cb6a38b88..133f1a66d4e33 100644 --- a/buildSrc/src/testKit/reaper/build.gradle +++ b/buildSrc/src/testKit/reaper/build.gradle @@ -2,7 +2,7 @@ plugins { id 'elasticsearch.reaper' } -task launchReaper { +tasks.register("launchReaper") { doLast { def reaper = project.extensions.getByName('reaper') reaper.registerCommand('test', 'true') diff --git a/buildSrc/src/testKit/symbolic-link-preserving-tar/build.gradle b/buildSrc/src/testKit/symbolic-link-preserving-tar/build.gradle index 0075dad46ff79..d61e9cf879d0f 100644 --- a/buildSrc/src/testKit/symbolic-link-preserving-tar/build.gradle +++ b/buildSrc/src/testKit/symbolic-link-preserving-tar/build.gradle @@ -23,7 +23,7 @@ switch (testPreserveFileTimestamps) { + testPreserveFileTimestamps + "]") } -task buildBZip2Tar(type: SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar tar -> +tasks.register("buildBZip2Tar", SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar tar -> tar.archiveExtension = 'tar.bz2' tar.compression = Compression.BZIP2 tar.preserveFileTimestamps = preserveFileTimestamps @@ -33,7 +33,7 @@ task buildBZip2Tar(type: SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar } } -task buildGZipTar(type: SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar tar -> +tasks.register("buildGZipTar", SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar tar -> tar.archiveExtension = 'tar.gz' tar.compression = Compression.GZIP tar.preserveFileTimestamps = preserveFileTimestamps @@ -43,7 +43,7 @@ task buildGZipTar(type: SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar t } } -task buildTar(type: SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar tar -> +tasks.register("buildTar", SymbolicLinkPreservingTar) { SymbolicLinkPreservingTar tar -> tar.archiveExtension = 'tar' tar.preserveFileTimestamps = preserveFileTimestamps from fileTree(source) diff --git a/buildSrc/src/testKit/testingConventions/build.gradle b/buildSrc/src/testKit/testingConventions/build.gradle index fa677142e9a6a..877f98eed9d2d 100644 --- a/buildSrc/src/testKit/testingConventions/build.gradle +++ b/buildSrc/src/testKit/testingConventions/build.gradle @@ -28,9 +28,7 @@ allprojects { } project(':empty_test_task') { - task emptyTest(type: Test) { - - } + tasks.register("emptyTest", Test) } project(':all_classes_in_tasks') { diff --git a/buildSrc/src/testKit/thirdPartyAudit/build.gradle b/buildSrc/src/testKit/thirdPartyAudit/build.gradle index 629460c2627c1..47818ffcd6194 100644 --- a/buildSrc/src/testKit/thirdPartyAudit/build.gradle +++ b/buildSrc/src/testKit/thirdPartyAudit/build.gradle @@ -23,7 +23,7 @@ repositories { jcenter() } -configurations.create("forbiddenApisCliJar") +configurations.register("forbiddenApisCliJar") dependencies { forbiddenApisCliJar 'de.thetaphi:forbiddenapis:2.7' @@ -31,12 +31,12 @@ dependencies { compile "org.${project.properties.compileGroup}:${project.properties.compileVersion}" } -task empty(type: ThirdPartyAuditTask) { +tasks.register("empty", ThirdPartyAuditTask) { targetCompatibility = JavaVersion.VERSION_11 signatureFile = file('third-party-audit-empty.txt') } -task absurd(type: ThirdPartyAuditTask) { +tasks.register("absurd", ThirdPartyAuditTask) { targetCompatibility = JavaVersion.VERSION_11 signatureFile = file('third-party-audit-absurd.txt') } diff --git a/buildSrc/src/testKit/thirdPartyAudit/sample_jars/build.gradle b/buildSrc/src/testKit/thirdPartyAudit/sample_jars/build.gradle index 23f08e6b4e935..a09f425a6c038 100644 --- a/buildSrc/src/testKit/thirdPartyAudit/sample_jars/build.gradle +++ b/buildSrc/src/testKit/thirdPartyAudit/sample_jars/build.gradle @@ -8,14 +8,11 @@ dependencies { compile 'org.apache.logging.log4j:log4j-core:2.11.1' } -// Tests have to clean mid-test but we don't want the sample jars to go away -clean.enabled = false - ["0.0.1", "0.0.2"].forEach { v -> ["elasticsearch", "other"].forEach { p -> - task "dummy-${p}-${v}"(type: Jar) { + tasks.register("dummy-${p}-${v}", Jar) { destinationDir = file("${buildDir}/testrepo/org/${p}/gradle/dummy-io/${v}/") - archiveName = "dummy-io-${v}.jar" + archiveFileName = "dummy-io-${v}.jar" from sourceSets.main.output include "**/TestingIO.class" if (v == "0.0.2") { @@ -32,9 +29,9 @@ clean.enabled = false ["0.0.1"].forEach { v -> ["elasticsearch", "other"].forEach { p -> - task "broken-log4j-${p}-${v}"(type: Jar) { + tasks.register("broken-log4j-${p}-${v}", Jar) { destinationDir = file("${buildDir}/testrepo/org/${p}/gradle/broken-log4j/${v}/") - archiveName = "broken-log4j-${v}.jar" + archiveFileName = "broken-log4j-${v}.jar" from sourceSets.main.output include "**/TestingLog4j.class" } @@ -42,11 +39,11 @@ clean.enabled = false } } -task jarhellJdk(type: Jar) { +tasks.register("jarhellJdk", Jar) { destinationDir = file("${buildDir}/testrepo/org/other/gradle/jarhellJdk/0.0.1/") - archiveName = "jarhellJdk-0.0.1.jar" + archiveFileName = "jarhellJdk-0.0.1.jar" from sourceSets.main.output include "**/String.class" into "java/lang" - build.dependsOn("jarhellJdk") } +build.dependsOn("jarhellJdk") diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index b42eedfcce12f..ee00629dcaf0c 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -157,7 +157,7 @@ BuildParams.bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInf Closure createRunBwcGradleTask = { name, extraConfig -> - return tasks.create(name: "$name", type: LoggedExec) { + return tasks.register("$name", LoggedExec) { dependsOn checkoutBwcBranch spoolOutput = true workingDir = checkoutDir @@ -225,10 +225,11 @@ BuildParams.bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInf return "buildBwc${projectName.replaceAll(/-\w/) { it[1].toUpperCase() }.capitalize()}" } - task buildBwc {} + def buildBwc = tasks.register("buildBwc"); Closure createBuildBwcTask = { projectName, projectDir, projectArtifact -> - Task bwcTask = createRunBwcGradleTask(buildBwcTaskName(projectName)) { + def bwcTaskName = buildBwcTaskName(projectName) + createRunBwcGradleTask(bwcTaskName) { inputs.file("${project.buildDir}/refspec") outputs.files(projectArtifact) outputs.cacheIf("BWC distribution caching is disabled on 'master' branch") { @@ -245,7 +246,9 @@ BuildParams.bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInf } } } - buildBwc.dependsOn bwcTask + buildBwc.configure { + dependsOn(bwcTaskName) + } } Map artifactFiles = [:] diff --git a/plugins/examples/rest-handler/build.gradle b/plugins/examples/rest-handler/build.gradle index 12f3c0e095335..a75c730668387 100644 --- a/plugins/examples/rest-handler/build.gradle +++ b/plugins/examples/rest-handler/build.gradle @@ -32,7 +32,7 @@ esplugin { // No unit tests in this example test.enabled = false -task exampleFixture(type: org.elasticsearch.gradle.test.AntFixture) { +tasks.register("exampleFixture", org.elasticsearch.gradle.test.AntFixture) { dependsOn testClasses env 'CLASSPATH', "${-> project.sourceSets.test.runtimeClasspath.asPath}" executable = "${BuildParams.runtimeJavaHome}/bin/java" diff --git a/plugins/repository-hdfs/build.gradle b/plugins/repository-hdfs/build.gradle index 149b3b0dbb267..9ea36caedb38f 100644 --- a/plugins/repository-hdfs/build.gradle +++ b/plugins/repository-hdfs/build.gradle @@ -98,7 +98,7 @@ String krb5conf = project(':test:fixtures:krb5kdc-fixture').ext.krb5Conf("hdfs") // Create HDFS File System Testing Fixtures for HA/Secure combinations for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture', 'secureHaHdfsFixture']) { - project.tasks.create(fixtureName, org.elasticsearch.gradle.test.AntFixture) { + def tsk = project.tasks.register(fixtureName, org.elasticsearch.gradle.test.AntFixture) { dependsOn project.configurations.hdfsFixture, project(':test:fixtures:krb5kdc-fixture').tasks.postProcessFixture executable = "${BuildParams.runtimeJavaHome}/bin/java" env 'CLASSPATH', "${-> project.configurations.hdfsFixture.asPath}" @@ -137,6 +137,10 @@ for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture', args miniHDFSArgs.toArray() } + + // TODO: The task configuration block has side effects that require it currently to be always executed. + // Otherwise tests start failing. Therefore we enforce the task creation for now. + tsk.get() } Set disabledIntegTestTaskNames = [] diff --git a/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle b/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle index 4ccc22cda821a..76d068b153d76 100644 --- a/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle +++ b/x-pack/qa/rolling-upgrade-multi-cluster/build.gradle @@ -55,20 +55,20 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { for (kind in ["follower", "leader"]) { // Attention!! Groovy trap: do not pass `kind` to a closure - tasks.create("${baseName}#${kind}#clusterTest", RestTestRunnerTask) { + tasks.register("${baseName}#${kind}#clusterTest", RestTestRunnerTask) { systemProperty 'tests.rest.upgrade_state', 'none' systemProperty 'tests.rest.cluster_name', kind ext.kindExt = kind } - tasks.create("${baseName}#${kind}#oneThirdUpgradedTest", RestTestRunnerTask) { + tasks.register("${baseName}#${kind}#oneThirdUpgradedTest", RestTestRunnerTask) { systemProperty 'tests.rest.upgrade_state', 'one_third' systemProperty 'tests.rest.cluster_name', kind dependsOn "${baseName}#leader#clusterTest", "${baseName}#follower#clusterTest" ext.kindExt = kind } - tasks.create("${baseName}#${kind}#twoThirdsUpgradedTest", RestTestRunnerTask) { + tasks.register("${baseName}#${kind}#twoThirdsUpgradedTest", RestTestRunnerTask) { systemProperty 'tests.rest.upgrade_state', 'two_third' systemProperty 'tests.rest.cluster_name', kind dependsOn "${baseName}#${kind}#oneThirdUpgradedTest"