From 7b358190d67764a4cfe4dd3dc43888631c7e4eca Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 16 Jun 2017 11:46:34 -0400 Subject: [PATCH] Remove assemble task when not used for publishing (#25228) Removes the `assemble` task from projects that are not published. This should speed up `gradle assemble` by skipping projects that don't need to be built. Which is useful because `gradle assemble` is how we cut releases. --- benchmarks/build.gradle | 2 ++ build.gradle | 13 +++++++++++++ .../org/elasticsearch/gradle/BuildPlugin.groovy | 7 +++++-- .../elasticsearch/gradle/doc/DocsTestPlugin.groovy | 2 ++ client/benchmark/build.gradle | 2 ++ .../client-benchmark-noop-api-plugin/build.gradle | 3 ++- distribution/bwc/build.gradle | 1 + plugins/examples/build.gradle | 9 +++++++++ plugins/jvm-example/build.gradle | 2 +- test/fixtures/example-fixture/build.gradle | 1 + 10 files changed, 38 insertions(+), 4 deletions(-) diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle index 5a508fa1065..45e20392b8a 100644 --- a/benchmarks/build.gradle +++ b/benchmarks/build.gradle @@ -34,6 +34,8 @@ apply plugin: 'com.github.johnrengelman.shadow' // have the shadow plugin provide the runShadow task apply plugin: 'application' +tasks.remove(assemble) // Not published so no need to assemble + archivesBaseName = 'elasticsearch-benchmarks' mainClassName = 'org.openjdk.jmh.Main' diff --git a/build.gradle b/build.gradle index e1b21d07a70..4806f7303f5 100644 --- a/build.gradle +++ b/build.gradle @@ -420,3 +420,16 @@ task run(type: Run) { group = 'Verification' impliesSubProjects = true } + +/* Remove assemble on all qa projects because we don't need to publish + * artifacts for them. */ +gradle.projectsEvaluated { + subprojects { + if (project.path.startsWith(':qa')) { + Task assemble = project.tasks.findByName('assemble') + if (assemble) { + project.tasks.remove(assemble) + } + } + } +} diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index af7716804bf..bafda0afc1b 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -394,8 +394,11 @@ class BuildPlugin implements Plugin { project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom t -> // place the pom next to the jar it is for t.destination = new File(project.buildDir, "distributions/${project.archivesBaseName}-${project.version}.pom") - // build poms with assemble - project.assemble.dependsOn(t) + // build poms with assemble (if the assemble task exists) + Task assemble = project.tasks.findByName('assemble') + if (assemble) { + assemble.dependsOn(t) + } } } } 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 66f9f0d4c4e..44670e20744 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy @@ -32,6 +32,8 @@ public class DocsTestPlugin extends RestTestPlugin { public void apply(Project project) { project.pluginManager.apply('elasticsearch.standalone-rest-test') super.apply(project) + // Docs are published separately so no need to assemble + project.tasks.remove(project.assemble) Map defaultSubstitutions = [ /* These match up with the asciidoc syntax for substitutions but * the values may differ. In particular {version} needs to resolve diff --git a/client/benchmark/build.gradle b/client/benchmark/build.gradle index d8a9105fae9..0ba9bd71c25 100644 --- a/client/benchmark/build.gradle +++ b/client/benchmark/build.gradle @@ -37,6 +37,8 @@ apply plugin: 'application' group = 'org.elasticsearch.client' +tasks.remove(assemble) // Not published so no need to assemble + archivesBaseName = 'client-benchmarks' mainClassName = 'org.elasticsearch.client.benchmark.BenchmarkMain' diff --git a/client/client-benchmark-noop-api-plugin/build.gradle b/client/client-benchmark-noop-api-plugin/build.gradle index a0d52f15916..17fe10fc8f7 100644 --- a/client/client-benchmark-noop-api-plugin/build.gradle +++ b/client/client-benchmark-noop-api-plugin/build.gradle @@ -27,9 +27,10 @@ esplugin { classname 'org.elasticsearch.plugin.noop.NoopPlugin' } +tasks.remove(assemble) // Not published so no need to assemble + compileJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked" // no unit tests test.enabled = false integTest.enabled = false - diff --git a/distribution/bwc/build.gradle b/distribution/bwc/build.gradle index 1c833a104ce..f1bb123411c 100644 --- a/distribution/bwc/build.gradle +++ b/distribution/bwc/build.gradle @@ -49,6 +49,7 @@ if (project.name == 'bwc-stable-snapshot') { if (enabled) { apply plugin: 'distribution' + tasks.remove(assemble) // Not published so no need to assemble def (String major, String minor, String bugfix) = bwcVersion.split('\\.') def (String currentMajor, String currentMinor, String currentBugfix) = version.split('\\.') diff --git a/plugins/examples/build.gradle b/plugins/examples/build.gradle index e69de29bb2d..150e2826f39 100644 --- a/plugins/examples/build.gradle +++ b/plugins/examples/build.gradle @@ -0,0 +1,9 @@ +// Subprojects aren't published so do not assemble +gradle.projectsEvaluated { + subprojects { + Task assemble = project.tasks.findByName('assemble') + if (assemble) { + project.tasks.remove(assemble) + } + } +} diff --git a/plugins/jvm-example/build.gradle b/plugins/jvm-example/build.gradle index fb362e6fa36..5e4523adc0f 100644 --- a/plugins/jvm-example/build.gradle +++ b/plugins/jvm-example/build.gradle @@ -21,6 +21,7 @@ esplugin { description 'Demonstrates all the pluggable Java entry points in Elasticsearch' classname 'org.elasticsearch.plugin.example.JvmExamplePlugin' } +tasks.remove(assemble) // Not published so no need to assemble // no unit tests test.enabled = false @@ -47,4 +48,3 @@ integTestCluster { integTestRunner { systemProperty 'external.address', "${ -> exampleFixture.addressAndPort }" } - diff --git a/test/fixtures/example-fixture/build.gradle b/test/fixtures/example-fixture/build.gradle index 17a4586a54d..7eb6afd50e4 100644 --- a/test/fixtures/example-fixture/build.gradle +++ b/test/fixtures/example-fixture/build.gradle @@ -19,3 +19,4 @@ apply plugin: 'elasticsearch.build' test.enabled = false +tasks.remove(assemble) // Not published so no need to assemble