Skip to content

Commit ff2ced3

Browse files
Merge remote-tracking branch 'elastic/master' into 42340
2 parents cb89655 + a322e0d commit ff2ced3

File tree

568 files changed

+6804
-11651
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

568 files changed

+6804
-11651
lines changed

benchmarks/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ archivesBaseName = 'elasticsearch-benchmarks'
2727
test.enabled = false
2828

2929
dependencies {
30-
compile("org.elasticsearch:elasticsearch:${version}") {
30+
compile(project(":server")) {
3131
// JMH ships with the conflicting version 4.6. This prevents us from using jopt-simple in benchmarks (which should be ok) but allows
3232
// us to invoke the JMH uberjar as usual.
3333
exclude group: 'net.sf.jopt-simple', module: 'jopt-simple'

build.gradle

Lines changed: 4 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -209,68 +209,7 @@ allprojects {
209209
javadoc.options.addStringOption('Xdoclint:all,-missing', '-quiet')
210210
}
211211

212-
/* Sets up the dependencies that we build as part of this project but
213-
register as though they were external to resolve internally. We register
214-
them as external dependencies so the build plugin that we use can be used
215-
to build elasticsearch plugins outside of the elasticsearch source tree. */
216-
ext.projectSubstitutions = [
217-
"org.elasticsearch.gradle:build-tools:${version}": ':build-tools',
218-
"org.elasticsearch:rest-api-spec:${version}": ':rest-api-spec',
219-
"org.elasticsearch:elasticsearch:${version}": ':server',
220-
"org.elasticsearch:elasticsearch-cli:${version}": ':libs:elasticsearch-cli',
221-
"org.elasticsearch:elasticsearch-core:${version}": ':libs:core',
222-
"org.elasticsearch:elasticsearch-nio:${version}": ':libs:nio',
223-
"org.elasticsearch:elasticsearch-x-content:${version}": ':libs:x-content',
224-
"org.elasticsearch:elasticsearch-geo:${version}": ':libs:elasticsearch-geo',
225-
"org.elasticsearch:elasticsearch-secure-sm:${version}": ':libs:secure-sm',
226-
"org.elasticsearch:elasticsearch-ssl-config:${version}": ':libs:elasticsearch-ssl-config',
227-
"org.elasticsearch.client:elasticsearch-rest-client:${version}": ':client:rest',
228-
"org.elasticsearch.client:elasticsearch-rest-client-sniffer:${version}": ':client:sniffer',
229-
"org.elasticsearch.client:elasticsearch-rest-high-level-client:${version}": ':client:rest-high-level',
230-
"org.elasticsearch.client:test:${version}": ':client:test',
231-
"org.elasticsearch.client:transport:${version}": ':client:transport',
232-
"org.elasticsearch.plugin:elasticsearch-scripting-painless-spi:${version}": ':modules:lang-painless:spi',
233-
"org.elasticsearch.test:framework:${version}": ':test:framework',
234-
"org.elasticsearch.test:logger-usage:${version}": ':test:logger-usage',
235-
"org.elasticsearch.xpack.test:feature-aware:${version}": ':x-pack:test:feature-aware',
236-
// for transport client
237-
"org.elasticsearch.plugin:transport-netty4-client:${version}": ':modules:transport-netty4',
238-
"org.elasticsearch.plugin:reindex-client:${version}": ':modules:reindex',
239-
"org.elasticsearch.plugin:lang-mustache-client:${version}": ':modules:lang-mustache',
240-
"org.elasticsearch.plugin:parent-join-client:${version}": ':modules:parent-join',
241-
"org.elasticsearch.plugin:aggs-matrix-stats-client:${version}": ':modules:aggs-matrix-stats',
242-
"org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator',
243-
"org.elasticsearch.plugin:rank-eval-client:${version}": ':modules:rank-eval',
244-
// for security example plugins
245-
"org.elasticsearch.plugin:x-pack-core:${version}": ':x-pack:plugin:core'
246-
]
247-
248-
/*
249-
* Gradle only resolve project substitutions during dependency resolution but
250-
* we sometimes want to do the resolution at other times. This creates a
251-
* convenient method we can call to do it.
252-
*/
253-
ext.dependencyToProject = { Dependency dep ->
254-
if (dep instanceof ProjectDependency) {
255-
return dep.dependencyProject
256-
} else {
257-
String substitution = projectSubstitutions.get("${dep.group}:${dep.name}:${dep.version}")
258-
if (substitution != null) {
259-
return findProject(substitution)
260-
}
261-
return null
262-
}
263-
}
264-
265212
project.afterEvaluate {
266-
configurations.matching { it.canBeResolved }.all {
267-
resolutionStrategy.dependencySubstitution { DependencySubstitutions subs ->
268-
projectSubstitutions.each { k,v ->
269-
subs.substitute(subs.module(k)).with(subs.project(v))
270-
}
271-
}
272-
}
273-
274213
// Handle javadoc dependencies across projects. Order matters: the linksOffline for
275214
// org.elasticsearch:elasticsearch must be the last one or all the links for the
276215
// other packages (e.g org.elasticsearch.client) will point to server rather than
@@ -279,10 +218,10 @@ allprojects {
279218
String artifactsHost = VersionProperties.elasticsearch.endsWith("-SNAPSHOT") ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
280219
Closure sortClosure = { a, b -> b.group <=> a.group }
281220
Closure depJavadocClosure = { shadowed, dep ->
282-
if (dep.group == null || false == dep.group.startsWith('org.elasticsearch')) {
221+
if ((dep instanceof ProjectDependency) == false) {
283222
return
284223
}
285-
Project upstreamProject = project.ext.dependencyToProject(dep)
224+
Project upstreamProject = dep.dependencyProject
286225
if (upstreamProject == null) {
287226
return
288227
}
@@ -338,8 +277,8 @@ gradle.projectsEvaluated {
338277
integTest.mustRunAfter test
339278
}
340279
configurations.matching { it.canBeResolved }.all { Configuration configuration ->
341-
dependencies.all { Dependency dep ->
342-
Project upstreamProject = dependencyToProject(dep)
280+
dependencies.matching { it instanceof ProjectDependency }.all { ProjectDependency dep ->
281+
Project upstreamProject = dep.dependencyProject
343282
if (upstreamProject != null) {
344283
if (project.path == upstreamProject.path) {
345284
// TODO: distribution integ tests depend on themselves (!), fix that
@@ -552,31 +491,6 @@ gradle.projectsEvaluated {
552491
}
553492
}
554493

555-
if (System.properties.get("build.compare") != null) {
556-
apply plugin: 'compare-gradle-builds'
557-
compareGradleBuilds {
558-
ext.referenceProject = System.properties.get("build.compare")
559-
doFirst {
560-
if (file(referenceProject).exists() == false) {
561-
throw new GradleException(
562-
"Use git worktree to check out a version to compare against to ../elasticsearch_build_reference"
563-
)
564-
}
565-
}
566-
sourceBuild {
567-
gradleVersion = gradle.getGradleVersion()
568-
projectDir = referenceProject
569-
tasks = ["clean", "assemble"]
570-
arguments = ["-Dbuild.compare_friendly=true"]
571-
}
572-
targetBuild {
573-
tasks = ["clean", "assemble"]
574-
// use -Dorg.gradle.java.home= to alter jdk versions
575-
arguments = ["-Dbuild.compare_friendly=true"]
576-
}
577-
}
578-
}
579-
580494
allprojects {
581495
task resolveAllDependencies {
582496
dependsOn tasks.matching { it.name == "pullFixture"}

buildSrc/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ if (project != rootProject) {
148148
distribution project(':distribution:archives:linux-tar')
149149
distribution project(':distribution:archives:oss-linux-tar')
150150
}
151+
152+
// for external projects we want to remove the marker file indicating we are running the Elasticsearch project
153+
processResources {
154+
exclude 'buildSrc.marker'
155+
}
151156

152157
String localDownloads = "${rootProject.buildDir}/local-downloads"
153158
task setupLocalDownloads(type:Copy) {

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.elasticsearch.gradle
2020

21+
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension
2122
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
2223
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2324
import groovy.transform.CompileDynamic
@@ -77,7 +78,6 @@ import org.gradle.authentication.http.HttpHeaderAuthentication
7778
import org.gradle.external.javadoc.CoreJavadocOptions
7879
import org.gradle.internal.jvm.Jvm
7980
import org.gradle.language.base.plugins.LifecycleBasePlugin
80-
import org.gradle.process.CommandLineArgumentProvider
8181
import org.gradle.process.ExecResult
8282
import org.gradle.process.ExecSpec
8383
import org.gradle.util.GradleVersion
@@ -259,7 +259,7 @@ class BuildPlugin implements Plugin<Project> {
259259
if (ext.get('buildDocker')) {
260260
(ext.get('requiresDocker') as List<Task>).add(task)
261261
} else {
262-
task.enabled = false
262+
task.onlyIf { false }
263263
}
264264
}
265265

@@ -530,39 +530,43 @@ class BuildPlugin implements Plugin<Project> {
530530
static void configurePomGeneration(Project project) {
531531
// Only works with `enableFeaturePreview('STABLE_PUBLISHING')`
532532
// https://github.com/gradle/gradle/issues/5696#issuecomment-396965185
533-
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom generatePOMTask ->
534-
// The GenerateMavenPom task is aggressive about setting the destination, instead of fighting it,
535-
// just make a copy.
536-
ExtraPropertiesExtension ext = generatePOMTask.extensions.getByType(ExtraPropertiesExtension)
537-
ext.set('pomFileName', null)
538-
generatePOMTask.doLast {
539-
project.copy { CopySpec spec ->
540-
spec.from generatePOMTask.destination
541-
spec.into "${project.buildDir}/distributions"
542-
spec.rename {
543-
ext.has('pomFileName') && ext.get('pomFileName') == null ?
544-
"${project.convention.getPlugin(BasePluginConvention).archivesBaseName}-${project.version}.pom" :
545-
ext.get('pomFileName')
533+
// dummy task to depend on the real pom generation
534+
project.plugins.withType(MavenPublishPlugin).whenPluginAdded {
535+
Task generatePomTask = project.tasks.create("generatePom")
536+
Task assemble = project.tasks.findByName('assemble')
537+
if (assemble) {
538+
assemble.dependsOn(generatePomTask)
539+
}
540+
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom pomTask ->
541+
// The GenerateMavenPom task is aggressive about setting the destination, instead of fighting it,
542+
// just make a copy.
543+
ExtraPropertiesExtension ext = pomTask.extensions.getByType(ExtraPropertiesExtension)
544+
ext.set('pomFileName', null)
545+
pomTask.doLast {
546+
project.copy { CopySpec spec ->
547+
spec.from pomTask.destination
548+
spec.into "${project.buildDir}/distributions"
549+
spec.rename {
550+
ext.has('pomFileName') && ext.get('pomFileName') == null ?
551+
"${project.convention.getPlugin(BasePluginConvention).archivesBaseName}-${project.version}.pom" :
552+
ext.get('pomFileName')
553+
}
546554
}
547555
}
548556
}
549-
// build poms with assemble (if the assemble task exists)
550-
Task assemble = project.tasks.findByName('assemble')
551-
if (assemble && assemble.enabled) {
552-
assemble.dependsOn(generatePOMTask)
553-
}
554-
}
555-
project.plugins.withType(MavenPublishPlugin).whenPluginAdded {
557+
generatePomTask.dependsOn = ['generatePomFileForNebulaPublication']
556558
PublishingExtension publishing = project.extensions.getByType(PublishingExtension)
557559
publishing.publications.all { MavenPublication publication -> // we only deal with maven
558560
// add exclusions to the pom directly, for each of the transitive deps of this project's deps
559561
publication.pom.withXml(fixupDependencies(project))
560562
}
561563
project.plugins.withType(ShadowPlugin).whenPluginAdded {
562-
MavenPublication publication = publishing.publications.maybeCreate('nebula', MavenPublication)
564+
MavenPublication publication = publishing.publications.maybeCreate('shadow', MavenPublication)
563565
publication.with {
564-
artifacts = [ project.tasks.getByName('shadowJar') ]
566+
ShadowExtension shadow = project.extensions.getByType(ShadowExtension)
567+
shadow.component(publication)
565568
}
569+
generatePomTask.dependsOn = ['generatePomFileForShadowPublication']
566570
}
567571
}
568572
}
@@ -690,6 +694,12 @@ class BuildPlugin implements Plugin<Project> {
690694
project.tasks.withType(Jar) { Jar jarTask ->
691695
// we put all our distributable files under distributions
692696
jarTask.destinationDir = new File(project.buildDir, 'distributions')
697+
project.plugins.withType(ShadowPlugin).whenPluginAdded {
698+
// ensure the original jar task places its output in 'libs' so we don't overwrite it with the shadowjar
699+
if (jarTask instanceof ShadowJar == false) {
700+
jarTask.destinationDir = new File(project.buildDir, 'libs')
701+
}
702+
}
693703
// fixup the jar manifest
694704
jarTask.doFirst {
695705
// this doFirst is added before the info plugin, therefore it will run
@@ -716,10 +726,6 @@ class BuildPlugin implements Plugin<Project> {
716726
jarTask.manifest.attributes('Change': shortHash)
717727
}
718728
}
719-
// Force manifest entries that change by nature to a constant to be able to compare builds more effectively
720-
if (System.properties.getProperty("build.compare_friendly", "false") == "true") {
721-
jarTask.manifest.getAttributes().clear()
722-
}
723729
}
724730

725731
// add license/notice files
@@ -744,12 +750,6 @@ class BuildPlugin implements Plugin<Project> {
744750
}
745751
}
746752
project.plugins.withType(ShadowPlugin).whenPluginAdded {
747-
/*
748-
* When we use the shadow plugin we entirely replace the
749-
* normal jar with the shadow jar so we no longer want to run
750-
* the jar task.
751-
*/
752-
project.tasks.getByName(JavaPlugin.JAR_TASK_NAME).enabled = false
753753
project.tasks.getByName('shadowJar').configure { ShadowJar shadowJar ->
754754
/*
755755
* Replace the default "shadow" classifier with null
@@ -768,7 +768,6 @@ class BuildPlugin implements Plugin<Project> {
768768
}
769769
// Make sure we assemble the shadow jar
770770
project.tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME).dependsOn project.tasks.getByName('shadowJar')
771-
project.artifacts.add('apiElements', project.tasks.getByName('shadowJar'))
772771
}
773772
}
774773

@@ -882,6 +881,7 @@ class BuildPlugin implements Plugin<Project> {
882881

883882
project.plugins.withType(ShadowPlugin).whenPluginAdded {
884883
// Test against a shadow jar if we made one
884+
test.classpath -= project.configurations.getByName('bundle')
885885
test.classpath -= project.tasks.getByName('compileJava').outputs.files
886886
test.classpath += project.tasks.getByName('shadowJar').outputs.files
887887

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,23 @@
1919
package org.elasticsearch.gradle.plugin
2020

2121
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
22-
import nebula.plugin.publishing.maven.MavenScmPlugin
2322
import org.elasticsearch.gradle.BuildPlugin
2423
import org.elasticsearch.gradle.NoticeTask
2524
import org.elasticsearch.gradle.Version
2625
import org.elasticsearch.gradle.VersionProperties
2726
import org.elasticsearch.gradle.test.RestIntegTestTask
2827
import org.elasticsearch.gradle.test.RunTask
2928
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
29+
import org.elasticsearch.gradle.tool.ClasspathUtils
3030
import org.gradle.api.InvalidUserDataException
3131
import org.gradle.api.Plugin
3232
import org.gradle.api.Project
3333
import org.gradle.api.Task
3434
import org.gradle.api.publish.maven.MavenPublication
3535
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
36-
import org.gradle.api.publish.maven.tasks.GenerateMavenPom
3736
import org.gradle.api.tasks.Copy
3837
import org.gradle.api.tasks.SourceSet
3938
import org.gradle.api.tasks.bundling.Zip
40-
import org.gradle.jvm.tasks.Jar
4139

4240
import java.util.regex.Matcher
4341
import java.util.regex.Pattern
@@ -131,31 +129,21 @@ class PluginBuildPlugin implements Plugin<Project> {
131129
}
132130

133131
private void configurePublishing(Project project, PluginPropertiesExtension extension) {
134-
// Only configure publishing if applied externally
135-
if (extension.hasClientJar) {
136-
project.plugins.apply(MavenScmPlugin.class)
137-
// Only change Jar tasks, we don't want a -client zip so we can't change archivesBaseName
138-
project.tasks.withType(Jar) {
139-
baseName = baseName + "-client"
140-
}
141-
// always configure publishing for client jars
142-
project.plugins.apply(MavenScmPlugin.class)
143-
project.publishing.publications.nebula(MavenPublication).artifactId(extension.name + "-client")
144-
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom generatePOMTask ->
145-
generatePOMTask.ext.pomFileName = "${project.archivesBaseName}-client-${project.versions.elasticsearch}.pom"
146-
}
147-
} else {
148-
if (project.plugins.hasPlugin(MavenPublishPlugin)) {
149-
project.publishing.publications.nebula(MavenPublication).artifactId(extension.name)
150-
}
151-
132+
if (project.plugins.hasPlugin(MavenPublishPlugin)) {
133+
project.publishing.publications.nebula(MavenPublication).artifactId(extension.name)
152134
}
135+
153136
}
154137

155138
private static void configureDependencies(Project project) {
156139
project.dependencies {
157-
compileOnly "org.elasticsearch:elasticsearch:${project.versions.elasticsearch}"
158-
testCompile "org.elasticsearch.test:framework:${project.versions.elasticsearch}"
140+
if (ClasspathUtils.isElasticsearchProject()) {
141+
compileOnly project.project(':server')
142+
testCompile project.project(':test:framework')
143+
} else {
144+
compileOnly "org.elasticsearch:elasticsearch:${project.versions.elasticsearch}"
145+
testCompile "org.elasticsearch.test:framework:${project.versions.elasticsearch}"
146+
}
159147
// we "upgrade" these optional deps to provided for plugins, since they will run
160148
// with a full elasticsearch server that includes optional deps
161149
compileOnly "org.locationtech.spatial4j:spatial4j:${project.versions.spatial4j}"
@@ -260,8 +248,6 @@ class PluginBuildPlugin implements Plugin<Project> {
260248
project.artifacts.add('zip', bundle)
261249
}
262250

263-
/** Adds a task to move jar and associated files to a "-client" name. */
264-
265251
static final Pattern GIT_PATTERN = Pattern.compile(/git@([^:]+):([^\.]+)\.git/)
266252

267253
/** Find the reponame. */

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesExtension.groovy

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ class PluginPropertiesExtension {
4747
@Input
4848
boolean hasNativeController = false
4949

50-
/** Indicates whether the plugin jar should be made available for the transport client. */
51-
@Input
52-
boolean hasClientJar = false
53-
5450
/** True if the plugin requires the elasticsearch keystore to exist, false otherwise. */
5551
@Input
5652
boolean requiresKeystore = false

0 commit comments

Comments
 (0)