From 519c3f0c54838a11e05209dbad9359975532c4cf Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Wed, 18 Jul 2018 11:35:03 -0400 Subject: [PATCH 01/17] WIP --- .../elasticsearch/gradle/BuildPlugin.groovy | 3 +++ .../gradle/plugin/PluginBuildPlugin.groovy | 23 ++++++++----------- x-pack/plugin/core/build.gradle | 21 +++++++++-------- x-pack/plugin/deprecation/build.gradle | 2 +- x-pack/plugin/graph/build.gradle | 2 +- x-pack/plugin/logstash/build.gradle | 2 +- x-pack/plugin/ml/build.gradle | 2 +- x-pack/plugin/monitoring/build.gradle | 4 ++-- x-pack/plugin/rollup/build.gradle | 2 +- x-pack/plugin/security/build.gradle | 4 ++-- x-pack/plugin/sql/build.gradle | 2 +- x-pack/plugin/upgrade/build.gradle | 4 ++-- x-pack/plugin/watcher/build.gradle | 2 +- x-pack/qa/security-client-tests/build.gradle | 2 +- .../build.gradle | 2 +- x-pack/qa/security-migrate-tests/build.gradle | 2 +- x-pack/qa/transport-client-tests/build.gradle | 2 +- x-pack/transport-client/build.gradle | 4 ++-- 18 files changed, 42 insertions(+), 43 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 219d00ba64032..9122dfda32f68 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -379,6 +379,9 @@ class BuildPlugin implements Plugin { project.configurations.compile.dependencies.all(disableTransitiveDeps) project.configurations.testCompile.dependencies.all(disableTransitiveDeps) project.configurations.compileOnly.dependencies.all(disableTransitiveDeps) + project.plugins.withType(ShadowPlugin).whenPluginAdded { + project.configurations.shadow.dependencies.all(disableTransitiveDeps) + } } /** Adds repositories used by ES dependencies */ 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 7f6f337e8a906..2efa29fbad669 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy @@ -48,18 +48,6 @@ public class PluginBuildPlugin extends BuildPlugin { @Override public void apply(Project project) { super.apply(project) - project.plugins.withType(ShadowPlugin).whenPluginAdded { - /* - * We've not tested these plugins together and we're fairly sure - * they aren't going to work properly as is *and* we're not really - * sure *why* you'd want to shade stuff in plugins. So we throw an - * exception here to make you come and read this comment. If you - * have a need for shadow while building plugins then know that you - * are probably going to have to fight with gradle for a while.... - */ - throw new InvalidUserDataException('elasticsearch.esplugin is not ' - + 'compatible with com.github.johnrengelman.shadow'); - } configureDependencies(project) // this afterEvaluate must happen before the afterEvaluate added by integTest creation, // so that the file name resolution for installing the plugin will be setup @@ -153,8 +141,15 @@ public class PluginBuildPlugin extends BuildPlugin { include(buildProperties.descriptorOutput.name) } from pluginMetadata // metadata (eg custom security policy) - from project.jar // this plugin's jar - from project.configurations.runtime - project.configurations.compileOnly // the dep jars + project.afterEvaluate { + if (project.plugins.hasPlugin(ShadowPlugin)) { + from project.shadowJar + from project.configurations.shadow + } else { + from project.jar // this plugin's jar + from project.configurations.runtime - project.configurations.compileOnly // the dep jars + } + } // extra files for the plugin to go into the zip from('src/main/packaging') // TODO: move all config/bin/_size/etc into packaging from('src/main') { diff --git a/x-pack/plugin/core/build.gradle b/x-pack/plugin/core/build.gradle index ca926fa0d54cc..e9ba78cec9a72 100644 --- a/x-pack/plugin/core/build.gradle +++ b/x-pack/plugin/core/build.gradle @@ -8,6 +8,7 @@ import java.nio.file.StandardCopyOption apply plugin: 'elasticsearch.esplugin' apply plugin: 'nebula.maven-base-publish' apply plugin: 'nebula.maven-scm' +apply plugin: 'com.github.johnrengelman.shadow' archivesBaseName = 'x-pack-core' @@ -28,19 +29,19 @@ dependencyLicenses { dependencies { compileOnly "org.elasticsearch:elasticsearch:${version}" compile project(':x-pack:protocol') - compile "org.apache.httpcomponents:httpclient:${versions.httpclient}" - compile "org.apache.httpcomponents:httpcore:${versions.httpcore}" - compile "org.apache.httpcomponents:httpcore-nio:${versions.httpcore}" - compile "org.apache.httpcomponents:httpasyncclient:${versions.httpasyncclient}" + shadow "org.apache.httpcomponents:httpclient:${versions.httpclient}" + shadow "org.apache.httpcomponents:httpcore:${versions.httpcore}" + shadow "org.apache.httpcomponents:httpcore-nio:${versions.httpcore}" + shadow "org.apache.httpcomponents:httpasyncclient:${versions.httpasyncclient}" - compile "commons-logging:commons-logging:${versions.commonslogging}" - compile "commons-codec:commons-codec:${versions.commonscodec}" + shadow "commons-logging:commons-logging:${versions.commonslogging}" + shadow "commons-codec:commons-codec:${versions.commonscodec}" // security deps - compile 'com.unboundid:unboundid-ldapsdk:3.2.0' - compile 'org.bouncycastle:bcprov-jdk15on:1.59' - compile 'org.bouncycastle:bcpkix-jdk15on:1.59' - compile project(path: ':modules:transport-netty4', configuration: 'runtime') + shadow 'com.unboundid:unboundid-ldapsdk:3.2.0' + shadow 'org.bouncycastle:bcprov-jdk15on:1.59' + shadow 'org.bouncycastle:bcpkix-jdk15on:1.59' + shadow project(path: ':modules:transport-netty4', configuration: 'runtime') testCompile 'org.elasticsearch:securemock:1.2' testCompile "org.elasticsearch:mocksocket:${versions.mocksocket}" diff --git a/x-pack/plugin/deprecation/build.gradle b/x-pack/plugin/deprecation/build.gradle index d89eb62e88492..3746287d615ff 100644 --- a/x-pack/plugin/deprecation/build.gradle +++ b/x-pack/plugin/deprecation/build.gradle @@ -10,7 +10,7 @@ esplugin { archivesBaseName = 'x-pack-deprecation' dependencies { - compileOnly "org.elasticsearch.plugin:x-pack-core:${version}" + compileOnly project(path: xpackModule('core'), configuration: 'shadow') } run { diff --git a/x-pack/plugin/graph/build.gradle b/x-pack/plugin/graph/build.gradle index 3ddd2ebee04a2..2b0f592b72040 100644 --- a/x-pack/plugin/graph/build.gradle +++ b/x-pack/plugin/graph/build.gradle @@ -10,7 +10,7 @@ esplugin { archivesBaseName = 'x-pack-graph' dependencies { - compileOnly "org.elasticsearch.plugin:x-pack-core:${version}" + compileOnly project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') } diff --git a/x-pack/plugin/logstash/build.gradle b/x-pack/plugin/logstash/build.gradle index 5a9b5d6cbe5ea..2e158a90ac7ab 100644 --- a/x-pack/plugin/logstash/build.gradle +++ b/x-pack/plugin/logstash/build.gradle @@ -10,7 +10,7 @@ esplugin { archivesBaseName = 'x-pack-logstash' dependencies { - compileOnly "org.elasticsearch.plugin:x-pack-core:${version}" + compileOnly project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') } diff --git a/x-pack/plugin/ml/build.gradle b/x-pack/plugin/ml/build.gradle index 4c3cc9eef9313..a673016133724 100644 --- a/x-pack/plugin/ml/build.gradle +++ b/x-pack/plugin/ml/build.gradle @@ -40,7 +40,7 @@ compileJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try, compileTestJava.options.compilerArgs << "-Xlint:-deprecation,-rawtypes,-serial,-try,-unchecked" dependencies { - compileOnly "org.elasticsearch.plugin:x-pack-core:${version}" + compileOnly project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') // This should not be here testCompile project(path: xpackModule('security'), configuration: 'testArtifacts') diff --git a/x-pack/plugin/monitoring/build.gradle b/x-pack/plugin/monitoring/build.gradle index 3fde6cd8c3775..a452ef09a20ff 100644 --- a/x-pack/plugin/monitoring/build.gradle +++ b/x-pack/plugin/monitoring/build.gradle @@ -13,7 +13,7 @@ esplugin { archivesBaseName = 'x-pack-monitoring' dependencies { - compileOnly "org.elasticsearch.plugin:x-pack-core:${version}" + compileOnly project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') // monitoring deps @@ -66,7 +66,7 @@ task internalClusterTest(type: RandomizedTestingTask, include '**/*IT.class' systemProperty 'es.set.netty.runtime.available.processors', 'false' } -check.dependsOn internalClusterTest +check.dependsOn internalClusterTest internalClusterTest.mustRunAfter test // also add an "alias" task to make typing on the command line easier task icTest { diff --git a/x-pack/plugin/rollup/build.gradle b/x-pack/plugin/rollup/build.gradle index ff9c30ed9a934..649a89bc2cdee 100644 --- a/x-pack/plugin/rollup/build.gradle +++ b/x-pack/plugin/rollup/build.gradle @@ -16,7 +16,7 @@ compileTestJava.options.compilerArgs << "-Xlint:-rawtypes" dependencies { compileOnly "org.elasticsearch:elasticsearch:${version}" - compileOnly "org.elasticsearch.plugin:x-pack-core:${version}" + compileOnly project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') } diff --git a/x-pack/plugin/security/build.gradle b/x-pack/plugin/security/build.gradle index 5bdfdf65014f9..12767dd1df8c2 100644 --- a/x-pack/plugin/security/build.gradle +++ b/x-pack/plugin/security/build.gradle @@ -12,7 +12,7 @@ esplugin { archivesBaseName = 'x-pack-security' dependencies { - compileOnly "org.elasticsearch.plugin:x-pack-core:${version}" + compileOnly project(path: xpackModule('core'), configuration: 'shadow') compileOnly project(path: ':modules:transport-netty4', configuration: 'runtime') compileOnly project(path: ':plugins:transport-nio', configuration: 'runtime') @@ -52,7 +52,7 @@ dependencies { compile "org.apache.httpcomponents:httpasyncclient:${versions.httpasyncclient}" compile "org.apache.httpcomponents:httpcore-nio:${versions.httpcore}" compile "org.apache.httpcomponents:httpclient-cache:${versions.httpclient}" - compile 'com.google.guava:guava:19.0' + compile 'com.google.guava:guava:19.0' testCompile 'org.elasticsearch:securemock:1.2' testCompile "org.elasticsearch:mocksocket:${versions.mocksocket}" diff --git a/x-pack/plugin/sql/build.gradle b/x-pack/plugin/sql/build.gradle index 436837e85b4f0..039e78c14952c 100644 --- a/x-pack/plugin/sql/build.gradle +++ b/x-pack/plugin/sql/build.gradle @@ -19,7 +19,7 @@ archivesBaseName = 'x-pack-sql' integTest.enabled = false dependencies { - compileOnly "org.elasticsearch.plugin:x-pack-core:${version}" + compileOnly project(path: xpackModule('core'), configuration: 'shadow') compileOnly(project(':modules:lang-painless')) { // exclude ASM to not affect featureAware task on Java 10+ exclude group: "org.ow2.asm" diff --git a/x-pack/plugin/upgrade/build.gradle b/x-pack/plugin/upgrade/build.gradle index 8e65f87da3070..f95cde7134c56 100644 --- a/x-pack/plugin/upgrade/build.gradle +++ b/x-pack/plugin/upgrade/build.gradle @@ -14,7 +14,7 @@ esplugin { archivesBaseName = 'x-pack-upgrade' dependencies { - compileOnly "org.elasticsearch.plugin:x-pack-core:${version}" + compileOnly project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') } @@ -39,7 +39,7 @@ task internalClusterTest(type: RandomizedTestingTask, include '**/*IT.class' systemProperty 'es.set.netty.runtime.available.processors', 'false' } -check.dependsOn internalClusterTest +check.dependsOn internalClusterTest internalClusterTest.mustRunAfter test // also add an "alias" task to make typing on the command line easier diff --git a/x-pack/plugin/watcher/build.gradle b/x-pack/plugin/watcher/build.gradle index 2b7b73d37962e..a0feab6746359 100644 --- a/x-pack/plugin/watcher/build.gradle +++ b/x-pack/plugin/watcher/build.gradle @@ -25,7 +25,7 @@ dependencyLicenses { dependencies { compileOnly "org.elasticsearch:elasticsearch:${version}" - compileOnly "org.elasticsearch.plugin:x-pack-core:${version}" + compileOnly project(path: xpackModule('core'), configuration: 'shadow') compileOnly project(path: ':modules:transport-netty4', configuration: 'runtime') compileOnly project(path: ':plugins:transport-nio', configuration: 'runtime') diff --git a/x-pack/qa/security-client-tests/build.gradle b/x-pack/qa/security-client-tests/build.gradle index 4e517f4d3633e..97945fb00efcd 100644 --- a/x-pack/qa/security-client-tests/build.gradle +++ b/x-pack/qa/security-client-tests/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackProject('transport-client').path, configuration: 'runtime') } diff --git a/x-pack/qa/security-example-spi-extension/build.gradle b/x-pack/qa/security-example-spi-extension/build.gradle index b2fac075cb315..7aeed3ad62de6 100644 --- a/x-pack/qa/security-example-spi-extension/build.gradle +++ b/x-pack/qa/security-example-spi-extension/build.gradle @@ -8,7 +8,7 @@ esplugin { } dependencies { - compileOnly project(path: xpackModule('core'), configuration: 'runtime') + compileOnly project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackProject('transport-client').path, configuration: 'runtime') } diff --git a/x-pack/qa/security-migrate-tests/build.gradle b/x-pack/qa/security-migrate-tests/build.gradle index 7ccf6d2349b8b..3a8a0cf100554 100644 --- a/x-pack/qa/security-migrate-tests/build.gradle +++ b/x-pack/qa/security-migrate-tests/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('security'), configuration: 'runtime') testCompile project(path: xpackProject('transport-client').path, configuration: 'runtime') } diff --git a/x-pack/qa/transport-client-tests/build.gradle b/x-pack/qa/transport-client-tests/build.gradle index c864a9084cba8..a94ad8fd59267 100644 --- a/x-pack/qa/transport-client-tests/build.gradle +++ b/x-pack/qa/transport-client-tests/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackProject('transport-client').path, configuration: 'runtime') } diff --git a/x-pack/transport-client/build.gradle b/x-pack/transport-client/build.gradle index 31c05569274de..7155dad5ee60d 100644 --- a/x-pack/transport-client/build.gradle +++ b/x-pack/transport-client/build.gradle @@ -9,8 +9,8 @@ archivesBaseName = 'x-pack-transport' dependencies { // this "api" dependency looks weird, but it is correct, as it contains - // all of x-pack for now, and transport client will be going away in the future. - compile "org.elasticsearch.plugin:x-pack-core:${version}" + // all of x-pack for now, and transport client will be going away in the future. + compile project(path: xpackModule('core'), configuration: 'shadow') compile "org.elasticsearch.client:transport:${version}" testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" testCompile "junit:junit:${versions.junit}" From 8e6bf297067bc8bfbed17c900e4f60c4a3b11753 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 19 Jul 2018 08:37:02 -0400 Subject: [PATCH 02/17] Wip --- .../org/elasticsearch/gradle/BuildPlugin.groovy | 11 +++++++++++ .../gradle/plugin/PluginBuildPlugin.groovy | 13 ++++++++++++- x-pack/qa/transport-client-tests/build.gradle | 2 +- x-pack/transport-client/build.gradle | 3 ++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 9122dfda32f68..9b79ca4827a19 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -340,6 +340,17 @@ class BuildPlugin implements Plugin { // we want to test compileOnly deps! project.configurations.testCompile.extendsFrom(project.configurations.compileOnly) + /* + * If we're using the shadow plugin we don't want "compile" + * dependencies in our "default" configuration or else downstream + * projects will jarhell on the classes that are shaded into the + * jar. + */ + project.plugins.withType(ShadowPlugin).whenPluginAdded { + println("AAA ${project.path} has shadow") + project.configurations.default.setExtendsFrom([project.configurations.shadow]) + } + // we are not shipping these jars, we act like dumb consumers of these things if (project.path.startsWith(':test:fixtures') || project.path == ':build-tools') { return 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 2efa29fbad669..7cc12397d8db7 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy @@ -92,7 +92,18 @@ public class PluginBuildPlugin extends BuildPlugin { } createIntegTestTask(project) createBundleTask(project) - project.configurations.getByName('default').extendsFrom(project.configurations.getByName('runtime')) + + project.configurations.default.extendsFrom(project.configurations.runtime) + /* + * If we're using the shadow plugin we don't want "compile" + * dependencies in our "default" configuration or else downstream + * projects will jarhell on the classes that are shaded into the + * jar. + */ + project.plugins.withType(ShadowPlugin).whenPluginAdded { + project.configurations.default.setExtendsFrom([project.configurations.shadow]) + } + project.tasks.create('run', RunTask) // allow running ES with this plugin in the foreground of a build } diff --git a/x-pack/qa/transport-client-tests/build.gradle b/x-pack/qa/transport-client-tests/build.gradle index a94ad8fd59267..3ece6dd1147c4 100644 --- a/x-pack/qa/transport-client-tests/build.gradle +++ b/x-pack/qa/transport-client-tests/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'shadow') + testCompile "org.elasticsearch.plugin:x-pack-core:${version}" testCompile project(path: xpackProject('transport-client').path, configuration: 'runtime') } diff --git a/x-pack/transport-client/build.gradle b/x-pack/transport-client/build.gradle index 7155dad5ee60d..f87623d4ee8aa 100644 --- a/x-pack/transport-client/build.gradle +++ b/x-pack/transport-client/build.gradle @@ -10,7 +10,8 @@ archivesBaseName = 'x-pack-transport' dependencies { // this "api" dependency looks weird, but it is correct, as it contains // all of x-pack for now, and transport client will be going away in the future. - compile project(path: xpackModule('core'), configuration: 'shadow') + // NOCOMMIT if you don't specify "default" here you get compile or runtime or something. EW! + compile project(path: xpackModule('core')/*, configuration: 'default'*/) compile "org.elasticsearch.client:transport:${version}" testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" testCompile "junit:junit:${versions.junit}" From 9783529a9fabde7cc435ec6629855a0c6ed6fdfd Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 19 Jul 2018 09:42:48 -0400 Subject: [PATCH 03/17] Works --- qa/ccs-unavailable-clusters/build.gradle | 2 +- x-pack/qa/transport-client-tests/build.gradle | 2 +- x-pack/transport-client/build.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qa/ccs-unavailable-clusters/build.gradle b/qa/ccs-unavailable-clusters/build.gradle index d9de422bb43e1..c9ecacc9b0e8b 100644 --- a/qa/ccs-unavailable-clusters/build.gradle +++ b/qa/ccs-unavailable-clusters/build.gradle @@ -21,5 +21,5 @@ apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.test-with-dependencies' dependencies { - testCompile project(path: ':client:rest-high-level', configuration: 'shadow') + testCompile project(path: ':client:rest-high-level', configuration: 'default') } diff --git a/x-pack/qa/transport-client-tests/build.gradle b/x-pack/qa/transport-client-tests/build.gradle index 3ece6dd1147c4..a94ad8fd59267 100644 --- a/x-pack/qa/transport-client-tests/build.gradle +++ b/x-pack/qa/transport-client-tests/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile "org.elasticsearch.plugin:x-pack-core:${version}" + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackProject('transport-client').path, configuration: 'runtime') } diff --git a/x-pack/transport-client/build.gradle b/x-pack/transport-client/build.gradle index f87623d4ee8aa..9b5bc7d8dcbb2 100644 --- a/x-pack/transport-client/build.gradle +++ b/x-pack/transport-client/build.gradle @@ -11,7 +11,7 @@ dependencies { // this "api" dependency looks weird, but it is correct, as it contains // all of x-pack for now, and transport client will be going away in the future. // NOCOMMIT if you don't specify "default" here you get compile or runtime or something. EW! - compile project(path: xpackModule('core')/*, configuration: 'default'*/) + compile project(path: xpackModule('core'), configuration: 'default') compile "org.elasticsearch.client:transport:${version}" testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" testCompile "junit:junit:${versions.junit}" From 6f4c70659a5990cb5d27aa5ac31c267ed6d559a3 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 19 Jul 2018 10:31:39 -0400 Subject: [PATCH 04/17] Wip --- .../src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 9b79ca4827a19..aec9d99be9b97 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -878,7 +878,7 @@ class BuildPlugin implements Plugin { project.check.dependsOn(precommit) project.test.mustRunAfter(precommit) // only require dependency licenses for non-elasticsearch deps - project.dependencyLicenses.dependencies = project.configurations.runtime.fileCollection { + project.dependencyLicenses.dependencies = project.configurations.default.fileCollection { it.group.startsWith('org.elasticsearch') == false } - project.configurations.compileOnly } From 1eefd6666c4915fc25b6c3ef79d3141ebe76e1b2 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 19 Jul 2018 11:24:19 -0400 Subject: [PATCH 05/17] Closer --- .../elasticsearch/gradle/BuildPlugin.groovy | 22 +++++++++---------- .../gradle/plugin/PluginBuildPlugin.groovy | 9 -------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index aec9d99be9b97..da2951a3ce5e9 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -340,17 +340,6 @@ class BuildPlugin implements Plugin { // we want to test compileOnly deps! project.configurations.testCompile.extendsFrom(project.configurations.compileOnly) - /* - * If we're using the shadow plugin we don't want "compile" - * dependencies in our "default" configuration or else downstream - * projects will jarhell on the classes that are shaded into the - * jar. - */ - project.plugins.withType(ShadowPlugin).whenPluginAdded { - println("AAA ${project.path} has shadow") - project.configurations.default.setExtendsFrom([project.configurations.shadow]) - } - // we are not shipping these jars, we act like dumb consumers of these things if (project.path.startsWith(':test:fixtures') || project.path == ':build-tools') { return @@ -878,14 +867,23 @@ class BuildPlugin implements Plugin { project.check.dependsOn(precommit) project.test.mustRunAfter(precommit) // only require dependency licenses for non-elasticsearch deps - project.dependencyLicenses.dependencies = project.configurations.default.fileCollection { + project.dependencyLicenses.dependencies = project.configurations.runtime.fileCollection { it.group.startsWith('org.elasticsearch') == false } - project.configurations.compileOnly + project.plugins.withType(ShadowPlugin).whenPluginAdded { + project.dependencyLicenses.dependencies += project.configurations.shadow.fileCollection { + it.group.startsWith('org.elasticsearch') == false + } + } } private static configureDependenciesInfo(Project project) { Task deps = project.tasks.create("dependenciesInfo", DependenciesInfoTask.class) deps.runtimeConfiguration = project.configurations.runtime + project.plugins.withType(ShadowPlugin).whenPluginAdded { + deps.runtimeConfiguration = project.configurations.create('infoDeps') + deps.runtimeConfiguration.extendsFrom(project.configurations.runtime, project.configurations.shadow) + } deps.compileOnlyConfiguration = project.configurations.compileOnly project.afterEvaluate { deps.mappings = project.dependencyLicenses.mappings 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 7cc12397d8db7..e3e5c97d233ee 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy @@ -94,15 +94,6 @@ public class PluginBuildPlugin extends BuildPlugin { createBundleTask(project) project.configurations.default.extendsFrom(project.configurations.runtime) - /* - * If we're using the shadow plugin we don't want "compile" - * dependencies in our "default" configuration or else downstream - * projects will jarhell on the classes that are shaded into the - * jar. - */ - project.plugins.withType(ShadowPlugin).whenPluginAdded { - project.configurations.default.setExtendsFrom([project.configurations.shadow]) - } project.tasks.create('run', RunTask) // allow running ES with this plugin in the foreground of a build } From f2feb0bdcf81bf529c4b9ca1e4bc060084488d12 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 19 Jul 2018 11:28:24 -0400 Subject: [PATCH 06/17] woops --- qa/ccs-unavailable-clusters/build.gradle | 2 +- x-pack/transport-client/build.gradle | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/qa/ccs-unavailable-clusters/build.gradle b/qa/ccs-unavailable-clusters/build.gradle index c9ecacc9b0e8b..d9de422bb43e1 100644 --- a/qa/ccs-unavailable-clusters/build.gradle +++ b/qa/ccs-unavailable-clusters/build.gradle @@ -21,5 +21,5 @@ apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.test-with-dependencies' dependencies { - testCompile project(path: ':client:rest-high-level', configuration: 'default') + testCompile project(path: ':client:rest-high-level', configuration: 'shadow') } diff --git a/x-pack/transport-client/build.gradle b/x-pack/transport-client/build.gradle index 9b5bc7d8dcbb2..7155dad5ee60d 100644 --- a/x-pack/transport-client/build.gradle +++ b/x-pack/transport-client/build.gradle @@ -10,8 +10,7 @@ archivesBaseName = 'x-pack-transport' dependencies { // this "api" dependency looks weird, but it is correct, as it contains // all of x-pack for now, and transport client will be going away in the future. - // NOCOMMIT if you don't specify "default" here you get compile or runtime or something. EW! - compile project(path: xpackModule('core'), configuration: 'default') + compile project(path: xpackModule('core'), configuration: 'shadow') compile "org.elasticsearch.client:transport:${version}" testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" testCompile "junit:junit:${versions.junit}" From 82e5f8ce593499ecf604c91fe2b99b5db3cac05d Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 19 Jul 2018 11:31:55 -0400 Subject: [PATCH 07/17] More --- x-pack/docs/build.gradle | 8 ++++---- x-pack/qa/full-cluster-restart/build.gradle | 4 ++-- x-pack/qa/ml-basic-multi-node/build.gradle | 2 +- x-pack/qa/ml-disabled/build.gradle | 2 +- x-pack/qa/ml-native-multi-node-tests/build.gradle | 2 +- x-pack/qa/ml-no-bootstrap-tests/build.gradle | 3 +-- x-pack/qa/ml-single-node-tests/build.gradle | 2 +- x-pack/qa/multi-cluster-search-security/build.gradle | 2 +- x-pack/qa/multi-node/build.gradle | 2 +- x-pack/qa/openldap-tests/build.gradle | 3 +-- x-pack/qa/reindex-tests-with-security/build.gradle | 2 +- x-pack/qa/rolling-upgrade-basic/build.gradle | 2 +- x-pack/qa/rolling-upgrade/build.gradle | 4 ++-- x-pack/qa/saml-idp-tests/build.gradle | 3 +-- x-pack/qa/security-setup-password-tests/build.gradle | 2 +- x-pack/qa/smoke-test-graph-with-security/build.gradle | 2 +- x-pack/qa/smoke-test-ml-with-security/build.gradle | 2 +- x-pack/qa/smoke-test-plugins-ssl/build.gradle | 2 +- x-pack/qa/smoke-test-plugins/build.gradle | 2 +- x-pack/qa/smoke-test-security-with-mustache/build.gradle | 2 +- x-pack/qa/smoke-test-watcher-with-security/build.gradle | 2 +- x-pack/qa/smoke-test-watcher/build.gradle | 2 +- x-pack/qa/third-party/hipchat/build.gradle | 2 +- x-pack/qa/third-party/jira/build.gradle | 2 +- x-pack/qa/third-party/pagerduty/build.gradle | 2 +- x-pack/qa/third-party/slack/build.gradle | 2 +- 26 files changed, 31 insertions(+), 34 deletions(-) diff --git a/x-pack/docs/build.gradle b/x-pack/docs/build.gradle index 4176cdeb0b7d6..2ae26044be5ab 100644 --- a/x-pack/docs/build.gradle +++ b/x-pack/docs/build.gradle @@ -30,7 +30,7 @@ buildRestTests.expectedUnconvertedCandidates = [ ] dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: xpackProject('plugin').path, configuration: 'testArtifacts') } @@ -264,7 +264,7 @@ setups['farequote_index'] = ''' airline: type: keyword doc_count: - type: integer + type: integer ''' setups['farequote_data'] = setups['farequote_index'] + ''' - do: @@ -277,7 +277,7 @@ setups['farequote_data'] = setups['farequote_index'] + ''' {"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000", "doc_count": 5} {"index": {"_id":"2"}} {"airline":"JBU","responsetime":877.5927,"time":"2016-02-07T00:00:00+0000", "doc_count": 23} - {"index": {"_id":"3"}} + {"index": {"_id":"3"}} {"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000", "doc_count": 42} ''' setups['farequote_job'] = setups['farequote_data'] + ''' @@ -309,7 +309,7 @@ setups['farequote_datafeed'] = setups['farequote_job'] + ''' "job_id":"farequote", "indexes":"farequote" } -''' +''' setups['server_metrics_index'] = ''' - do: indices.create: diff --git a/x-pack/qa/full-cluster-restart/build.gradle b/x-pack/qa/full-cluster-restart/build.gradle index 78ac1436fd8bc..d7e801dc78a2f 100644 --- a/x-pack/qa/full-cluster-restart/build.gradle +++ b/x-pack/qa/full-cluster-restart/build.gradle @@ -11,7 +11,7 @@ apply plugin: 'elasticsearch.build' test.enabled = false dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile (project(path: xpackModule('security'), configuration: 'runtime')) { // Need to drop the guava dependency here or we get a conflict with watcher's guava dependency. // This is total #$%, but the solution is to get the SAML realm (which uses guava) out of security proper @@ -249,7 +249,7 @@ subprojects { check.dependsOn(integTest) dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('watcher'), configuration: 'runtime') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: xpackModule('security'), configuration: 'testArtifacts') diff --git a/x-pack/qa/ml-basic-multi-node/build.gradle b/x-pack/qa/ml-basic-multi-node/build.gradle index d396d38b22354..3df77aadccbd5 100644 --- a/x-pack/qa/ml-basic-multi-node/build.gradle +++ b/x-pack/qa/ml-basic-multi-node/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('ml'), configuration: 'runtime') } diff --git a/x-pack/qa/ml-disabled/build.gradle b/x-pack/qa/ml-disabled/build.gradle index 22a7dfc74ac73..e914def3507cd 100644 --- a/x-pack/qa/ml-disabled/build.gradle +++ b/x-pack/qa/ml-disabled/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('ml'), configuration: 'runtime') } diff --git a/x-pack/qa/ml-native-multi-node-tests/build.gradle b/x-pack/qa/ml-native-multi-node-tests/build.gradle index 286d4daee8aa5..0395c65b47db2 100644 --- a/x-pack/qa/ml-native-multi-node-tests/build.gradle +++ b/x-pack/qa/ml-native-multi-node-tests/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: xpackModule('ml'), configuration: 'runtime') testCompile project(path: xpackModule('ml'), configuration: 'testArtifacts') diff --git a/x-pack/qa/ml-no-bootstrap-tests/build.gradle b/x-pack/qa/ml-no-bootstrap-tests/build.gradle index cad5201a67b6a..7e252afa3022e 100644 --- a/x-pack/qa/ml-no-bootstrap-tests/build.gradle +++ b/x-pack/qa/ml-no-bootstrap-tests/build.gradle @@ -1,7 +1,6 @@ apply plugin: 'elasticsearch.standalone-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('ml'), configuration: 'runtime') } - diff --git a/x-pack/qa/ml-single-node-tests/build.gradle b/x-pack/qa/ml-single-node-tests/build.gradle index 9fd4a8d44d23f..b62e37894b3c3 100644 --- a/x-pack/qa/ml-single-node-tests/build.gradle +++ b/x-pack/qa/ml-single-node-tests/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('ml'), configuration: 'runtime') } diff --git a/x-pack/qa/multi-cluster-search-security/build.gradle b/x-pack/qa/multi-cluster-search-security/build.gradle index f5265466965c1..5d90f974762bc 100644 --- a/x-pack/qa/multi-cluster-search-security/build.gradle +++ b/x-pack/qa/multi-cluster-search-security/build.gradle @@ -3,7 +3,7 @@ import org.elasticsearch.gradle.test.RestIntegTestTask apply plugin: 'elasticsearch.standalone-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') } diff --git a/x-pack/qa/multi-node/build.gradle b/x-pack/qa/multi-node/build.gradle index 69c7a696ff0be..19729cf367ef5 100644 --- a/x-pack/qa/multi-node/build.gradle +++ b/x-pack/qa/multi-node/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') } integTestCluster { diff --git a/x-pack/qa/openldap-tests/build.gradle b/x-pack/qa/openldap-tests/build.gradle index 5c0399a1d9fa2..24cd6184afa63 100644 --- a/x-pack/qa/openldap-tests/build.gradle +++ b/x-pack/qa/openldap-tests/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'elasticsearch.standalone-test' apply plugin: 'elasticsearch.vagrantsupport' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('security'), configuration: 'testArtifacts') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') } @@ -32,4 +32,3 @@ namingConventions { // integ tests use Tests instead of IT skipIntegTestInDisguise = true } - diff --git a/x-pack/qa/reindex-tests-with-security/build.gradle b/x-pack/qa/reindex-tests-with-security/build.gradle index ddf72f7d45833..097d343b27984 100644 --- a/x-pack/qa/reindex-tests-with-security/build.gradle +++ b/x-pack/qa/reindex-tests-with-security/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('security'), configuration: 'testArtifacts') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: ':modules:reindex') diff --git a/x-pack/qa/rolling-upgrade-basic/build.gradle b/x-pack/qa/rolling-upgrade-basic/build.gradle index 6d5b250b460b7..21ac4414d86b2 100644 --- a/x-pack/qa/rolling-upgrade-basic/build.gradle +++ b/x-pack/qa/rolling-upgrade-basic/build.gradle @@ -7,7 +7,7 @@ import java.nio.charset.StandardCharsets apply plugin: 'elasticsearch.standalone-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') // to be moved in a later commit } diff --git a/x-pack/qa/rolling-upgrade/build.gradle b/x-pack/qa/rolling-upgrade/build.gradle index 351f33b941227..bdf2ea5afc734 100644 --- a/x-pack/qa/rolling-upgrade/build.gradle +++ b/x-pack/qa/rolling-upgrade/build.gradle @@ -10,7 +10,7 @@ apply plugin: 'elasticsearch.build' test.enabled = false dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('security'), configuration: 'runtime') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') // to be moved in a later commit } @@ -284,7 +284,7 @@ subprojects { check.dependsOn(integTest) dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: xpackModule('watcher')) } diff --git a/x-pack/qa/saml-idp-tests/build.gradle b/x-pack/qa/saml-idp-tests/build.gradle index ebb0d88991ff6..752ec6fb3071b 100644 --- a/x-pack/qa/saml-idp-tests/build.gradle +++ b/x-pack/qa/saml-idp-tests/build.gradle @@ -6,7 +6,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: xpackModule('security'), configuration: 'testArtifacts') testCompile 'com.google.jimfs:jimfs:1.1' @@ -84,4 +84,3 @@ thirdPartyAudit.excludes = [ // missing 'com.ibm.icu.lang.UCharacter' ] - diff --git a/x-pack/qa/security-setup-password-tests/build.gradle b/x-pack/qa/security-setup-password-tests/build.gradle index 16accc87a9476..adb159acf6f6b 100644 --- a/x-pack/qa/security-setup-password-tests/build.gradle +++ b/x-pack/qa/security-setup-password-tests/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('security'), configuration: 'runtime') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') } diff --git a/x-pack/qa/smoke-test-graph-with-security/build.gradle b/x-pack/qa/smoke-test-graph-with-security/build.gradle index d3f788d0b06e4..9cdfaffccfbce 100644 --- a/x-pack/qa/smoke-test-graph-with-security/build.gradle +++ b/x-pack/qa/smoke-test-graph-with-security/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') } // bring in graph rest test suite diff --git a/x-pack/qa/smoke-test-ml-with-security/build.gradle b/x-pack/qa/smoke-test-ml-with-security/build.gradle index 2a12aa2f28d3f..84c23add25411 100644 --- a/x-pack/qa/smoke-test-ml-with-security/build.gradle +++ b/x-pack/qa/smoke-test-ml-with-security/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: xpackProject('plugin').path, configuration: 'testArtifacts') } diff --git a/x-pack/qa/smoke-test-plugins-ssl/build.gradle b/x-pack/qa/smoke-test-plugins-ssl/build.gradle index 595c562af3707..5fc47d115f773 100644 --- a/x-pack/qa/smoke-test-plugins-ssl/build.gradle +++ b/x-pack/qa/smoke-test-plugins-ssl/build.gradle @@ -15,7 +15,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') } String outputDir = "${buildDir}/generated-resources/${project.name}" diff --git a/x-pack/qa/smoke-test-plugins/build.gradle b/x-pack/qa/smoke-test-plugins/build.gradle index 4badc9d3509c8..b66903af18bfb 100644 --- a/x-pack/qa/smoke-test-plugins/build.gradle +++ b/x-pack/qa/smoke-test-plugins/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') } ext.pluginsCount = 0 diff --git a/x-pack/qa/smoke-test-security-with-mustache/build.gradle b/x-pack/qa/smoke-test-security-with-mustache/build.gradle index 1c43db0b63e34..d921c5f5b6605 100644 --- a/x-pack/qa/smoke-test-security-with-mustache/build.gradle +++ b/x-pack/qa/smoke-test-security-with-mustache/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') testCompile project(path: ':modules:lang-mustache', configuration: 'runtime') } diff --git a/x-pack/qa/smoke-test-watcher-with-security/build.gradle b/x-pack/qa/smoke-test-watcher-with-security/build.gradle index 0f052074bfbf6..a843641be801f 100644 --- a/x-pack/qa/smoke-test-watcher-with-security/build.gradle +++ b/x-pack/qa/smoke-test-watcher-with-security/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') } // bring in watcher rest test suite diff --git a/x-pack/qa/smoke-test-watcher/build.gradle b/x-pack/qa/smoke-test-watcher/build.gradle index abfd27e729b6d..dc87248df617f 100644 --- a/x-pack/qa/smoke-test-watcher/build.gradle +++ b/x-pack/qa/smoke-test-watcher/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('watcher'), configuration: 'runtime') testCompile project(path: ':modules:lang-mustache', configuration: 'runtime') testCompile project(path: ':modules:lang-painless', configuration: 'runtime') diff --git a/x-pack/qa/third-party/hipchat/build.gradle b/x-pack/qa/third-party/hipchat/build.gradle index cd37d6e738e64..03b6c31969844 100644 --- a/x-pack/qa/third-party/hipchat/build.gradle +++ b/x-pack/qa/third-party/hipchat/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('watcher'), configuration: 'runtime') } diff --git a/x-pack/qa/third-party/jira/build.gradle b/x-pack/qa/third-party/jira/build.gradle index 078fed4dd36e2..3814c8e9a5382 100644 --- a/x-pack/qa/third-party/jira/build.gradle +++ b/x-pack/qa/third-party/jira/build.gradle @@ -7,7 +7,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('watcher'), configuration: 'runtime') } diff --git a/x-pack/qa/third-party/pagerduty/build.gradle b/x-pack/qa/third-party/pagerduty/build.gradle index 683e18caa1c7e..c0f337e160e0a 100644 --- a/x-pack/qa/third-party/pagerduty/build.gradle +++ b/x-pack/qa/third-party/pagerduty/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('watcher'), configuration: 'runtime') } diff --git a/x-pack/qa/third-party/slack/build.gradle b/x-pack/qa/third-party/slack/build.gradle index abcdad0e096e1..431752765f3a0 100644 --- a/x-pack/qa/third-party/slack/build.gradle +++ b/x-pack/qa/third-party/slack/build.gradle @@ -5,7 +5,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core'), configuration: 'runtime') + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('watcher'), configuration: 'runtime') } From 90b02b2af113b9b5abc353999bdbfcbaa050cafc Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 19 Jul 2018 12:35:08 -0400 Subject: [PATCH 08/17] Moar shadow --- x-pack/license-tools/build.gradle | 4 ++-- x-pack/plugin/core/build.gradle | 3 ++- x-pack/qa/smoke-test-monitoring-with-watcher/build.gradle | 3 +-- x-pack/qa/sql/security/build.gradle | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/x-pack/license-tools/build.gradle b/x-pack/license-tools/build.gradle index 3ef08073bbf84..183b9ab50e03b 100644 --- a/x-pack/license-tools/build.gradle +++ b/x-pack/license-tools/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'elasticsearch.build' dependencies { - compile project(xpackModule('core')) + compile project(path: xpackModule('core'), configuration: 'shadow') compile "org.elasticsearch:elasticsearch:${version}" testCompile "org.elasticsearch.test:framework:${version}" } @@ -17,7 +17,7 @@ task buildZip(type: Zip, dependsOn: jar) { into(parentDir + '/lib') { from jar from configurations.runtime - } + } into(parentDir + '/bin') { from 'bin' } diff --git a/x-pack/plugin/core/build.gradle b/x-pack/plugin/core/build.gradle index e9ba78cec9a72..28f55408f7b1f 100644 --- a/x-pack/plugin/core/build.gradle +++ b/x-pack/plugin/core/build.gradle @@ -111,7 +111,8 @@ test { // TODO: don't publish test artifacts just to run messy tests, fix the tests! // https://github.com/elastic/x-plugins/issues/724 configurations { - testArtifacts.extendsFrom testRuntime + testArtifacts.extendsFrom(testRuntime, shadow) + testArtifacts.exclude(group: project(':x-pack:protocol').group, module: project(':x-pack:protocol').name) } task testJar(type: Jar) { appendix 'test' diff --git a/x-pack/qa/smoke-test-monitoring-with-watcher/build.gradle b/x-pack/qa/smoke-test-monitoring-with-watcher/build.gradle index 4e079430562a7..8ce0cde76575a 100644 --- a/x-pack/qa/smoke-test-monitoring-with-watcher/build.gradle +++ b/x-pack/qa/smoke-test-monitoring-with-watcher/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.rest-test' dependencies { - testCompile project(path: xpackModule('core')) + testCompile project(path: xpackModule('core'), configuration: 'shadow') testCompile project(path: xpackModule('watcher')) testCompile project(path: xpackModule('monitoring')) } @@ -24,4 +24,3 @@ integTestCluster { // one of the exporters should configure cluster alerts // setting 'xpack.monitoring.exporters.my_http.cluster_alerts.management.enabled', 'true' } - diff --git a/x-pack/qa/sql/security/build.gradle b/x-pack/qa/sql/security/build.gradle index 15f7734f9422e..f02886f80a103 100644 --- a/x-pack/qa/sql/security/build.gradle +++ b/x-pack/qa/sql/security/build.gradle @@ -1,5 +1,5 @@ dependencies { - testCompile "org.elasticsearch.plugin:x-pack-core:${version}" + testCompile project(path: xpackModule('core'), configuration: 'shadow') } Project mainProject = project @@ -20,7 +20,7 @@ subprojects { } dependencies { - testCompile "org.elasticsearch.plugin:x-pack-core:${version}" + testCompile project(path: xpackModule('core'), configuration: 'shadow') } integTestCluster { From d53a38a95d6e014988d7667abfae6d4f028b9708 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 19 Jul 2018 13:09:22 -0400 Subject: [PATCH 09/17] Revert bad --- .../org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 e3e5c97d233ee..2efa29fbad669 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy @@ -92,9 +92,7 @@ public class PluginBuildPlugin extends BuildPlugin { } createIntegTestTask(project) createBundleTask(project) - - project.configurations.default.extendsFrom(project.configurations.runtime) - + project.configurations.getByName('default').extendsFrom(project.configurations.getByName('runtime')) project.tasks.create('run', RunTask) // allow running ES with this plugin in the foreground of a build } From 8420ea652f4c9413d96abea6a5fd2fd1c4985d66 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 19 Jul 2018 13:13:43 -0400 Subject: [PATCH 10/17] Explain --- .../gradle/plugin/PluginBuildPlugin.groovy | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 2efa29fbad669..f7c6b816a37ec 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy @@ -141,13 +141,22 @@ public class PluginBuildPlugin extends BuildPlugin { include(buildProperties.descriptorOutput.name) } from pluginMetadata // metadata (eg custom security policy) + /* + * We bundle the plugin's jar file and its dependencies. We have + * to wait until the project is evaluated before we know if the + * plug *has* the shadow plugin. If it does we need the shadow + * jar and the deps in the shadow configuration because those are + * the jars that are not bundled into the plugin's jar. Otherwise + * we're fine with the jar an all of the non-provided runtime + * dependencies. + */ project.afterEvaluate { if (project.plugins.hasPlugin(ShadowPlugin)) { from project.shadowJar from project.configurations.shadow } else { - from project.jar // this plugin's jar - from project.configurations.runtime - project.configurations.compileOnly // the dep jars + from project.jar + from project.configurations.runtime - project.configurations.compileOnly } } // extra files for the plugin to go into the zip From bad3c1bca64486d855a0c85b30c4a851e9d2d08f Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 19 Jul 2018 17:31:44 -0400 Subject: [PATCH 11/17] Fix eclipse --- build.gradle | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/build.gradle b/build.gradle index 66f34d8f445de..8df7dc25ded9a 100644 --- a/build.gradle +++ b/build.gradle @@ -466,6 +466,24 @@ allprojects { } } + /* + * Ironically, eclipse doesn't know about the shadow plugin so we replace + * all shadow dependencies with runtime dependencies which will cause + * eclipse to reference shadowed projects. This is the correct thing for + * it to do because it doesn't run the jar shadowing at all. + */ + if (isEclipse) { + configurations.all { Configuration configuration -> + dependencies.all { Dependency dep -> + if (dep instanceof ProjectDependency) { + if (dep.getTargetConfiguration() == 'shadow') { + configuration.dependencies.add(project.dependencies.project(path: dep.dependencyProject.path, configuration: 'runtime')) + } + } + } + } + } + plugins.withType(JavaBasePlugin) { File eclipseBuild = project.file('build-eclipse') eclipse.classpath.defaultOutputDir = eclipseBuild From 17322bd5f19280879bd86b7f4d40a436fd7d57b2 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 20 Jul 2018 09:01:40 -0400 Subject: [PATCH 12/17] Fix intellij --- build.gradle | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/build.gradle b/build.gradle index 8df7dc25ded9a..9210647857aef 100644 --- a/build.gradle +++ b/build.gradle @@ -466,24 +466,6 @@ allprojects { } } - /* - * Ironically, eclipse doesn't know about the shadow plugin so we replace - * all shadow dependencies with runtime dependencies which will cause - * eclipse to reference shadowed projects. This is the correct thing for - * it to do because it doesn't run the jar shadowing at all. - */ - if (isEclipse) { - configurations.all { Configuration configuration -> - dependencies.all { Dependency dep -> - if (dep instanceof ProjectDependency) { - if (dep.getTargetConfiguration() == 'shadow') { - configuration.dependencies.add(project.dependencies.project(path: dep.dependencyProject.path, configuration: 'runtime')) - } - } - } - } - } - plugins.withType(JavaBasePlugin) { File eclipseBuild = project.file('build-eclipse') eclipse.classpath.defaultOutputDir = eclipseBuild @@ -534,6 +516,32 @@ allprojects { tasks.eclipse.dependsOn(cleanEclipse, copyEclipseSettings) } +allprojects { + /* + * IntelliJ and, ironically, Eclipse don't know about the shadow plugin so + * when we're in "IntelliJ mode" or "Eclipse mode" add "runtime" + * dependencies eveywhere where we see a "shadow" dependency which will + * cause them to reference shadowed projects directly rather than rely + * on the shadowing to include them. This is the correct thing for + * it to do because it doesn't run the jar shadowing at all. This isn't + * needed for the project itself because the IDE configuration is done + * by SourceSets but it is *is* needed for projects that depends on the + * project doing the shadowing. Without this they won't properly depend + * on the shadowed project. + */ + if (isEclipse || isIdea) { + configurations.all { Configuration configuration -> + dependencies.all { Dependency dep -> + if (dep instanceof ProjectDependency) { + if (dep.getTargetConfiguration() == 'shadow') { + configuration.dependencies.add(project.dependencies.project(path: dep.dependencyProject.path, configuration: 'runtime')) + } + } + } + } + } +} + // we need to add the same --debug-jvm option as // the real RunTask has, so we can pass it through class Run extends DefaultTask { From 16cf779cff16635c8eecdae6b62754dd1017d827 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 20 Jul 2018 09:14:53 -0400 Subject: [PATCH 13/17] Fix featureAware --- x-pack/test/feature-aware/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/feature-aware/build.gradle b/x-pack/test/feature-aware/build.gradle index 11b0e67183c8f..f6a1f6cb16f2a 100644 --- a/x-pack/test/feature-aware/build.gradle +++ b/x-pack/test/feature-aware/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'elasticsearch.build' dependencies { compile 'org.ow2.asm:asm:6.2' compile "org.elasticsearch:elasticsearch:${version}" - compile "org.elasticsearch.plugin:x-pack-core:${version}" + compile project(path: xpackModule('core'), configuration: 'shadow') testCompile "org.elasticsearch.test:framework:${version}" } From 640b4f7f2da09c348c83854b1a648f3e6f8bd27a Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 23 Jul 2018 18:28:45 -0400 Subject: [PATCH 14/17] Explanation of configurations Includes a start of explaining gradle and gradle projects which feels sort of required before talking about configurations. Not at all finished but a start. --- CONTRIBUTING.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b8f4262ca5ce8..2bef1ebd22a22 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -214,7 +214,7 @@ If your changes affect only the documentation, run: ```sh ./gradlew -p docs check ``` -For more information about testing code examples in the documentation, see +For more information about testing code examples in the documentation, see https://github.com/elastic/elasticsearch/blob/master/docs/README.asciidoc ### Project layout @@ -305,6 +305,39 @@ the `qa` subdirectory functions just like the top level `qa` subdirectory. The Elasticsearch process. The `transport-client` subdirectory contains extensions to Elasticsearch's standard transport client to work properly with x-pack. +### Gradle Build + +We use Gradle to build Elasticsearch because it is flexible enough to not only +build and package Elasticsearch, but also orchestrate all of the ways that we +have to test Elasticsearch. + +#### Configurations + +Gradle organizes dependencies and build artifacts into "configurations" and +allows you to use these configurations arbitrarilly. Here are some of the most +common configurations in our build and how we use them: + +
+
`compile`
Code that is on the classpath at both compile and +runtime. If the `shadow` plugin is applied to the project then this code is +bundled into the jar produced by the project.
+
`runtime`
Code that is not on the classpath at compile time but is +on the classpath at runtime. We mostly use this configuration to make sure that +we do not accidentally compile against dependencies of our dependencies also +known as "transitive" dependencies".
+
`compileOnly`
Code that is on the classpath at comile time but that +should not be shipped with the project because it is "provided" by the runtime +somehow. Elasticsearch plugins use this configuration to include dependencies +that are bundled with Elasticsearch's server.
+
`shadow`
Only available in projects with the shadow plugin. Code +that is on the classpath at both compile and runtime but it *not* bundled into +the jar produced by the project. If you depend on a project with the `shadow` +plugin then you need to depend on this configuration because it will bring +along all of the dependencies you need at runtime.
+
`testCompile`
Code that is on the classpath for compiling tests +that are part of this project but not production code. The canonical example +of this is `junit`.
+
Contributing as part of a class ------------------------------- From 99d91d7d89fa61a466cb6082e55d195d068956a0 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 24 Jul 2018 09:08:27 -0400 Subject: [PATCH 15/17] Wait until the last second! --- .../gradle/plugin/PluginBuildPlugin.groovy | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) 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 bb2585096bfaa..00f178fda9c9f 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy @@ -142,23 +142,12 @@ public class PluginBuildPlugin extends BuildPlugin { } from pluginMetadata // metadata (eg custom security policy) /* - * We bundle the plugin's jar file and its dependencies. We have - * to wait until the project is evaluated before we know if the - * project *has* the shadow plugin. If it does we need the shadow - * jar and the deps in the shadow configuration because those are - * the jars that are not bundled into the plugin's jar. Otherwise - * we're fine with the jar an all of the non-provided runtime - * dependencies. + * If the plugin is using the shadow plugin then we need to bundle + * "shadow" things rather than the default jar and dependencies so + * we don't hit jar hell. */ - project.afterEvaluate { - if (project.plugins.hasPlugin(ShadowPlugin)) { - from project.shadowJar - from project.configurations.shadow - } else { - from project.jar - from project.configurations.runtime - project.configurations.compileOnly - } - } + from { project.plugins.hasPlugin(ShadowPlugin) ? project.shadowJar : project.jar } + from { project.plugins.hasPlugin(ShadowPlugin) ? project.configurations.shadow : project.configurations.runtime - project.configurations.compileOnly } // extra files for the plugin to go into the zip from('src/main/packaging') // TODO: move all config/bin/_size/etc into packaging from('src/main') { From f3d7a5ea918dba61ed7cdba8728fd475dbac06d3 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 24 Jul 2018 09:10:32 -0400 Subject: [PATCH 16/17] Link --- CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2bef1ebd22a22..8ee03c3d999c4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -319,8 +319,8 @@ common configurations in our build and how we use them:
`compile`
Code that is on the classpath at both compile and -runtime. If the `shadow` plugin is applied to the project then this code is -bundled into the jar produced by the project.
+runtime. If the [`shadow`][shadow-plugin] plugin is applied to the project then +this code is bundled into the jar produced by the project.
`runtime`
Code that is not on the classpath at compile time but is on the classpath at runtime. We mostly use this configuration to make sure that we do not accidentally compile against dependencies of our dependencies also @@ -370,3 +370,4 @@ repeating in this section because it has come up in this context. [eclipse]: http://www.eclipse.org/community/eclipse_newsletter/2017/june/ [intellij]: https://blog.jetbrains.com/idea/2017/07/intellij-idea-2017-2-is-here-smart-sleek-and-snappy/ +[shadow-plugin]: https://github.com/johnrengelman/shadow From d23123d8348faf65c474186e160f74d96633c875 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 24 Jul 2018 09:24:07 -0400 Subject: [PATCH 17/17] Fix last jarHell --- x-pack/plugin/security/cli/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/security/cli/build.gradle b/x-pack/plugin/security/cli/build.gradle index 1799a2c7b81e1..19b86dd91c78b 100644 --- a/x-pack/plugin/security/cli/build.gradle +++ b/x-pack/plugin/security/cli/build.gradle @@ -4,7 +4,7 @@ archivesBaseName = 'elasticsearch-security-cli' dependencies { compileOnly "org.elasticsearch:elasticsearch:${version}" - compileOnly xpackProject('plugin:core') + compileOnly project(path: xpackModule('core'), configuration: 'shadow') compile 'org.bouncycastle:bcprov-jdk15on:1.59' compile 'org.bouncycastle:bcpkix-jdk15on:1.59' testImplementation 'com.google.jimfs:jimfs:1.1' @@ -17,4 +17,4 @@ dependencies { dependencyLicenses { mapping from: /bc.*/, to: 'bouncycastle' -} \ No newline at end of file +}