-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build: Shadow x-pack:protocol into x-pack:plugin:core #32240
Changes from 15 commits
519c3f0
8e6bf29
9783529
6f4c706
1eefd66
f2feb0b
82e5f8c
90b02b2
d53a38a
8420ea6
bad3c1b
17322bd
16cf779
4413a6b
640b4f7
99d91d7
f3d7a5e
d23123d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -386,6 +386,9 @@ class BuildPlugin implements Plugin<Project> { | |
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 */ | ||
|
@@ -873,11 +876,20 @@ class BuildPlugin implements Plugin<Project> { | |
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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this is new, but I think this will resolve the configuration at configuration time which is undesirable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It mimics what we do above for the |
||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,24 @@ 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 | ||
/* | ||
* 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. | ||
*/ | ||
project.afterEvaluate { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That works! Awesome! |
||
if (project.plugins.hasPlugin(ShadowPlugin)) { | ||
from project.shadowJar | ||
from project.configurations.shadow | ||
} else { | ||
from project.jar | ||
from 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') { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to link to the
shadow
to be 100% clear on what plugin is meant.There are often multiple Gradle plugins doing the same thing and its easy to get confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linked!