diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy index ef5392156f3..5e36d34424c 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy @@ -24,6 +24,7 @@ import org.elasticsearch.gradle.VersionProperties import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task +import org.gradle.api.tasks.TaskProvider /** * Sets up tests for documentation. @@ -42,7 +43,7 @@ class DocsTestPlugin implements Plugin { project.testClusters.integTest.nameCustomization = { it.replace("integTest", "node") } // Docs are published separately so no need to assemble project.tasks.assemble.enabled = false - Map defaultSubstitutions = [ + Map commonDefaultSubstitutions = [ /* These match up with the asciidoc syntax for substitutions but * the values may differ. In particular {version} needs to resolve * to the version being built for testing but needs to resolve to @@ -53,26 +54,26 @@ class DocsTestPlugin implements Plugin { '\\{build_flavor\\}' : distribution, '\\{build_type\\}' : OS.conditionalString().onWindows({"zip"}).onUnix({"tar"}).supply(), ] - Task listSnippets = project.tasks.create('listSnippets', SnippetsTask) - listSnippets.group 'Docs' - listSnippets.description 'List each snippet' - listSnippets.defaultSubstitutions = defaultSubstitutions - listSnippets.perSnippet { println(it.toString()) } - - Task listConsoleCandidates = project.tasks.create( - 'listConsoleCandidates', SnippetsTask) - listConsoleCandidates.group 'Docs' - listConsoleCandidates.description - 'List snippets that probably should be marked // CONSOLE' - listConsoleCandidates.defaultSubstitutions = defaultSubstitutions - listConsoleCandidates.perSnippet { - if (RestTestsFromSnippetsTask.isConsoleCandidate(it)) { - println(it.toString()) + project.tasks.register('listSnippets', SnippetsTask) { + group 'Docs' + description 'List each snippet' + defaultSubstitutions = commonDefaultSubstitutions + perSnippet { println(it.toString()) } + } + project.tasks.register('listConsoleCandidates', SnippetsTask) { + group 'Docs' + description + 'List snippets that probably should be marked // CONSOLE' + defaultSubstitutions = commonDefaultSubstitutions + perSnippet { + if (RestTestsFromSnippetsTask.isConsoleCandidate(it)) { + println(it.toString()) + } } } - Task buildRestTests = project.tasks.create( - 'buildRestTests', RestTestsFromSnippetsTask) - buildRestTests.defaultSubstitutions = defaultSubstitutions + project.tasks.register('buildRestTests', RestTestsFromSnippetsTask) { + defaultSubstitutions = commonDefaultSubstitutions + } } } diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy index 818974eb701..0a1bf99da05 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy @@ -67,7 +67,9 @@ class PluginBuildPlugin implements Plugin { createIntegTestTask(project) createBundleTasks(project, extension) - project.tasks.integTest.dependsOn(project.tasks.bundlePlugin) + project.tasks.named("integTest").configure { + it.dependsOn(project.tasks.named("bundlePlugin")) + } if (isModule) { project.testClusters.integTest.module(project.tasks.bundlePlugin.archiveFile) } else { @@ -80,7 +82,7 @@ class PluginBuildPlugin implements Plugin { if (project.findProject(":modules:${pluginName}") != null) { project.integTest.dependsOn(project.project(":modules:${pluginName}").tasks.bundlePlugin) project.testClusters.integTest.module( - project.project(":modules:${pluginName}").tasks.bundlePlugin.archiveFile + project.project(":modules:${pluginName}").tasks.bundlePlugin.archiveFile ) } } @@ -101,15 +103,15 @@ class PluginBuildPlugin implements Plugin { } Map properties = [ - 'name' : extension1.name, - 'description' : extension1.description, - 'version' : extension1.version, - 'elasticsearchVersion': Version.fromString(VersionProperties.elasticsearch).toString(), - 'javaVersion' : project.targetCompatibility as String, - 'classname' : extension1.classname, - 'extendedPlugins' : extension1.extendedPlugins.join(','), - 'hasNativeController' : extension1.hasNativeController, - 'requiresKeystore' : extension1.requiresKeystore + 'name' : extension1.name, + 'description' : extension1.description, + 'version' : extension1.version, + 'elasticsearchVersion': Version.fromString(VersionProperties.elasticsearch).toString(), + 'javaVersion' : project.targetCompatibility as String, + 'classname' : extension1.classname, + 'extendedPlugins' : extension1.extendedPlugins.join(','), + 'hasNativeController' : extension1.hasNativeController, + 'requiresKeystore' : extension1.requiresKeystore ] project.tasks.named('pluginProperties').configure { expand(properties) @@ -142,7 +144,7 @@ class PluginBuildPlugin implements Plugin { } } project.configurations.getByName('default') - .extendsFrom(project.configurations.getByName('runtimeClasspath')) + .extendsFrom(project.configurations.getByName('runtimeClasspath')) // allow running ES with this plugin in the foreground of a build project.tasks.register('run', RunTask) { dependsOn(project.tasks.bundlePlugin) @@ -235,7 +237,7 @@ class PluginBuildPlugin implements Plugin { */ from { project.plugins.hasPlugin(ShadowPlugin) ? project.shadowJar : project.jar } from project.configurations.runtimeClasspath - project.configurations.getByName( - CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME + CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME ) // extra files for the plugin to go into the zip from('src/main/packaging') // TODO: move all config/bin/_size/etc into packaging diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/StandaloneRestTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/StandaloneRestTestPlugin.groovy index a8d19582181..3c531b00d37 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/StandaloneRestTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/StandaloneRestTestPlugin.groovy @@ -62,7 +62,7 @@ class StandaloneRestTestPlugin implements Plugin { project.pluginManager.apply(TestClustersPlugin) project.pluginManager.apply(RepositoriesSetupPlugin) - project.getTasks().create("buildResources", ExportElasticsearchBuildResourcesTask) + project.getTasks().register("buildResources", ExportElasticsearchBuildResourcesTask) ElasticsearchJavaPlugin.configureTestTasks(project) ElasticsearchJavaPlugin.configureInputNormalization(project) ElasticsearchJavaPlugin.configureCompile(project) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java index 663684e41ae..de027fa8ef6 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/TestClustersPlugin.java @@ -114,12 +114,15 @@ public class TestClustersPlugin implements Plugin { } private void createListClustersTask(Project project, NamedDomainObjectContainer container) { - Task listTask = project.getTasks().create(LIST_TASK_NAME); - listTask.setGroup("ES cluster formation"); - listTask.setDescription("Lists all ES clusters configured for this project"); - listTask.doLast( - (Task task) -> container.forEach(cluster -> logger.lifecycle(" * {}: {}", cluster.getName(), cluster.getNumberOfNodes())) - ); + // Task is never up to date so we can pass an lambda for the task action + project.getTasks().register(LIST_TASK_NAME, task -> { + task.setGroup("ES cluster formation"); + task.setDescription("Lists all ES clusters configured for this project"); + task.doLast( + (Task t) -> container.forEach(cluster -> logger.lifecycle(" * {}: {}", cluster.getName(), cluster.getNumberOfNodes())) + ); + }); + } static class TestClustersHookPlugin implements Plugin { diff --git a/distribution/build.gradle b/distribution/build.gradle index e3f9b182a6e..5f224f153ba 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -54,23 +54,23 @@ tasks.register("generateDependenciesReport", ConcatFilesTask) { *****************************************************************************/ // integ test zip only uses server, so a different notice file is needed there -task buildServerNotice(type: NoticeTask) +tasks.register("buildServerNotice", NoticeTask) // other distributions include notices from modules as well, which are added below later -task buildDefaultNotice(type: NoticeTask) { +tasks.register("buildDefaultNotice", NoticeTask).configure { licensesDir new File(project(':distribution').projectDir, 'licenses') } -task buildOssNotice(type: NoticeTask) { +tasks.register("buildOssNotice", NoticeTask).configure { licensesDir new File(project(':distribution').projectDir, 'licenses') } -task buildDefaultNoJdkNotice(type: NoticeTask) +tasks.register("buildDefaultNoJdkNotice", NoticeTask) -task buildOssNoJdkNotice(type: NoticeTask) +tasks.register("buildOssNoJdkNotice", NoticeTask) // The :server and :libs projects belong to all distributions -tasks.withType(NoticeTask) { +tasks.withType(NoticeTask).configureEach { licensesDir project(':server').file('licenses') source project(':server').file('src/main/java') project(':libs').subprojects.each { Project lib -> diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index eb9ac6cfd3d..0ebd18123f5 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -42,8 +42,9 @@ BuildParams.bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInf String bwcBranch = unreleasedVersion.branch apply plugin: 'distribution' // Not published so no need to assemble - assemble.enabled = false - + tasks.named("assemble").configure { + enabled = false + } File checkoutDir = file("${buildDir}/bwc/checkout-${bwcBranch}") final String remote = System.getProperty("bwc.remote", "elastic") @@ -58,13 +59,13 @@ BuildParams.bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInf throw new GradleException("tests.bwc.git_fetch_latest must be [true] or [false] but was [" + gitFetchLatestProperty + "]") } - task createClone(type: LoggedExec) { + tasks.register("createClone", LoggedExec) { onlyIf { checkoutDir.exists() == false } commandLine = ['git', 'clone', rootDir, checkoutDir] } - task findRemote(type: LoggedExec) { - dependsOn createClone + tasks.register("findRemote", LoggedExec) { + dependsOn "createClone" workingDir = checkoutDir commandLine = ['git', 'remote', '-v'] ByteArrayOutputStream output = new ByteArrayOutputStream() @@ -79,16 +80,16 @@ BuildParams.bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInf } } - task addRemote(type: LoggedExec) { + tasks.register("addRemote", LoggedExec) { dependsOn findRemote onlyIf { project.ext.remoteExists == false } workingDir = checkoutDir commandLine = ['git', 'remote', 'add', "${remote}", "https://github.com/${remote}/elasticsearch.git"] } - task fetchLatest(type: LoggedExec) { + tasks.register("fetchLatest", LoggedExec) { onlyIf { project.gradle.startParameter.isOffline() == false && gitFetchLatest } - dependsOn addRemote + dependsOn("addRemote") workingDir = checkoutDir commandLine = ['git', 'fetch', '--all'] } @@ -104,8 +105,8 @@ BuildParams.bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInf return os.toString().trim() } } - task checkoutBwcBranch() { - dependsOn fetchLatest + tasks.register("checkoutBwcBranch") { + dependsOn("fetchLatest") doLast { def refspec = System.getProperty("bwc.refspec." + bwcBranch) ?: System.getProperty("tests.bwc.refspec." + bwcBranch) ?: "${remote}/${bwcBranch}" if (System.getProperty("bwc.checkout.align") != null) { @@ -156,9 +157,9 @@ BuildParams.bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInf } - Closure createRunBwcGradleTask = { name, extraConfig -> + Closure createRunBwcGradleTask = { name, extraConfig -> return tasks.register("$name", LoggedExec) { - dependsOn checkoutBwcBranch + dependsOn "checkoutBwcBranch" spoolOutput = true workingDir = checkoutDir doFirst { @@ -304,7 +305,9 @@ BuildParams.bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInf Version currentVersion = Version.fromString(version) if (currentVersion.getMinor() == 0 && currentVersion.getRevision() == 0) { // We only want to resolve dependencies for live versions of master, without cascading this to older versions - resolveAllDependencies.dependsOn resolveAllBwcDependencies + tasks.named("resolveAllDependencies").configure { + dependsOn("resolveAllBwcDependencies") + } } for (e in artifactFiles) { @@ -326,7 +329,9 @@ BuildParams.bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInf } } // make sure no dependencies were added to assemble; we want it to be a no-op - assemble.dependsOn = [] + tasks.named("assemble").configure { + dependsOn = [] + } } } diff --git a/distribution/docker/build.gradle b/distribution/docker/build.gradle index 34f78f3206e..697543a1d5f 100644 --- a/distribution/docker/build.gradle +++ b/distribution/docker/build.gradle @@ -109,7 +109,7 @@ project.ext { } void addCopyDockerContextTask(final String architecture, final boolean oss) { - task(taskName("copy", architecture, oss, "DockerContext"), type: Sync) { + tasks.register(taskName("copy", architecture, oss, "DockerContext"), Sync) { expansions(architecture, oss, true).findAll { it.key != 'build_date' }.each { k, v -> inputs.property(k, { v.toString() }) } @@ -143,7 +143,7 @@ def createAndSetWritable(Object... locations) { } } -task copyKeystore(type: Sync) { +tasks.register("copyKeystore", Sync) { from project(':x-pack:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') into "${buildDir}/certs" @@ -167,9 +167,9 @@ elasticsearch_distributions { } } -preProcessFixture { +tasks.named("preProcessFixture").configure { dependsOn elasticsearch_distributions.docker_default, elasticsearch_distributions.docker_oss - dependsOn copyKeystore + dependsOn "copyKeystore" doLast { // tests expect to have an empty repo project.delete( @@ -187,21 +187,25 @@ preProcessFixture { } } -processTestResources { +tasks.named("processTestResources").configure { from project(':x-pack:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') } -task integTest(type: Test) { +tasks.register("integTest", Test) { outputs.doNotCacheIf('Build cache is disabled for Docker tests') { true } maxParallelForks = '1' include '**/*IT.class' } -check.dependsOn integTest +tasks.named("check").configure { + dependsOn "integTest" +} void addBuildDockerImage(final String architecture, final boolean oss) { - final Task buildDockerImageTask = task(taskName("build", architecture, oss, "DockerImage"), type: DockerBuildTask) { + final TaskProvider buildDockerImageTask = + tasks.register(taskName("build", architecture, oss, "DockerImage"), DockerBuildTask) { + onlyIf { Architecture.current().name().toLowerCase().equals(architecture) } TaskProvider copyContextTask = tasks.named(taskName("copy", architecture, oss, "DockerContext")) dependsOn(copyContextTask) dockerContext.fileProvider(copyContextTask.map { it.destinationDir }) @@ -220,8 +224,9 @@ void addBuildDockerImage(final String architecture, final boolean oss) { ] } } - buildDockerImageTask.onlyIf { Architecture.current().name().toLowerCase().equals(architecture) } - assemble.dependsOn(buildDockerImageTask) + tasks.named("assemble").configure { + dependsOn(buildDockerImageTask) + } } for (final String architecture : ["aarch64", "x64"]) { @@ -253,7 +258,7 @@ subprojects { Project subProject -> def buildTaskName = taskName("build", architecture, oss, "DockerImage") def tarFile = "${parent.projectDir}/build/elasticsearch${"aarch64".equals(architecture) ? '-aarch64' : ''}${oss ? '-oss' : ''}_test.${VersionProperties.elasticsearch}.docker.tar" - final Task exportDockerImageTask = task(exportTaskName, type: LoggedExec) { + final TaskProvider exportDockerImageTask = tasks.register(exportTaskName, LoggedExec) { inputs.file("${parent.projectDir}/build/markers/${buildTaskName}.marker") executable 'docker' outputs.file(tarFile) @@ -261,18 +266,19 @@ subprojects { Project subProject -> "-o", tarFile, "elasticsearch${oss ? '-oss' : ''}:test" + + dependsOn(parent.path + ":" + buildTaskName) + onlyIf { Architecture.current().name().toLowerCase().equals(architecture) } } - exportDockerImageTask.dependsOn(parent.tasks.getByName(buildTaskName)) - - exportDockerImageTask.onlyIf { Architecture.current().name().toLowerCase().equals(architecture) } - artifacts.add('default', file(tarFile)) { type 'tar' name "elasticsearch${"aarch64".equals(architecture) ? '-aarch64' : ''}${oss ? '-oss' : ''}" builtBy exportTaskName } - assemble.dependsOn exportTaskName + tasks.named("assemble").configure { + dependsOn(exportTaskName) + } } } diff --git a/distribution/docker/docker-build-context/build.gradle b/distribution/docker/docker-build-context/build.gradle index b641e697c4a..dc61d46bfd2 100644 --- a/distribution/docker/docker-build-context/build.gradle +++ b/distribution/docker/docker-build-context/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'base' -task buildDockerBuildContext(type: Tar) { +tasks.register("buildDockerBuildContext", Tar) { archiveExtension = 'tar.gz' compression = Compression.GZIP archiveClassifier = "docker-build-context" @@ -10,4 +10,4 @@ task buildDockerBuildContext(type: Tar) { with dockerBuildContext("", false, false) } -assemble.dependsOn buildDockerBuildContext +tasks.named("assemble").configure {dependsOn "buildDockerBuildContext"} diff --git a/distribution/docker/oss-docker-build-context/build.gradle b/distribution/docker/oss-docker-build-context/build.gradle index a3603254d13..819d3813ace 100644 --- a/distribution/docker/oss-docker-build-context/build.gradle +++ b/distribution/docker/oss-docker-build-context/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'base' -task buildOssDockerBuildContext(type: Tar) { +tasks.register("buildOssDockerBuildContext", Tar) { archiveExtension = 'tar.gz' compression = Compression.GZIP archiveClassifier = "docker-build-context" @@ -10,4 +10,4 @@ task buildOssDockerBuildContext(type: Tar) { with dockerBuildContext("", true, false) } -assemble.dependsOn buildOssDockerBuildContext +tasks.named("assemble").configure { dependsOn "buildOssDockerBuildContext" } diff --git a/distribution/packages/build.gradle b/distribution/packages/build.gradle index f6e3934d127..aa76e569f3c 100644 --- a/distribution/packages/build.gradle +++ b/distribution/packages/build.gradle @@ -59,7 +59,7 @@ void addProcessFilesTask(String type, boolean oss, boolean jdk) { String packagingFiles = "build/packaging/${oss ? 'oss-' : ''}${jdk ? '' : 'no-jdk-'}${type}" String taskName = "process${oss ? 'Oss' : ''}${jdk ? '' : 'NoJdk'}${type.capitalize()}Files" - task(taskName, type: Copy) { + tasks.register(taskName, Copy) { into packagingFiles with copySpec { @@ -464,15 +464,15 @@ subprojects { } } - check.dependsOn checkExtraction + tasks.named("check").configure { dependsOn "checkExtraction" } if (project.name.contains('deb')) { - checkExtraction { + tasks.named("checkExtraction").configure { onlyIf dpkgExists - commandLine 'dpkg-deb', '-x', "${-> buildDist.get()outputs.files.filter(debFilter).singleFile}", packageExtractionDir + commandLine 'dpkg-deb', '-x', "${-> buildDist.get().outputs.files.filter(debFilter).singleFile}", packageExtractionDir } } else { assert project.name.contains('rpm') - checkExtraction { + tasks.named("checkExtraction").configure { onlyIf rpmExists final File rpmDatabase = new File(extractionDir, 'rpm-database') commandLine 'rpm', @@ -491,12 +491,12 @@ subprojects { } } - task checkLicense { - dependsOn buildDist, checkExtraction + tasks.register("checkLicense") { + dependsOn buildDist, "checkExtraction" } - check.dependsOn checkLicense + check.dependsOn "checkLicense" if (project.name.contains('deb')) { - checkLicense { + tasks.named("checkLicense").configure { onlyIf dpkgExists doLast { Path copyrightPath @@ -521,7 +521,7 @@ subprojects { } } else { assert project.name.contains('rpm') - checkLicense { + tasks.named("checkLicense").configure { onlyIf rpmExists doLast { String licenseFilename @@ -537,8 +537,8 @@ subprojects { } } - task checkNotice { - dependsOn buildDist, checkExtraction + tasks.register("checkNotice") { + dependsOn buildDist, "checkExtraction" onlyIf { (project.name.contains('deb') && dpkgExists.call(it)) || (project.name.contains('rpm') && rpmExists.call(it)) } @@ -548,10 +548,10 @@ subprojects { assertLinesInFile(noticePath, noticeLines) } } - check.dependsOn checkNotice + tasks.named("check").configure { dependsOn "checkNotice" } tasks.register('checkLicenseMetadata', LoggedExec) { - dependsOn buildDist, checkExtraction + dependsOn buildDist, "checkExtraction" } check.dependsOn checkLicenseMetadata if (project.name.contains('deb')) { diff --git a/gradle/ide.gradle b/gradle/ide.gradle index 93c8860b4fa..21f6ee7806c 100644 --- a/gradle/ide.gradle +++ b/gradle/ide.gradle @@ -16,7 +16,7 @@ buildscript { allprojects { apply plugin: 'idea' - tasks.named('idea') { + tasks.named('idea').configure { doFirst { throw new GradleException("Use of the 'idea' task has been deprecated. For details on importing into IntelliJ see CONTRIBUTING.md.") } } } diff --git a/modules/ingest-geoip/build.gradle b/modules/ingest-geoip/build.gradle index 1ff036353c0..d0ddd9bcba7 100644 --- a/modules/ingest-geoip/build.gradle +++ b/modules/ingest-geoip/build.gradle @@ -43,40 +43,41 @@ restResources { } } -task copyDefaultGeoIp2DatabaseFiles(type: Copy) { +tasks.register("copyDefaultGeoIp2DatabaseFiles", Copy) { from { zipTree(configurations.testCompileClasspath.files.find { it.name.contains('geolite2-databases') }) } into "${project.buildDir}/ingest-geoip" include "*.mmdb" } -project.bundlePlugin.dependsOn(copyDefaultGeoIp2DatabaseFiles) - -bundlePlugin { +tasks.named("bundlePlugin").configure { + dependsOn("copyDefaultGeoIp2DatabaseFiles") from("${project.buildDir}/ingest-geoip") { into '/' } } -thirdPartyAudit.ignoreMissingClasses( - // geoip WebServiceClient needs apache http client, but we're not using WebServiceClient: - 'org.apache.http.HttpEntity', - 'org.apache.http.HttpHost', - 'org.apache.http.HttpResponse', - 'org.apache.http.StatusLine', - 'org.apache.http.auth.UsernamePasswordCredentials', - 'org.apache.http.client.config.RequestConfig$Builder', - 'org.apache.http.client.config.RequestConfig', - 'org.apache.http.client.methods.CloseableHttpResponse', - 'org.apache.http.client.methods.HttpGet', - 'org.apache.http.client.utils.URIBuilder', - 'org.apache.http.impl.auth.BasicScheme', - 'org.apache.http.impl.client.CloseableHttpClient', - 'org.apache.http.impl.client.HttpClientBuilder', - 'org.apache.http.util.EntityUtils' -) +tasks.named("thirdPartyAudit").configure { + ignoreMissingClasses( + // geoip WebServiceClient needs apache http client, but we're not using WebServiceClient: + 'org.apache.http.HttpEntity', + 'org.apache.http.HttpHost', + 'org.apache.http.HttpResponse', + 'org.apache.http.StatusLine', + 'org.apache.http.auth.UsernamePasswordCredentials', + 'org.apache.http.client.config.RequestConfig$Builder', + 'org.apache.http.client.config.RequestConfig', + 'org.apache.http.client.methods.CloseableHttpResponse', + 'org.apache.http.client.methods.HttpGet', + 'org.apache.http.client.utils.URIBuilder', + 'org.apache.http.impl.auth.BasicScheme', + 'org.apache.http.impl.client.CloseableHttpClient', + 'org.apache.http.impl.client.HttpClientBuilder', + 'org.apache.http.util.EntityUtils' + ) +} -test { - if (Os.isFamily(Os.FAMILY_WINDOWS)) { +if (Os.isFamily(Os.FAMILY_WINDOWS)) { + tasks.named("test").configure { // Windows cannot cleanup database files properly unless it loads everything on heap. // See https://github.com/maxmind/MaxMind-DB-Reader-java#file-lock-on-windows for more information systemProperty 'es.geoip.load_db_on_heap', 'true' diff --git a/modules/lang-painless/build.gradle b/modules/lang-painless/build.gradle index 8f042cafb1e..090e4b232b3 100644 --- a/modules/lang-painless/build.gradle +++ b/modules/lang-painless/build.gradle @@ -56,27 +56,28 @@ restResources { integTest.enabled = false -test { +tasks.named("test").configure { // in WhenThingsGoWrongTests we intentionally generate an out of memory error, this prevents the heap from being dumped to disk jvmArgs '-XX:-OmitStackTraceInFastThrow', '-XX:-HeapDumpOnOutOfMemoryError' } /* Build Javadoc for the Java classes in Painless's public API that are in the * Painless plugin */ -task apiJavadoc(type: Javadoc) { +tasks.register("apiJavadoc", Javadoc) { source = sourceSets.main.allJava classpath = sourceSets.main.runtimeClasspath include '**/org/elasticsearch/painless/api/' destinationDir = new File(docsDir, 'apiJavadoc') } -task apiJavadocJar(type: Jar) { +tasks.register("apiJavadocJar", Jar) { archiveClassifier = 'apiJavadoc' from apiJavadoc } -assemble.dependsOn apiJavadocJar - +tasks.named("assemble").configure { + dependsOn "apiJavadocJar" +} /********************************************** * Context API Generation * **********************************************/ @@ -96,7 +97,7 @@ testClusters { } } -task generateContextDoc(type: DefaultTestClustersTask) { +tasks.register("generateContextDoc", DefaultTestClustersTask) { dependsOn sourceSets.doc.runtimeClasspath useCluster testClusters.generateContextCluster doFirst { @@ -123,7 +124,7 @@ dependencies { String grammarPath = 'src/main/antlr' String outputPath = 'src/main/java/org/elasticsearch/painless/antlr' -task cleanGenerated(type: Delete) { +tasks.register("cleanGenerated", Delete) { delete fileTree(grammarPath) { include '*.tokens' } @@ -132,8 +133,8 @@ task cleanGenerated(type: Delete) { } } -task regenLexer(type: JavaExec) { - dependsOn cleanGenerated +tasks.register("regenLexer", JavaExec) { + dependsOn "cleanGenerated" main = 'org.antlr.v4.Tool' classpath = configurations.regenerate systemProperty 'file.encoding', 'UTF-8' @@ -146,8 +147,8 @@ task regenLexer(type: JavaExec) { "${file(grammarPath)}/PainlessLexer.g4" } -task regenParser(type: JavaExec) { - dependsOn regenLexer +tasks.register("regenParser", JavaExec) { + dependsOn "regenLexer" main = 'org.antlr.v4.Tool' classpath = configurations.regenerate systemProperty 'file.encoding', 'UTF-8' @@ -163,8 +164,8 @@ task regenParser(type: JavaExec) { "${file(grammarPath)}/PainlessParser.g4" } -task regen { - dependsOn regenParser +tasks.register("regen") { + dependsOn "regenParser" doLast { // moves token files to grammar directory for use with IDE's ant.move(file: "${outputPath}/PainlessLexer.tokens", toDir: grammarPath) diff --git a/plugins/discovery-azure-classic/build.gradle b/plugins/discovery-azure-classic/build.gradle index 901fc6cb091..cfcb48841c4 100644 --- a/plugins/discovery-azure-classic/build.gradle +++ b/plugins/discovery-azure-classic/build.gradle @@ -72,7 +72,7 @@ String host = InetAddress.getLoopbackAddress().getHostAddress() File keystore = new File(project.buildDir, 'keystore/test-node.jks') // generate the keystore -task createKey(type: LoggedExec) { +TaskProvider createKey = tasks.register("createKey", LoggedExec) { doFirst { project.delete(keystore.parentFile) keystore.parentFile.mkdirs() @@ -91,9 +91,9 @@ task createKey(type: LoggedExec) { '-storepass', 'keypass' } //no unit tests -test.enabled = false +tasks.named("test").configure { enabled = false } // add keystore to test classpath: it expects it there -processInternalClusterTestResources { +tasks.named("processInternalClusterTestResources").configure { from createKey } @@ -110,7 +110,9 @@ tasks.named("dependencyLicenses").configure { mapping from: /jaxb-.*/, to: 'jaxb' } -thirdPartyAudit.ignoreMissingClasses( + +tasks.named("thirdPartyAudit").configure { + ignoreMissingClasses( 'javax.servlet.ServletContextEvent', 'javax.servlet.ServletContextListener', 'org.apache.avalon.framework.logger.Logger', @@ -147,7 +149,7 @@ thirdPartyAudit.ignoreMissingClasses( // jarhell with jdk (intentionally, because jaxb was removed from default modules in java 9) if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) { - thirdPartyAudit.ignoreJarHellWithJDK( + ignoreJarHellWithJDK( 'javax.xml.bind.Binder', 'javax.xml.bind.ContextFinder$1', 'javax.xml.bind.ContextFinder', @@ -251,14 +253,15 @@ if (BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_1_8) { 'javax.xml.bind.util.ValidationEventCollector' ) } else { - thirdPartyAudit.ignoreMissingClasses( - 'javax.activation.ActivationDataFlavor', - 'javax.activation.DataContentHandler', - 'javax.activation.DataHandler', - 'javax.activation.DataSource', - 'javax.activation.FileDataSource', - 'javax.activation.FileTypeMap', - 'javax.activation.MimeType', - 'javax.activation.MimeTypeParseException', - ) + ignoreMissingClasses( + 'javax.activation.ActivationDataFlavor', + 'javax.activation.DataContentHandler', + 'javax.activation.DataHandler', + 'javax.activation.DataSource', + 'javax.activation.FileDataSource', + 'javax.activation.FileTypeMap', + 'javax.activation.MimeType', + 'javax.activation.MimeTypeParseException', + ) + } } diff --git a/plugins/discovery-ec2/build.gradle b/plugins/discovery-ec2/build.gradle index ad78c177fd8..9baefd13e1f 100644 --- a/plugins/discovery-ec2/build.gradle +++ b/plugins/discovery-ec2/build.gradle @@ -53,13 +53,13 @@ tasks.named("dependencyLicenses").configure { mapping from: /jackson-.*/, to: 'jackson' } -bundlePlugin { +tasks.named("bundlePlugin").configure { from('config/discovery-ec2') { into 'config' } } -task writeTestJavaPolicy { +tasks.register("writeTestJavaPolicy") { doLast { final File tmp = file("${buildDir}/tmp") if (tmp.exists() == false && tmp.mkdirs() == false) { @@ -97,8 +97,8 @@ task writeTestJavaPolicy { } } -test { - dependsOn writeTestJavaPolicy +tasks.named("test").configure { + dependsOn "writeTestJavaPolicy" // this is needed for insecure plugins, remove if possible! systemProperty 'tests.artifact', project.name @@ -113,43 +113,45 @@ test { } } -check { +tasks.named("check").configure { // also execute the QA tests when testing the plugin dependsOn 'qa:amazon-ec2:check' } -thirdPartyAudit.ignoreMissingClasses( - // classes are missing - 'com.amazonaws.jmespath.JmesPathEvaluationVisitor', - 'com.amazonaws.jmespath.JmesPathExpression', - 'com.amazonaws.jmespath.JmesPathField', - 'com.amazonaws.jmespath.JmesPathFlatten', - 'com.amazonaws.jmespath.JmesPathIdentity', - 'com.amazonaws.jmespath.JmesPathLengthFunction', - 'com.amazonaws.jmespath.JmesPathLiteral', - 'com.amazonaws.jmespath.JmesPathProjection', - 'com.amazonaws.jmespath.JmesPathSubExpression', - 'com.amazonaws.jmespath.ObjectMapperSingleton', - 'com.amazonaws.jmespath.OpGreaterThan', - 'software.amazon.ion.IonReader', - 'software.amazon.ion.IonSystem', - 'software.amazon.ion.IonType', - 'software.amazon.ion.IonWriter', - 'software.amazon.ion.Timestamp', - 'software.amazon.ion.system.IonBinaryWriterBuilder', - 'software.amazon.ion.system.IonSystemBuilder', - 'software.amazon.ion.system.IonTextWriterBuilder', - 'software.amazon.ion.system.IonWriterBuilder', - 'javax.servlet.ServletContextEvent', - 'javax.servlet.ServletContextListener', - 'org.apache.avalon.framework.logger.Logger', - 'org.apache.log.Hierarchy', - 'org.apache.log.Logger' -) - -if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { - thirdPartyAudit.ignoreMissingClasses( - 'javax.xml.bind.DatatypeConverter', - 'javax.xml.bind.JAXBContext' +tasks.named("thirdPartyAudit").configure { + ignoreMissingClasses( + // classes are missing + 'com.amazonaws.jmespath.JmesPathEvaluationVisitor', + 'com.amazonaws.jmespath.JmesPathExpression', + 'com.amazonaws.jmespath.JmesPathField', + 'com.amazonaws.jmespath.JmesPathFlatten', + 'com.amazonaws.jmespath.JmesPathIdentity', + 'com.amazonaws.jmespath.JmesPathLengthFunction', + 'com.amazonaws.jmespath.JmesPathLiteral', + 'com.amazonaws.jmespath.JmesPathProjection', + 'com.amazonaws.jmespath.JmesPathSubExpression', + 'com.amazonaws.jmespath.ObjectMapperSingleton', + 'com.amazonaws.jmespath.OpGreaterThan', + 'software.amazon.ion.IonReader', + 'software.amazon.ion.IonSystem', + 'software.amazon.ion.IonType', + 'software.amazon.ion.IonWriter', + 'software.amazon.ion.Timestamp', + 'software.amazon.ion.system.IonBinaryWriterBuilder', + 'software.amazon.ion.system.IonSystemBuilder', + 'software.amazon.ion.system.IonTextWriterBuilder', + 'software.amazon.ion.system.IonWriterBuilder', + 'javax.servlet.ServletContextEvent', + 'javax.servlet.ServletContextListener', + 'org.apache.avalon.framework.logger.Logger', + 'org.apache.log.Hierarchy', + 'org.apache.log.Logger' ) + + if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { + ignoreMissingClasses( + 'javax.xml.bind.DatatypeConverter', + 'javax.xml.bind.JAXBContext' + ) + } } diff --git a/plugins/discovery-gce/qa/gce/build.gradle b/plugins/discovery-gce/qa/gce/build.gradle index d2ee721e0bd..9447d92137e 100644 --- a/plugins/discovery-gce/qa/gce/build.gradle +++ b/plugins/discovery-gce/qa/gce/build.gradle @@ -50,7 +50,7 @@ Map expansions = [ 'expected_nodes': gceNumberOfNodes ] -processYamlRestTestResources { +tasks.named("processYamlRestTestResources").configure { inputs.properties(expansions) MavenFilteringHack.filter(it, expansions) } diff --git a/plugins/repository-s3/build.gradle b/plugins/repository-s3/build.gradle index 40700489eb5..cf35480feb4 100644 --- a/plugins/repository-s3/build.gradle +++ b/plugins/repository-s3/build.gradle @@ -283,7 +283,7 @@ if (useFixture) { } // 3rd Party Tests -task s3ThirdPartyTest(type: Test) { +TaskProvider s3ThirdPartyTest = tasks.register("s3ThirdPartyTest", Test) { SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); SourceSet internalTestSourceSet = sourceSets.getByName(InternalClusterTestPlugin.SOURCE_SET_NAME) setTestClassesDirs(internalTestSourceSet.getOutput().getClassesDirs()) @@ -297,7 +297,7 @@ task s3ThirdPartyTest(type: Test) { nonInputProperties.systemProperty 'test.s3.endpoint', "${-> fixtureAddress('minio-fixture', 'minio-fixture', '9000') }" } } -check.dependsOn(s3ThirdPartyTest) +tasks.named("check").configure { dependsOn(s3ThirdPartyTest) } thirdPartyAudit.ignoreMissingClasses( // classes are missing diff --git a/qa/full-cluster-restart/build.gradle b/qa/full-cluster-restart/build.gradle index a441c295cb7..472aa5bd1d0 100644 --- a/qa/full-cluster-restart/build.gradle +++ b/qa/full-cluster-restart/build.gradle @@ -78,7 +78,7 @@ configurations { testArtifacts.extendsFrom testImplementation } -task testJar(type: Jar) { +TaskProvider testJar = tasks.register("testJar", Jar) { appendix 'test' from sourceSets.test.output } diff --git a/qa/multi-cluster-search/build.gradle b/qa/multi-cluster-search/build.gradle index eaf8ae5d4cd..0ed4989fff4 100644 --- a/qa/multi-cluster-search/build.gradle +++ b/qa/multi-cluster-search/build.gradle @@ -53,11 +53,10 @@ testClusters.mixedClusterTest { setting 'cluster.remote.connections_per_cluster', '1' } - -task integTest { - dependsOn mixedClusterTest +tasks.register("integTest") { + dependsOn "mixedClusterTest" } -test.enabled = false // no unit tests for multi-cluster-search, only integration tests +tasks.named("test").configure { enabled = false }// no unit tests for multi-cluster-search, only integration tests -check.dependsOn(integTest) +tasks.named("check").configure { dependsOn("integTest") } diff --git a/qa/remote-clusters/build.gradle b/qa/remote-clusters/build.gradle index 15f912334df..b9fa5f83507 100644 --- a/qa/remote-clusters/build.gradle +++ b/qa/remote-clusters/build.gradle @@ -31,7 +31,7 @@ dependencies { testImplementation project(':client:rest-high-level') } -task copyKeystore(type: Sync) { +tasks.register("copyKeystore", Sync) { from project(':x-pack:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') into "${buildDir}/certs" @@ -52,7 +52,7 @@ elasticsearch_distributions { } preProcessFixture { - dependsOn copyKeystore, elasticsearch_distributions.docker + dependsOn "copyKeystore", elasticsearch_distributions.docker doLast { // tests expect to have an empty repo project.delete( @@ -87,15 +87,15 @@ def createAndSetWritable(Object... locations) { } } -processTestResources { +tasks.named("processTestResources").configure { from project(':x-pack:plugin:core') .file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.jks') } -task integTest(type: Test) { +tasks.register("integTest", Test) { outputs.doNotCacheIf('Build cache is disabled for Docker tests') { true } maxParallelForks = '1' include '**/*IT.class' } -check.dependsOn integTest +tasks.named("check").configure { dependsOn "integTest" } diff --git a/qa/repository-multi-version/build.gradle b/qa/repository-multi-version/build.gradle index 50bd71ad275..ac0e3f8c5f6 100644 --- a/qa/repository-multi-version/build.gradle +++ b/qa/repository-multi-version/build.gradle @@ -92,7 +92,7 @@ configurations { testArtifacts.extendsFrom testImplementation } -task testJar(type: Jar) { +def testJar = tasks.register("testJar", Jar) { appendix 'test' from sourceSets.test.output } diff --git a/qa/wildfly/build.gradle b/qa/wildfly/build.gradle index 46c5689d1c8..ea5f86e3bf0 100644 --- a/qa/wildfly/build.gradle +++ b/qa/wildfly/build.gradle @@ -75,7 +75,7 @@ dockerCompose { } } -task integTest(type: Test) { +tasks.register("integTest", Test) { outputs.doNotCacheIf('Build cache is disabled for Docker tests') { true } maxParallelForks = '1' include '**/*IT.class' diff --git a/server/build.gradle b/server/build.gradle index 288292d84f5..59c5704fae7 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -132,9 +132,9 @@ dependencies { } } -compileJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked" -compileTestJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked" -compileInternalClusterTestJava.options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked" +tasks.withType(JavaCompile).configureEach { + options.compilerArgs << "-Xlint:-cast,-rawtypes,-unchecked" +} // Until this project is always being formatted with spotless, we need to // guard against `spotless()` not existing. @@ -152,187 +152,186 @@ catch (Exception e) { } } -forbiddenPatterns { - exclude '**/*.json' - exclude '**/*.jmx' - exclude '**/*.dic' - exclude '**/*.binary' - exclude '**/*.st' +tasks.named("forbiddenPatterns").configure { + exclude '**/*.json' + exclude '**/*.jmx' + exclude '**/*.dic' + exclude '**/*.binary' + exclude '**/*.st' } -testingConventions { - naming.clear() - naming { - Tests { - baseClass "org.apache.lucene.util.LuceneTestCase" +tasks.named("testingConventions").configure { + naming.clear() + naming { + Tests { + baseClass "org.apache.lucene.util.LuceneTestCase" + } + IT { + baseClass "org.elasticsearch.test.ESIntegTestCase" + baseClass "org.elasticsearch.test.ESSingleNodeTestCase" + } } - IT { - baseClass "org.elasticsearch.test.ESIntegTestCase" - baseClass "org.elasticsearch.test.ESSingleNodeTestCase" +} + +def generateModulesList = tasks.register("generateModulesList") { + List modules = project(':modules').subprojects.collect { it.name } + modules.add('x-pack') + File modulesFile = new File(buildDir, 'generated-resources/modules.txt') + processResources.from(modulesFile) + inputs.property('modules', modules) + outputs.file(modulesFile) + doLast { + modulesFile.parentFile.mkdirs() + modulesFile.setText(modules.join('\n'), 'UTF-8') } - } } -task generateModulesList { - List modules = project(':modules').subprojects.collect { it.name } - modules.add('x-pack') - File modulesFile = new File(buildDir, 'generated-resources/modules.txt') - processResources.from(modulesFile) - inputs.property('modules', modules) - outputs.file(modulesFile) - doLast { - modulesFile.parentFile.mkdirs() - modulesFile.setText(modules.join('\n'), 'UTF-8') - } +def generatePluginsList = tasks.register("generatePluginsList") { + Set plugins = new TreeSet<>(project(':plugins').childProjects.keySet()) + plugins.remove('example') + + File pluginsFile = new File(buildDir, 'generated-resources/plugins.txt') + processResources.from(pluginsFile) + inputs.property('plugins', plugins) + outputs.file(pluginsFile) + doLast { + pluginsFile.parentFile.mkdirs() + pluginsFile.setText(plugins.join('\n'), 'UTF-8') + } } -task generatePluginsList { - Set plugins = new TreeSet<>(project(':plugins').childProjects.keySet()) - plugins.remove('example') - - File pluginsFile = new File(buildDir, 'generated-resources/plugins.txt') - processResources.from(pluginsFile) - inputs.property('plugins', plugins) - outputs.file(pluginsFile) - doLast { - pluginsFile.parentFile.mkdirs() - pluginsFile.setText(plugins.join('\n'), 'UTF-8') - } +tasks.named("processResources").configure { + dependsOn generateModulesList, generatePluginsList } -processResources { - dependsOn generateModulesList, generatePluginsList -} +tasks.named("thirdPartyAudit").configure { + ignoreMissingClasses( + // from com.fasterxml.jackson.dataformat.yaml.YAMLMapper (jackson-dataformat-yaml) + 'com.fasterxml.jackson.databind.ObjectMapper', -thirdPartyAudit.ignoreMissingClasses( - // from com.fasterxml.jackson.dataformat.yaml.YAMLMapper (jackson-dataformat-yaml) - 'com.fasterxml.jackson.databind.ObjectMapper', + // from log4j + 'com.conversantmedia.util.concurrent.DisruptorBlockingQueue', + 'com.conversantmedia.util.concurrent.SpinPolicy', + 'com.fasterxml.jackson.annotation.JsonInclude$Include', + 'com.fasterxml.jackson.databind.DeserializationContext', + 'com.fasterxml.jackson.databind.DeserializationFeature', + 'com.fasterxml.jackson.databind.JsonMappingException', + 'com.fasterxml.jackson.databind.JsonNode', + 'com.fasterxml.jackson.databind.Module$SetupContext', + 'com.fasterxml.jackson.databind.ObjectReader', + 'com.fasterxml.jackson.databind.ObjectWriter', + 'com.fasterxml.jackson.databind.SerializerProvider', + 'com.fasterxml.jackson.databind.deser.std.StdDeserializer', + 'com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer', + 'com.fasterxml.jackson.databind.module.SimpleModule', + 'com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter', + 'com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider', + 'com.fasterxml.jackson.databind.ser.std.StdScalarSerializer', + 'com.fasterxml.jackson.databind.ser.std.StdSerializer', + 'com.fasterxml.jackson.dataformat.xml.JacksonXmlModule', + 'com.fasterxml.jackson.dataformat.xml.XmlMapper', + 'com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter', + 'com.fasterxml.jackson.databind.node.ObjectNode', + 'org.fusesource.jansi.Ansi', + 'org.fusesource.jansi.AnsiRenderer$Code', + 'com.lmax.disruptor.BlockingWaitStrategy', + 'com.lmax.disruptor.BusySpinWaitStrategy', + 'com.lmax.disruptor.EventFactory', + 'com.lmax.disruptor.EventTranslator', + 'com.lmax.disruptor.EventTranslatorTwoArg', + 'com.lmax.disruptor.EventTranslatorVararg', + 'com.lmax.disruptor.ExceptionHandler', + 'com.lmax.disruptor.LifecycleAware', + 'com.lmax.disruptor.RingBuffer', + 'com.lmax.disruptor.Sequence', + 'com.lmax.disruptor.SequenceReportingEventHandler', + 'com.lmax.disruptor.SleepingWaitStrategy', + 'com.lmax.disruptor.TimeoutBlockingWaitStrategy', + 'com.lmax.disruptor.WaitStrategy', + 'com.lmax.disruptor.YieldingWaitStrategy', + 'com.lmax.disruptor.dsl.Disruptor', + 'com.lmax.disruptor.dsl.ProducerType', + 'javax.jms.Connection', + 'javax.jms.ConnectionFactory', + 'javax.jms.Destination', + 'javax.jms.JMSException', + 'javax.jms.MapMessage', + 'javax.jms.Message', + 'javax.jms.MessageConsumer', + 'javax.jms.MessageProducer', + 'javax.jms.Session', + 'javax.mail.Authenticator', + 'javax.mail.Message$RecipientType', + 'javax.mail.PasswordAuthentication', + 'javax.mail.Session', + 'javax.mail.Transport', + 'javax.mail.internet.InternetAddress', + 'javax.mail.internet.InternetHeaders', + 'javax.mail.internet.MimeBodyPart', + 'javax.mail.internet.MimeMessage', + 'javax.mail.internet.MimeMultipart', + 'javax.mail.internet.MimeUtility', + 'javax.mail.util.ByteArrayDataSource', + 'org.apache.commons.compress.compressors.CompressorStreamFactory', + 'org.apache.commons.compress.utils.IOUtils', + 'org.apache.commons.csv.CSVFormat', + 'org.apache.commons.csv.QuoteMode', + 'org.apache.kafka.clients.producer.Callback', + 'org.apache.kafka.clients.producer.KafkaProducer', + 'org.apache.kafka.clients.producer.Producer', + 'org.apache.kafka.clients.producer.ProducerRecord', + 'org.apache.kafka.clients.producer.RecordMetadata', + 'org.codehaus.stax2.XMLStreamWriter2', + 'org.jctools.queues.MessagePassingQueue$Consumer', + 'org.jctools.queues.MpscArrayQueue', + 'org.osgi.framework.AdaptPermission', + 'org.osgi.framework.AdminPermission', + 'org.osgi.framework.Bundle', + 'org.osgi.framework.BundleActivator', + 'org.osgi.framework.BundleContext', + 'org.osgi.framework.BundleEvent', + 'org.osgi.framework.BundleReference', + 'org.osgi.framework.FrameworkUtil', + 'org.osgi.framework.ServiceRegistration', + 'org.osgi.framework.SynchronousBundleListener', + 'org.osgi.framework.wiring.BundleWire', + 'org.osgi.framework.wiring.BundleWiring', + 'org.zeromq.ZMQ$Context', + 'org.zeromq.ZMQ$Socket', + 'org.zeromq.ZMQ', - // from log4j - 'com.conversantmedia.util.concurrent.DisruptorBlockingQueue', - 'com.conversantmedia.util.concurrent.SpinPolicy', - 'com.fasterxml.jackson.annotation.JsonInclude$Include', - 'com.fasterxml.jackson.databind.DeserializationContext', - 'com.fasterxml.jackson.databind.DeserializationFeature', - 'com.fasterxml.jackson.databind.JsonMappingException', - 'com.fasterxml.jackson.databind.JsonNode', - 'com.fasterxml.jackson.databind.Module$SetupContext', - 'com.fasterxml.jackson.databind.ObjectReader', - 'com.fasterxml.jackson.databind.ObjectWriter', - 'com.fasterxml.jackson.databind.SerializerProvider', - 'com.fasterxml.jackson.databind.deser.std.StdDeserializer', - 'com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer', - 'com.fasterxml.jackson.databind.module.SimpleModule', - 'com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter', - 'com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider', - 'com.fasterxml.jackson.databind.ser.std.StdScalarSerializer', - 'com.fasterxml.jackson.databind.ser.std.StdSerializer', - 'com.fasterxml.jackson.dataformat.xml.JacksonXmlModule', - 'com.fasterxml.jackson.dataformat.xml.XmlMapper', - 'com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter', - 'com.fasterxml.jackson.databind.node.ObjectNode', - 'org.fusesource.jansi.Ansi', - 'org.fusesource.jansi.AnsiRenderer$Code', - 'com.lmax.disruptor.BlockingWaitStrategy', - 'com.lmax.disruptor.BusySpinWaitStrategy', - 'com.lmax.disruptor.EventFactory', - 'com.lmax.disruptor.EventTranslator', - 'com.lmax.disruptor.EventTranslatorTwoArg', - 'com.lmax.disruptor.EventTranslatorVararg', - 'com.lmax.disruptor.ExceptionHandler', - 'com.lmax.disruptor.LifecycleAware', - 'com.lmax.disruptor.RingBuffer', - 'com.lmax.disruptor.Sequence', - 'com.lmax.disruptor.SequenceReportingEventHandler', - 'com.lmax.disruptor.SleepingWaitStrategy', - 'com.lmax.disruptor.TimeoutBlockingWaitStrategy', - 'com.lmax.disruptor.WaitStrategy', - 'com.lmax.disruptor.YieldingWaitStrategy', - 'com.lmax.disruptor.dsl.Disruptor', - 'com.lmax.disruptor.dsl.ProducerType', - 'javax.jms.Connection', - 'javax.jms.ConnectionFactory', - 'javax.jms.Destination', - 'javax.jms.JMSException', - 'javax.jms.MapMessage', - 'javax.jms.Message', - 'javax.jms.MessageConsumer', - 'javax.jms.MessageProducer', - 'javax.jms.Session', - 'javax.mail.Authenticator', - 'javax.mail.Message$RecipientType', - 'javax.mail.PasswordAuthentication', - 'javax.mail.Session', - 'javax.mail.Transport', - 'javax.mail.internet.InternetAddress', - 'javax.mail.internet.InternetHeaders', - 'javax.mail.internet.MimeBodyPart', - 'javax.mail.internet.MimeMessage', - 'javax.mail.internet.MimeMultipart', - 'javax.mail.internet.MimeUtility', - 'javax.mail.util.ByteArrayDataSource', - 'org.apache.commons.compress.compressors.CompressorStreamFactory', - 'org.apache.commons.compress.utils.IOUtils', - 'org.apache.commons.csv.CSVFormat', - 'org.apache.commons.csv.QuoteMode', - 'org.apache.kafka.clients.producer.Callback', - 'org.apache.kafka.clients.producer.KafkaProducer', - 'org.apache.kafka.clients.producer.Producer', - 'org.apache.kafka.clients.producer.ProducerRecord', - 'org.apache.kafka.clients.producer.RecordMetadata', - 'org.codehaus.stax2.XMLStreamWriter2', - 'org.jctools.queues.MessagePassingQueue$Consumer', - 'org.jctools.queues.MpscArrayQueue', - 'org.osgi.framework.AdaptPermission', - 'org.osgi.framework.AdminPermission', - 'org.osgi.framework.Bundle', - 'org.osgi.framework.BundleActivator', - 'org.osgi.framework.BundleContext', - 'org.osgi.framework.BundleEvent', - 'org.osgi.framework.BundleReference', - 'org.osgi.framework.FrameworkUtil', - 'org.osgi.framework.ServiceRegistration', - 'org.osgi.framework.SynchronousBundleListener', - 'org.osgi.framework.wiring.BundleWire', - 'org.osgi.framework.wiring.BundleWiring', - 'org.zeromq.ZMQ$Context', - 'org.zeromq.ZMQ$Socket', - 'org.zeromq.ZMQ', + // from org.locationtech.spatial4j.io.GeoJSONReader (spatial4j) + 'org.noggit.JSONParser', - // from org.locationtech.spatial4j.io.GeoJSONReader (spatial4j) - 'org.noggit.JSONParser', + // from lucene-spatial + 'com.fasterxml.jackson.databind.JsonSerializer', + 'com.fasterxml.jackson.databind.JsonDeserializer', + 'com.fasterxml.jackson.databind.node.ArrayNode', + 'com.google.common.geometry.S2Cell', + 'com.google.common.geometry.S2CellId', + 'com.google.common.geometry.S2Projections', + 'com.google.common.geometry.S2Point', + 'com.google.common.geometry.S2$Metric', + 'com.google.common.geometry.S2LatLng' + ) - // from lucene-spatial - 'com.fasterxml.jackson.databind.JsonSerializer', - 'com.fasterxml.jackson.databind.JsonDeserializer', - 'com.fasterxml.jackson.databind.node.ArrayNode', - 'com.google.common.geometry.S2Cell', - 'com.google.common.geometry.S2CellId', - 'com.google.common.geometry.S2Projections', - 'com.google.common.geometry.S2Point', - 'com.google.common.geometry.S2$Metric', - 'com.google.common.geometry.S2LatLng' -) - -if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { - thirdPartyAudit.ignoreMissingClasses 'javax.xml.bind.DatatypeConverter' + if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_1_8) { + ignoreMissingClasses 'javax.xml.bind.DatatypeConverter' + } } tasks.named("dependencyLicenses").configure { - mapping from: /lucene-.*/, to: 'lucene' - dependencies = project.configurations.runtimeClasspath.fileCollection { - it.group.startsWith('org.elasticsearch') == false || - // keep the following org.elasticsearch jars in - (it.name == 'jna' || - it.name == 'securesm') - } + mapping from: /lucene-.*/, to: 'lucene' + dependencies = project.configurations.runtimeClasspath.fileCollection { + it.group.startsWith('org.elasticsearch') == false || + // keep the following org.elasticsearch jars in + (it.name == 'jna' || + it.name == 'securesm') + } } -licenseHeaders { - // Ignore our vendored version of Google Guice - excludes << 'org/elasticsearch/common/inject/**/*' -} - -licenseHeaders { - excludes << 'org/elasticsearch/client/documentation/placeholder.txt' -} +tasks.named("licenseHeaders").configure { + // Ignore our vendored version of Google Guice + excludes << 'org/elasticsearch/common/inject/**/*' + excludes << 'org/elasticsearch/client/documentation/placeholder.txt' +} \ No newline at end of file diff --git a/test/framework/build.gradle b/test/framework/build.gradle index 5cb0e685683..bd3a0dc8f40 100644 --- a/test/framework/build.gradle +++ b/test/framework/build.gradle @@ -66,7 +66,7 @@ test { systemProperty 'tests.gradle_unreleased_versions', BuildParams.bwcVersions.unreleased.join(',') } -task integTest(type: Test) { +tasks.register("integTest", Test) { include "**/*IT.class" } diff --git a/test/logger-usage/build.gradle b/test/logger-usage/build.gradle index fa12225ced3..c2328262638 100644 --- a/test/logger-usage/build.gradle +++ b/test/logger-usage/build.gradle @@ -25,22 +25,27 @@ dependencies { testImplementation project(":test:framework") } -loggerUsageCheck.enabled = false +tasks.named("loggerUsageCheck").configure { + enabled = false +} tasks.named('forbiddenApisMain').configure { replaceSignatureFiles 'jdk-signatures' // does not depend on core, only jdk signatures } + jarHell.enabled = true // disabled by parent project -thirdPartyAudit.ignoreMissingClasses( - // log4j - 'org.osgi.framework.AdaptPermission', - 'org.osgi.framework.AdminPermission', - 'org.osgi.framework.Bundle', - 'org.osgi.framework.BundleActivator', - 'org.osgi.framework.BundleContext', - 'org.osgi.framework.BundleEvent', - 'org.osgi.framework.SynchronousBundleListener', - 'org.osgi.framework.wiring.BundleWire', - 'org.osgi.framework.wiring.BundleWiring' -) +tasks.named("thirdPartyAudit").configure { + ignoreMissingClasses( + // log4j + 'org.osgi.framework.AdaptPermission', + 'org.osgi.framework.AdminPermission', + 'org.osgi.framework.Bundle', + 'org.osgi.framework.BundleActivator', + 'org.osgi.framework.BundleContext', + 'org.osgi.framework.BundleEvent', + 'org.osgi.framework.SynchronousBundleListener', + 'org.osgi.framework.wiring.BundleWire', + 'org.osgi.framework.wiring.BundleWiring' + ) +} \ No newline at end of file diff --git a/x-pack/build.gradle b/x-pack/build.gradle index ad8c2fe2952..337a928f6ed 100644 --- a/x-pack/build.gradle +++ b/x-pack/build.gradle @@ -31,7 +31,7 @@ subprojects { project.esplugin.noticeFile = xpackRootProject.file('NOTICE.txt') } - tasks.withType(LicenseHeadersTask.class) { + tasks.withType(LicenseHeadersTask.class).configureEach { approvedLicenses = ['Elastic License', 'Generated', 'Vendored'] additionalLicense 'ELAST', 'Elastic License', 'Licensed under the Elastic License' } diff --git a/x-pack/license-tools/build.gradle b/x-pack/license-tools/build.gradle index cb3c749c94c..7ae0b2dba92 100644 --- a/x-pack/license-tools/build.gradle +++ b/x-pack/license-tools/build.gradle @@ -12,7 +12,8 @@ project.forbiddenPatterns { tasks.named("dependencyLicenses").configure { it.enabled = false } -task buildZip(type: Zip, dependsOn: jar) { +tasks.register("buildZip", Zip) { + dependsOn "jar" String parentDir = "license-tools-${archiveVersion}" into(parentDir + '/lib') { from jar @@ -23,4 +24,4 @@ task buildZip(type: Zip, dependsOn: jar) { } } -assemble.dependsOn buildZip +tasks.named("assemble").configure { dependsOn("buildZip") } diff --git a/x-pack/plugin/build.gradle b/x-pack/plugin/build.gradle index ea608089364..5aa094666fe 100644 --- a/x-pack/plugin/build.gradle +++ b/x-pack/plugin/build.gradle @@ -75,7 +75,7 @@ artifacts { restXpackTests(new File(projectDir, "src/test/resources/rest-api-spec/test")) } -task testJar(type: Jar) { +def testJar = tasks.register("testJar", Jar) { appendix 'test' from sourceSets.test.output /* @@ -107,7 +107,7 @@ File nodeCert = file("$keystoreDir/testnode.crt") // it can run in a FIPS 140 JVM // TODO: Remove all existing uses of cross project file references when the new approach for referencing static files is available // https://github.com/elastic/elasticsearch/pull/32201 -task copyKeyCerts(type: Copy) { +tasks.register("copyKeyCerts", Copy) { from(project(':x-pack:plugin:core').file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/')) { include 'testnode.crt', 'testnode.pem' } @@ -115,7 +115,7 @@ task copyKeyCerts(type: Copy) { } // Add keystores to test classpath: it expects it there sourceSets.test.resources.srcDir(keystoreDir) -processTestResources.dependsOn(copyKeyCerts) +processTestResources.dependsOn("copyKeyCerts") integTest.runner { /* diff --git a/x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle b/x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle index 28e6e7a65fe..cc4199d2593 100644 --- a/x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle +++ b/x-pack/plugin/ccr/qa/downgrade-to-basic-license/build.gradle @@ -22,7 +22,7 @@ testClusters."leader-cluster" { } File policyFile = file("${buildDir}/tmp/java.policy") -task writeJavaPolicy { +tasks.register("writeJavaPolicy") { doLast { if (policyFile.parentFile.exists() == false && policyFile.parentFile.mkdirs() == false) { throw new GradleException("failed to create temporary directory [${tmp}]") @@ -82,5 +82,6 @@ testClusters."follow-cluster" { } -check.dependsOn "follow-cluster" -test.enabled = false // no unit tests for multi-cluster-search, only the rest integration test +tasks.named("check").configure { dependsOn "follow-cluster" } +// no unit tests for multi-cluster-search, only the rest integration test +tasks.named("test").configure { enabled = false } \ No newline at end of file diff --git a/x-pack/plugin/ccr/qa/security/build.gradle b/x-pack/plugin/ccr/qa/security/build.gradle index 01368adeed6..f7024c7f4f3 100644 --- a/x-pack/plugin/ccr/qa/security/build.gradle +++ b/x-pack/plugin/ccr/qa/security/build.gradle @@ -9,7 +9,7 @@ dependencies { testImplementation project(':x-pack:plugin:ccr:qa') } -task resolve { +tasks.register("resolve") { doLast { configurations.testCompileClasspath.files.each { println it diff --git a/x-pack/plugin/core/build.gradle b/x-pack/plugin/core/build.gradle index a77cd87c149..9e9ca2d4b48 100644 --- a/x-pack/plugin/core/build.gradle +++ b/x-pack/plugin/core/build.gradle @@ -125,7 +125,7 @@ configurations { testArtifacts.extendsFrom testRuntime testArtifacts.extendsFrom testImplementation } -task testJar(type: Jar) { +def testJar = tasks.register("testJar", Jar) { appendix 'test' from sourceSets.test.output } @@ -136,15 +136,17 @@ artifacts { testArtifacts testJar } -thirdPartyAudit.ignoreMissingClasses( - //commons-logging optional dependencies - 'org.apache.avalon.framework.logger.Logger', - 'org.apache.log.Hierarchy', - 'org.apache.log.Logger', - //commons-logging provided dependencies - 'javax.servlet.ServletContextEvent', - 'javax.servlet.ServletContextListener' -) +tasks.named("thirdPartyAudit").configure { + ignoreMissingClasses( + //commons-logging optional dependencies + 'org.apache.avalon.framework.logger.Logger', + 'org.apache.log.Hierarchy', + 'org.apache.log.Logger', + //commons-logging provided dependencies + 'javax.servlet.ServletContextEvent', + 'javax.servlet.ServletContextListener' + ) +} restResources { restApi { @@ -160,4 +162,4 @@ testClusters.yamlRestTest { user username: "x_pack_rest_user", password: "x-pack-test-password" } -testingConventions.enabled = false +tasks.named("testingConventions").configure { enabled = false } diff --git a/x-pack/plugin/eql/build.gradle b/x-pack/plugin/eql/build.gradle index 913902752d5..b5348c4800b 100644 --- a/x-pack/plugin/eql/build.gradle +++ b/x-pack/plugin/eql/build.gradle @@ -73,7 +73,7 @@ dependencies { String grammarPath = 'src/main/antlr' String outputPath = 'src/main/java/org/elasticsearch/xpack/eql/parser' -task cleanGenerated(type: Delete) { +tasks.register("cleanGenerated", Delete) { delete fileTree(grammarPath) { include '*.tokens' } @@ -82,8 +82,8 @@ task cleanGenerated(type: Delete) { } } -task regenParser(type: JavaExec) { - dependsOn cleanGenerated +tasks.register("regenParser", JavaExec) { + dependsOn "cleanGenerated" main = 'org.antlr.v4.Tool' classpath = configurations.regenerate systemProperty 'file.encoding', 'UTF-8' @@ -98,8 +98,8 @@ task regenParser(type: JavaExec) { "${file(grammarPath)}/EqlBase.g4" } -task regen { - dependsOn regenParser +tasks.register("regen") { + dependsOn "regenParser" doLast { // moves token files to grammar directory for use with IDE's ant.move(file: "${outputPath}/EqlBase.tokens", toDir: grammarPath) diff --git a/x-pack/plugin/ml/build.gradle b/x-pack/plugin/ml/build.gradle index 837d6becf99..d18c3bb78b0 100644 --- a/x-pack/plugin/ml/build.gradle +++ b/x-pack/plugin/ml/build.gradle @@ -69,17 +69,17 @@ configurations { testArtifacts.extendsFrom testRuntime testArtifacts.extendsFrom testImplementation } -task testJar(type: Jar) { +TaskProvider testJar = tasks.register("testJar", Jar) { appendix 'test' from sourceSets.test.output } artifacts { // normal es plugins do not publish the jar but we need to since users need it for Transport Clients and extensions - archives jar + archives tasks.named('jar') testArtifacts testJar } -task extractNativeLicenses(type: Copy) { +tasks.register("extractNativeLicenses", Copy) { dependsOn configurations.nativeBundle into "${buildDir}" from { @@ -89,23 +89,28 @@ task extractNativeLicenses(type: Copy) { } project.afterEvaluate { // Add an extra licenses directory to the combined notices - project.tasks.findByName('generateNotice').dependsOn extractNativeLicenses - project.tasks.findByName('generateNotice').licensesDir new File("${project.buildDir}/platform/licenses") - project.tasks.findByName('generateNotice').outputs.upToDateWhen { - extractNativeLicenses.state.upToDate + tasks.named('generateNotice').configure { + dependsOn "extractNativeLicenses" + licensesDir new File("${project.buildDir}/platform/licenses") + outputs.upToDateWhen { + extractNativeLicenses.didWork + } } } // xpack modules are installed in real clusters as the meta plugin, so // installing them as individual plugins for integ tests doesn't make sense, // so we disable integ tests -integTest.enabled = false +tasks.named("integTest").configure { + enabled = false +} +def checkTask = tasks.named("check") // add all sub-projects of the qa sub-project gradle.projectsEvaluated { project.subprojects .find { it.path == project.path + ":qa" } .subprojects .findAll { it.path.startsWith(project.path + ":qa") } - .each { check.dependsOn it.check } + .each { subProj -> checkTask.configure { dependsOn subProj.tasks.named("check") } } } diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle b/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle index 81a9f198f4b..701b71535ea 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/build.gradle @@ -16,7 +16,7 @@ File keystoreDir = new File(project.buildDir, 'keystore') File nodeKey = file("$keystoreDir/testnode.pem") File nodeCert = file("$keystoreDir/testnode.crt") // Add key and certs to test classpath: it expects it there -task copyKeyCerts(type: Copy) { +tasks.register("copyKeyCerts", Copy) { from(project(':x-pack:plugin:core').file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/')) { include 'testnode.crt', 'testnode.pem' } @@ -24,10 +24,10 @@ task copyKeyCerts(type: Copy) { } // Add keys and cets to test classpath: it expects it there sourceSets.test.resources.srcDir(keystoreDir) -processTestResources.dependsOn(copyKeyCerts) +tasks.named("processTestResources").configure { dependsOn("copyKeyCerts") } integTest { - dependsOn copyKeyCerts + dependsOn "copyKeyCerts" runner { /* * We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each diff --git a/x-pack/plugin/monitoring/build.gradle b/x-pack/plugin/monitoring/build.gradle index 6a25fc5b438..53a78aa7a00 100644 --- a/x-pack/plugin/monitoring/build.gradle +++ b/x-pack/plugin/monitoring/build.gradle @@ -28,13 +28,13 @@ configurations { testArtifacts.extendsFrom testRuntime testArtifacts.extendsFrom testImplementation } -task testJar(type: Jar) { +TaskProvider testJar = tasks.register("testJar", Jar) { appendix 'test' from sourceSets.test.output } artifacts { // normal es plugins do not publish the jar but we need to since users need it for Transport Clients and extensions - archives jar + archives tasks.named("jar") testArtifacts testJar } @@ -46,4 +46,4 @@ tasks.named("dependencyLicenses").configure { // xpack modules are installed in real clusters as the meta plugin, so // installing them as individual plugins for integ tests doesn't make sense, // so we disable integ tests -integTest.enabled = false +tasks.named("integTest").configure { enabled = false } diff --git a/x-pack/plugin/ql/build.gradle b/x-pack/plugin/ql/build.gradle index daab9a2716d..9968b8f0fff 100644 --- a/x-pack/plugin/ql/build.gradle +++ b/x-pack/plugin/ql/build.gradle @@ -21,17 +21,18 @@ configurations { testArtifacts.extendsFrom testImplementation } -task testJar(type: Jar) { +TaskProvider testJar = tasks.register("testJar", Jar) { appendix 'test' from sourceSets.test.output } artifacts { // normal es plugins do not publish the jar but we need to since users need it for extensions - archives jar + archives tasks.named("jar") testArtifacts testJar } - // disable integration tests for now -integTest.enabled = false +tasks.named("integTest").configure { + enabled = false +} diff --git a/x-pack/plugin/searchable-snapshots/build.gradle b/x-pack/plugin/searchable-snapshots/build.gradle index d24b3bb84c3..5b81bc25282 100644 --- a/x-pack/plugin/searchable-snapshots/build.gradle +++ b/x-pack/plugin/searchable-snapshots/build.gradle @@ -35,7 +35,7 @@ configurations { testArtifacts.extendsFrom testImplementation } -task testJar(type: Jar) { +def testJar = tasks.register("testJar", Jar) { appendix 'test' from sourceSets.test.output } diff --git a/x-pack/plugin/searchable-snapshots/qa/azure/build.gradle b/x-pack/plugin/searchable-snapshots/qa/azure/build.gradle index fee7dd3e0fa..0469244055a 100644 --- a/x-pack/plugin/searchable-snapshots/qa/azure/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/azure/build.gradle @@ -101,7 +101,7 @@ testClusters.integTest { } } -task azureThirdPartyTest { - dependsOn integTest +tasks.register("azureThirdPartyTest") { + dependsOn "integTest" } diff --git a/x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle b/x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle index ca7cf2178da..acf1aa53a33 100644 --- a/x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/gcs/build.gradle @@ -63,7 +63,7 @@ if (!gcsServiceAccount && !gcsBucket && !gcsBasePath) { } /** A service account file that points to the Google Cloud Storage service emulated by the fixture **/ -task createServiceAccountFile() { +tasks.register("createServiceAccountFile") { doLast { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA") keyPairGenerator.initialize(1024) @@ -133,6 +133,6 @@ testClusters.integTest { setting 'xpack.license.self_generated.type', 'trial' } -task gcsThirdPartyTest { - dependsOn integTest +tasks.register("gcsThirdPartyTest") { + dependsOn "integTest" } diff --git a/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle b/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle index f1998ffa066..ab98f5a40fa 100644 --- a/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle +++ b/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle @@ -77,6 +77,6 @@ testClusters.integTest { } } -task s3ThirdPartyTest { - dependsOn integTest +tasks.register("s3ThirdPartyTest") { + dependsOn "integTest" } diff --git a/x-pack/plugin/security/build.gradle b/x-pack/plugin/security/build.gradle index 7a0cb4ad60b..841ca95a22b 100644 --- a/x-pack/plugin/security/build.gradle +++ b/x-pack/plugin/security/build.gradle @@ -145,13 +145,13 @@ configurations { testArtifacts.extendsFrom testRuntime testArtifacts.extendsFrom testImplementation } -task testJar(type: Jar) { +TaskProvider testJar = tasks.register("testJar", Jar) { appendix 'test' from sourceSets.test.output } artifacts { // normal es plugins do not publish the jar but we need to since users need it for Transport Clients and extensions - archives jar + archives tasks.named('jar') testArtifacts testJar } diff --git a/x-pack/plugin/security/qa/basic-enable-security/build.gradle b/x-pack/plugin/security/qa/basic-enable-security/build.gradle index 33fdda0c0e6..2b0379bac94 100644 --- a/x-pack/plugin/security/qa/basic-enable-security/build.gradle +++ b/x-pack/plugin/security/qa/basic-enable-security/build.gradle @@ -55,5 +55,5 @@ task integTestSecurity(type: RestTestRunnerTask) { nonInputProperties.systemProperty 'tests.rest.cluster', "${-> testClusters.integTest.getAllHttpSocketURI().join(",")}" } } -check.dependsOn(integTestSecurity) +tasks.named("check").configure { dependsOn(integTestSecurity) } diff --git a/x-pack/plugin/sql/build.gradle b/x-pack/plugin/sql/build.gradle index ef940572720..232a6f1bb21 100644 --- a/x-pack/plugin/sql/build.gradle +++ b/x-pack/plugin/sql/build.gradle @@ -85,7 +85,7 @@ dependencies { String grammarPath = 'src/main/antlr' String outputPath = 'src/main/java/org/elasticsearch/xpack/sql/parser' -task cleanGenerated(type: Delete) { +tasks.register("cleanGenerated", Delete) { delete fileTree(grammarPath) { include '*.tokens' } @@ -94,8 +94,8 @@ task cleanGenerated(type: Delete) { } } -task regenParser(type: JavaExec) { - dependsOn cleanGenerated +tasks.register("regenParser", JavaExec) { + dependsOn "cleanGenerated" main = 'org.antlr.v4.Tool' classpath = configurations.regenerate systemProperty 'file.encoding', 'UTF-8' @@ -110,8 +110,8 @@ task regenParser(type: JavaExec) { "${file(grammarPath)}/SqlBase.g4" } -task regen { - dependsOn regenParser +tasks.register("regen") { + dependsOn "regenParser" doLast { // moves token files to grammar directory for use with IDE's ant.move(file: "${outputPath}/SqlBase.tokens", toDir: grammarPath) diff --git a/x-pack/plugin/sql/qa/server/build.gradle b/x-pack/plugin/sql/qa/server/build.gradle index 7ea79c34438..7a9a26a4853 100644 --- a/x-pack/plugin/sql/qa/server/build.gradle +++ b/x-pack/plugin/sql/qa/server/build.gradle @@ -33,15 +33,12 @@ dependencies { testRuntimeOnly "org.elasticsearch:jna:${versions.jna}" } -/* disable unit tests because these are all integration tests used - * other qa projects. */ -test.enabled = false - -tasks.named("dependencyLicenses").configure { it.enabled = false } -dependenciesInfo.enabled = false - -// just a test fixture: we aren't using this jars in releases and H2GIS requires disabling a lot of checks -thirdPartyAudit.enabled = false +// this is just a test fixture used by other projects and not in production +['test', 'dependencyLicenses', 'thirdPartyAudit', 'dependenciesInfo'].each { + tasks.named(it).configure { + enabled = false + } +} subprojects { if (subprojects.isEmpty()) { diff --git a/x-pack/plugin/sql/sql-cli/build.gradle b/x-pack/plugin/sql/sql-cli/build.gradle index c344347f03e..3e6ef43e510 100644 --- a/x-pack/plugin/sql/sql-cli/build.gradle +++ b/x-pack/plugin/sql/sql-cli/build.gradle @@ -54,9 +54,9 @@ tasks.named('forbiddenApisMain').configure { signaturesFiles += files('src/forbidden/cli-signatures.txt') } -task runcli { +tasks.register("runcli") { description = 'Run the CLI and connect to elasticsearch running on 9200' - dependsOn shadowJar + dependsOn "shadowJar" doLast { List command = ["${BuildParams.runtimeJavaHome}/bin/java"] if ('true'.equals(System.getProperty('debug', 'false'))) { diff --git a/x-pack/plugin/transform/qa/multi-node-tests/build.gradle b/x-pack/plugin/transform/qa/multi-node-tests/build.gradle index 75a78673b40..33e4dc540c6 100644 --- a/x-pack/plugin/transform/qa/multi-node-tests/build.gradle +++ b/x-pack/plugin/transform/qa/multi-node-tests/build.gradle @@ -14,7 +14,7 @@ File keystoreDir = new File(project.buildDir, 'keystore') File nodeKey = file("$keystoreDir/testnode.pem") File nodeCert = file("$keystoreDir/testnode.crt") // Add key and certs to test classpath: it expects it there -task copyKeyCerts(type: Copy) { +tasks.register("copyKeyCerts", Copy) { from(project(':x-pack:plugin:core').file('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/')) { include 'testnode.crt', 'testnode.pem' } @@ -22,9 +22,9 @@ task copyKeyCerts(type: Copy) { } // Add keys and cets to test classpath: it expects it there sourceSets.test.resources.srcDir(keystoreDir) -processTestResources.dependsOn(copyKeyCerts) +tasks.named("processTestResources").configure { dependsOn("copyKeyCerts") } -integTest.dependsOn copyKeyCerts +tasks.named("integTest").configure { dependsOn "copyKeyCerts" } testClusters.integTest { testDistribution = 'DEFAULT' diff --git a/x-pack/plugin/watcher/qa/rest/build.gradle b/x-pack/plugin/watcher/qa/rest/build.gradle index 265f19722f2..f26d6f376b7 100644 --- a/x-pack/plugin/watcher/qa/rest/build.gradle +++ b/x-pack/plugin/watcher/qa/rest/build.gradle @@ -12,7 +12,7 @@ configurations { testArtifacts.extendsFrom testImplementation } -task testJar(type: Jar) { +def testJar = tasks.register("testJar", Jar) { appendix 'test' from sourceSets.test.output } diff --git a/x-pack/qa/full-cluster-restart/build.gradle b/x-pack/qa/full-cluster-restart/build.gradle index dc49ead6f3d..4993ccb22b0 100644 --- a/x-pack/qa/full-cluster-restart/build.gradle +++ b/x-pack/qa/full-cluster-restart/build.gradle @@ -15,11 +15,11 @@ dependencies { testImplementation project(':x-pack:qa') } -licenseHeaders { +tasks.named("licenseHeaders").configure { approvedLicenses << 'Apache' } -forbiddenPatterns { +tasks.named("forbiddenPatterns") { exclude '**/system_key' } diff --git a/x-pack/qa/kerberos-tests/build.gradle b/x-pack/qa/kerberos-tests/build.gradle index 1f7a6fe255e..3136e77884d 100644 --- a/x-pack/qa/kerberos-tests/build.gradle +++ b/x-pack/qa/kerberos-tests/build.gradle @@ -41,7 +41,7 @@ testClusters.integTest { user username: "test_kibana_user", password: "x-pack-test-password", role: "kibana_system" } -task copyKeytabToGeneratedResources(type: Copy) { +tasks.register("copyKeytabToGeneratedResources", Copy) { from project(':test:fixtures:krb5kdc-fixture').ext.krb5Keytabs("peppa", "peppa.keytab") into "$buildDir/generated-resources/keytabs" dependsOn project(':test:fixtures:krb5kdc-fixture').postProcessFixture diff --git a/x-pack/qa/multi-cluster-search-security/build.gradle b/x-pack/qa/multi-cluster-search-security/build.gradle index 85141164c8f..dd1b942f5bb 100644 --- a/x-pack/qa/multi-cluster-search-security/build.gradle +++ b/x-pack/qa/multi-cluster-search-security/build.gradle @@ -55,9 +55,9 @@ testClusters.'mixed-cluster' { user username: "test_user", password: "x-pack-test-password" } -task integTest { +tasks.register("integTest") { dependsOn 'mixed-cluster' } -test.enabled = false // no unit tests for multi-cluster-search, only the rest integration test -check.dependsOn(integTest) +tasks.named("test").configure { enabled = false } // no unit tests for multi-cluster-search, only the rest integration test +tasks.named("check").configure { dependsOn("integTest") } diff --git a/x-pack/qa/multi-cluster-tests-with-security/build.gradle b/x-pack/qa/multi-cluster-tests-with-security/build.gradle index fb0536cdaf2..9d45399ea26 100644 --- a/x-pack/qa/multi-cluster-tests-with-security/build.gradle +++ b/x-pack/qa/multi-cluster-tests-with-security/build.gradle @@ -54,9 +54,9 @@ testClusters.'mixed-cluster' { user username: "test_user", password: "x-pack-test-password" } -task integTest { +tasks.register("integTest") { dependsOn 'mixed-cluster' } -test.enabled = false // no unit tests for multi-cluster-search, only the rest integration test -check.dependsOn(integTest) +tasks.named("test").configure { enabled = false } // no unit tests for multi-cluster-search, only the rest integration test +tasks.named("check").configure { dependsOn("integTest") } diff --git a/x-pack/qa/oidc-op-tests/build.gradle b/x-pack/qa/oidc-op-tests/build.gradle index bd4fa155d88..20120b8dbff 100644 --- a/x-pack/qa/oidc-op-tests/build.gradle +++ b/x-pack/qa/oidc-op-tests/build.gradle @@ -14,7 +14,7 @@ testFixtures.useFixture ":x-pack:test:idp-fixture", "oidc-provider" String ephemeralOpPort String ephemeralProxyPort -task setupPorts { +tasks.register("setupPorts") { // Don't attempt to get ephemeral ports when Docker is not available onlyIf { idpFixtureProject.postProcessFixture.state.skipped == false } dependsOn idpFixtureProject.postProcessFixture @@ -25,7 +25,7 @@ task setupPorts { } integTest.runner { - dependsOn setupPorts + dependsOn "setupPorts" } testClusters.integTest { diff --git a/x-pack/qa/openldap-tests/build.gradle b/x-pack/qa/openldap-tests/build.gradle index e873e2e4ab4..332bfaeb0fb 100644 --- a/x-pack/qa/openldap-tests/build.gradle +++ b/x-pack/qa/openldap-tests/build.gradle @@ -11,7 +11,7 @@ testFixtures.useFixture ":x-pack:test:idp-fixture", "openldap" Project idpFixtureProject = xpackProject("test:idp-fixture") String outputDir = "${project.buildDir}/generated-resources/${project.name}" -task copyIdpTrust(type: Copy) { +def copyIdpTrust = tasks.register("copyIdpTrust", Copy) { from idpFixtureProject.file('openldap/certs/ca.jks'); from idpFixtureProject.file('openldap/certs/ca_server.pem'); into outputDir diff --git a/x-pack/qa/rolling-upgrade/build.gradle b/x-pack/qa/rolling-upgrade/build.gradle index 5b384a5da59..08c02603dc6 100644 --- a/x-pack/qa/rolling-upgrade/build.gradle +++ b/x-pack/qa/rolling-upgrade/build.gradle @@ -25,7 +25,7 @@ forbiddenPatterns { String outputDir = "${buildDir}/generated-resources/${project.name}" -task copyTestNodeKeyMaterial(type: Copy) { +tasks.register("copyTestNodeKeyMaterial", Copy) { from project(':x-pack:plugin:core').files('src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.pem', 'src/test/resources/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testnode.crt') into outputDir @@ -92,7 +92,7 @@ for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible) { tasks.register("${baseName}#oldClusterTest", RestTestRunnerTask) { useCluster testClusters."${baseName}" mustRunAfter(precommit) - dependsOn copyTestNodeKeyMaterial + dependsOn "copyTestNodeKeyMaterial" systemProperty 'tests.rest.suite', 'old_cluster' systemProperty 'tests.upgrade_from_version', oldVersion nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}".allHttpSocketURI.join(",")}") diff --git a/x-pack/qa/saml-idp-tests/build.gradle b/x-pack/qa/saml-idp-tests/build.gradle index 838d5614f37..387e13d93f4 100644 --- a/x-pack/qa/saml-idp-tests/build.gradle +++ b/x-pack/qa/saml-idp-tests/build.gradle @@ -13,13 +13,13 @@ testFixtures.useFixture ":x-pack:test:idp-fixture" String outputDir = "${project.buildDir}/generated-resources/${project.name}" -task copyIdpFiles(type: Copy) { +def copyIdpFiles = tasks.register("copyIdpFiles", Copy) { from idpFixtureProject.files('idp/shibboleth-idp/credentials/idp-browser.pem', 'idp/shibboleth-idp/metadata/idp-metadata.xml'); into outputDir } project.sourceSets.test.output.dir(outputDir, builtBy: copyIdpFiles) -task setupPorts { +tasks.register("setupPorts") { dependsOn copyIdpFiles, idpFixtureProject.postProcessFixture // Don't attempt to get ephemeral ports when Docker is not available onlyIf { idpFixtureProject.postProcessFixture.state.skipped == false } @@ -39,7 +39,7 @@ task setupPorts { } -integTest.runner.dependsOn setupPorts +integTest.runner.dependsOn "setupPorts" testClusters.integTest { testDistribution = 'DEFAULT' @@ -85,13 +85,13 @@ testClusters.integTest { user username: "test_admin", password: 'x-pack-test-password' } -forbiddenPatterns { +tasks.named("forbiddenPatterns").configure { exclude '**/*.der' exclude '**/*.p12' exclude '**/*.key' } -thirdPartyAudit { +tasks.named("thirdPartyAudit").configure { ignoreViolations( // uses internal java api: sun.misc.Unsafe 'com.google.common.cache.Striped64', diff --git a/x-pack/qa/smoke-test-plugins-ssl/build.gradle b/x-pack/qa/smoke-test-plugins-ssl/build.gradle index d555db7d222..6dabd912cd6 100644 --- a/x-pack/qa/smoke-test-plugins-ssl/build.gradle +++ b/x-pack/qa/smoke-test-plugins-ssl/build.gradle @@ -12,7 +12,7 @@ dependencies { } String outputDir = "${buildDir}/generated-resources/${project.name}" -task copyXPackPluginProps(type: Copy) { +def copyXPackPluginProps = tasks.register("copyXPackPluginProps", Copy) { from project(xpackModule('core')).file('src/main/plugin-metadata') from project(xpackModule('core')).tasks.pluginProperties into outputDir @@ -29,7 +29,7 @@ File clientKey = file("$keystoreDir/testclient.pem") File clientCert = file("$keystoreDir/testclient.crt") // Add keystores to test classpath: it expects it there -task copyKeyCerts(type: Copy) { +def copyKeyCerts = tasks.register("copyKeyCerts", Copy) { from('./') { include '*.crt', '*.pem', '*.jks' } @@ -77,7 +77,7 @@ ext.expansions = [ 'expected.plugins.count': pluginsCount ] -processTestResources { +tasks.named("processTestResources").configure { from(sourceSets.test.resources.srcDirs) { duplicatesStrategy = DuplicatesStrategy.INCLUDE include '**/*.yml' diff --git a/x-pack/qa/third-party/jira/build.gradle b/x-pack/qa/third-party/jira/build.gradle index 4f3a0870bdd..7e9f478c0b6 100644 --- a/x-pack/qa/third-party/jira/build.gradle +++ b/x-pack/qa/third-party/jira/build.gradle @@ -24,7 +24,7 @@ String jiraUser = System.getenv('jira_user') String jiraPassword = System.getenv('jira_password') String jiraProject = System.getenv('jira_project') -task cleanJira(type: DefaultTask) { +tasks.register("cleanJira", DefaultTask) { doLast { List issues = jiraIssues(jiraProject) assert issues instanceof List @@ -54,7 +54,7 @@ if (!jiraUrl && !jiraUser && !jiraPassword && !jiraProject) { keystore 'xpack.notification.jira.account.test.secure_user', jiraUser keystore 'xpack.notification.jira.account.test.secure_password', jiraPassword } - integTest.runner.finalizedBy cleanJira + integTest.runner.finalizedBy "cleanJira" } /** List all issues associated to a given Jira project **/