Skip to content

Commit 2222e5f

Browse files
author
David Roberts
committed
Merge branch 'master' into log_file_format_finder
2 parents cd9d17f + 19ef41e commit 2222e5f

File tree

1,340 files changed

+39318
-17014
lines changed

Some content is hidden

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

1,340 files changed

+39318
-17014
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Contributing to the Elasticsearch codebase
9595
JDK 10 is required to build Elasticsearch. You must have a JDK 10 installation
9696
with the environment variable `JAVA_HOME` referencing the path to Java home for
9797
your JDK 10 installation. By default, tests use the same runtime as `JAVA_HOME`.
98-
However, since Elasticsearch, supports JDK 8 the build supports compiling with
98+
However, since Elasticsearch supports JDK 8, the build supports compiling with
9999
JDK 10 and testing on a JDK 8 runtime; to do this, set `RUNTIME_JAVA_HOME`
100100
pointing to the Java home of a JDK 8 installation. Note that this mechanism can
101101
be used to test against other JDKs as well, this is not only limited to JDK 8.
@@ -325,21 +325,19 @@ common configurations in our build and how we use them:
325325

326326
<dl>
327327
<dt>`compile`</dt><dd>Code that is on the classpath at both compile and
328-
runtime. If the [`shadow`][shadow-plugin] plugin is applied to the project then
329-
this code is bundled into the jar produced by the project.</dd>
328+
runtime.</dd>
330329
<dt>`runtime`</dt><dd>Code that is not on the classpath at compile time but is
331330
on the classpath at runtime. We mostly use this configuration to make sure that
332331
we do not accidentally compile against dependencies of our dependencies also
333332
known as "transitive" dependencies".</dd>
334-
<dt>`compileOnly`</dt><dd>Code that is on the classpath at comile time but that
333+
<dt>`compileOnly`</dt><dd>Code that is on the classpath at compile time but that
335334
should not be shipped with the project because it is "provided" by the runtime
336335
somehow. Elasticsearch plugins use this configuration to include dependencies
337336
that are bundled with Elasticsearch's server.</dd>
338-
<dt>`shadow`</dt><dd>Only available in projects with the shadow plugin. Code
339-
that is on the classpath at both compile and runtime but it *not* bundled into
340-
the jar produced by the project. If you depend on a project with the `shadow`
341-
plugin then you need to depend on this configuration because it will bring
342-
along all of the dependencies you need at runtime.</dd>
337+
<dt>`bundle`</dt><dd>Only available in projects with the shadow plugin,
338+
dependencies with this configuration are bundled into the jar produced by the
339+
build. Since IDEs do not understand this configuration we rig them to treat
340+
dependencies in this configuration as `compile` dependencies.</dd>
343341
<dt>`testCompile`</dt><dd>Code that is on the classpath for compiling tests
344342
that are part of this project but not production code. The canonical example
345343
of this is `junit`.</dd>

build.gradle

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import org.elasticsearch.gradle.LoggedExec
2222
import org.elasticsearch.gradle.Version
2323
import org.elasticsearch.gradle.VersionCollection
2424
import org.elasticsearch.gradle.VersionProperties
25+
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
2526
import org.gradle.plugins.ide.eclipse.model.SourceFolder
2627
import org.gradle.util.GradleVersion
2728
import org.gradle.util.DistributionLocator
@@ -87,8 +88,15 @@ subprojects {
8788
}
8889
}
8990
}
91+
repositories {
92+
maven {
93+
name = 'localTest'
94+
url = "${rootProject.buildDir}/local-test-repo"
95+
}
96+
}
9097
}
9198
}
99+
92100
plugins.withType(BuildPlugin).whenPluginAdded {
93101
project.licenseFile = project.rootProject.file('licenses/APACHE-LICENSE-2.0.txt')
94102
project.noticeFile = project.rootProject.file('NOTICE.txt')
@@ -228,6 +236,7 @@ subprojects {
228236
"org.elasticsearch.client:elasticsearch-rest-high-level-client:${version}": ':client:rest-high-level',
229237
"org.elasticsearch.client:test:${version}": ':client:test',
230238
"org.elasticsearch.client:transport:${version}": ':client:transport',
239+
"org.elasticsearch.plugin:elasticsearch-scripting-painless-spi:${version}": ':modules:lang-painless:spi',
231240
"org.elasticsearch.test:framework:${version}": ':test:framework',
232241
"org.elasticsearch.distribution.integ-test-zip:elasticsearch:${version}": ':distribution:archives:integ-test-zip',
233242
"org.elasticsearch.distribution.zip:elasticsearch:${version}": ':distribution:archives:zip',
@@ -296,7 +305,7 @@ subprojects {
296305
// org.elasticsearch:elasticsearch must be the last one or all the links for the
297306
// other packages (e.g org.elasticsearch.client) will point to server rather than
298307
// their own artifacts.
299-
if (project.plugins.hasPlugin(BuildPlugin)) {
308+
if (project.plugins.hasPlugin(BuildPlugin) || project.plugins.hasPlugin(PluginBuildPlugin)) {
300309
String artifactsHost = VersionProperties.elasticsearch.isSnapshot() ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
301310
Closure sortClosure = { a, b -> b.group <=> a.group }
302311
Closure depJavadocClosure = { shadowed, dep ->
@@ -314,13 +323,6 @@ subprojects {
314323
*/
315324
project.evaluationDependsOn(upstreamProject.path)
316325
project.javadoc.source += upstreamProject.javadoc.source
317-
/*
318-
* Do not add those projects to the javadoc classpath because
319-
* we are going to resolve them with their source instead.
320-
*/
321-
project.javadoc.classpath = project.javadoc.classpath.filter { f ->
322-
false == upstreamProject.configurations.archives.artifacts.files.files.contains(f)
323-
}
324326
/*
325327
* Instead we need the upstream project's javadoc classpath so
326328
* we don't barf on the classes that it references.
@@ -337,16 +339,16 @@ subprojects {
337339
project.configurations.compile.dependencies
338340
.findAll()
339341
.toSorted(sortClosure)
340-
.each({ c -> depJavadocClosure(hasShadow, c) })
342+
.each({ c -> depJavadocClosure(false, c) })
341343
project.configurations.compileOnly.dependencies
342344
.findAll()
343345
.toSorted(sortClosure)
344-
.each({ c -> depJavadocClosure(hasShadow, c) })
346+
.each({ c -> depJavadocClosure(false, c) })
345347
if (hasShadow) {
346-
project.configurations.shadow.dependencies
348+
project.configurations.bundle.dependencies
347349
.findAll()
348350
.toSorted(sortClosure)
349-
.each({ c -> depJavadocClosure(false, c) })
351+
.each({ c -> depJavadocClosure(true, c) })
350352
}
351353
}
352354
}
@@ -515,25 +517,18 @@ allprojects {
515517
allprojects {
516518
/*
517519
* IntelliJ and Eclipse don't know about the shadow plugin so when we're
518-
* in "IntelliJ mode" or "Eclipse mode" add "runtime" dependencies
519-
* eveywhere where we see a "shadow" dependency which will cause them to
520-
* reference shadowed projects directly rather than rely on the shadowing
521-
* to include them. This is the correct thing for it to do because it
522-
* doesn't run the jar shadowing at all. This isn't needed for the project
520+
* in "IntelliJ mode" or "Eclipse mode" switch "bundle" dependencies into
521+
* regular "compile" dependencies. This isn't needed for the project
523522
* itself because the IDE configuration is done by SourceSets but it is
524523
* *is* needed for projects that depends on the project doing the shadowing.
525524
* Without this they won't properly depend on the shadowed project.
526525
*/
527526
if (isEclipse || isIdea) {
528-
configurations.all { Configuration configuration ->
529-
dependencies.all { Dependency dep ->
530-
if (dep instanceof ProjectDependency) {
531-
if (dep.getTargetConfiguration() == 'shadow') {
532-
configuration.dependencies.add(project.dependencies.project(path: dep.dependencyProject.path, configuration: 'runtime'))
533-
}
534-
}
535-
}
536-
}
527+
project.plugins.withType(ShadowPlugin).whenPluginAdded {
528+
project.afterEvaluate {
529+
project.configurations.compile.extendsFrom project.configurations.bundle
530+
}
531+
}
537532
}
538533
}
539534

buildSrc/build.gradle

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ dependencies {
102102
compile 'com.netflix.nebula:gradle-info-plugin:3.0.3'
103103
compile 'org.eclipse.jgit:org.eclipse.jgit:3.2.0.201312181205-r'
104104
compile 'com.perforce:p4java:2012.3.551082' // THIS IS SUPPOSED TO BE OPTIONAL IN THE FUTURE....
105-
compile 'de.thetaphi:forbiddenapis:2.5'
106105
compile 'org.apache.rat:apache-rat:0.11'
107106
compile "org.elasticsearch:jna:4.5.1"
108107
compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
@@ -162,11 +161,24 @@ if (project != rootProject) {
162161
// it's fine as we run them as part of :buildSrc
163162
test.enabled = false
164163
task integTest(type: Test) {
164+
// integration test requires the local testing repo for example plugin builds
165+
dependsOn project.rootProject.allprojects.collect {
166+
it.tasks.matching { it.name == 'publishNebulaPublicationToLocalTestRepository'}
167+
}
165168
exclude "**/*Tests.class"
166169
include "**/*IT.class"
167170
testClassesDirs = sourceSets.test.output.classesDirs
168171
classpath = sourceSets.test.runtimeClasspath
169172
inputs.dir(file("src/testKit"))
173+
// tell BuildExamplePluginsIT where to find the example plugins
174+
systemProperty (
175+
'test.build-tools.plugin.examples',
176+
files(
177+
project(':example-plugins').subprojects.collect { it.projectDir }
178+
).asPath,
179+
)
180+
systemProperty 'test.local-test-repo-path', "${rootProject.buildDir}/local-test-repo"
181+
systemProperty 'test.lucene-snapshot-revision', (versions.lucene =~ /\w+-snapshot-([a-z0-9]+)/)[0][1]
170182
}
171183
check.dependsOn(integTest)
172184

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

Lines changed: 41 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,21 @@ class BuildPlugin implements Plugin<Project> {
7979
}
8080
project.pluginManager.apply('java')
8181
project.pluginManager.apply('carrotsearch.randomized-testing')
82-
// these plugins add lots of info to our jars
82+
configureConfigurations(project)
8383
configureJars(project) // jar config must be added before info broker
84+
// these plugins add lots of info to our jars
8485
project.pluginManager.apply('nebula.info-broker')
8586
project.pluginManager.apply('nebula.info-basic')
8687
project.pluginManager.apply('nebula.info-java')
8788
project.pluginManager.apply('nebula.info-scm')
8889
project.pluginManager.apply('nebula.info-jar')
8990

91+
project.getTasks().create("buildResources", ExportElasticsearchBuildResourcesTask)
92+
9093
globalBuildInfo(project)
9194
configureRepositories(project)
92-
configureConfigurations(project)
9395
project.ext.versions = VersionProperties.versions
96+
configureSourceSets(project)
9497
configureCompile(project)
9598
configureJavadoc(project)
9699
configureSourcesJar(project)
@@ -101,6 +104,7 @@ class BuildPlugin implements Plugin<Project> {
101104
configureDependenciesInfo(project)
102105
}
103106

107+
104108
/** Performs checks on the build environment and prints information about the build environment. */
105109
static void globalBuildInfo(Project project) {
106110
if (project.rootProject.ext.has('buildChecksDone') == false) {
@@ -418,8 +422,10 @@ class BuildPlugin implements Plugin<Project> {
418422
project.configurations.compile.dependencies.all(disableTransitiveDeps)
419423
project.configurations.testCompile.dependencies.all(disableTransitiveDeps)
420424
project.configurations.compileOnly.dependencies.all(disableTransitiveDeps)
425+
421426
project.plugins.withType(ShadowPlugin).whenPluginAdded {
422-
project.configurations.shadow.dependencies.all(disableTransitiveDeps)
427+
Configuration bundle = project.configurations.create('bundle')
428+
bundle.dependencies.all(disableTransitiveDeps)
423429
}
424430
}
425431

@@ -525,11 +531,16 @@ class BuildPlugin implements Plugin<Project> {
525531
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom generatePOMTask ->
526532
// The GenerateMavenPom task is aggressive about setting the destination, instead of fighting it,
527533
// just make a copy.
534+
generatePOMTask.ext.pomFileName = null
528535
doLast {
529536
project.copy {
530537
from generatePOMTask.destination
531538
into "${project.buildDir}/distributions"
532-
rename { "${project.archivesBaseName}-${project.version}.pom" }
539+
rename {
540+
generatePOMTask.ext.pomFileName == null ?
541+
"${project.archivesBaseName}-${project.version}.pom" :
542+
generatePOMTask.ext.pomFileName
543+
}
533544
}
534545
}
535546
// build poms with assemble (if the assemble task exists)
@@ -551,37 +562,26 @@ class BuildPlugin implements Plugin<Project> {
551562
project.publishing {
552563
publications {
553564
nebula(MavenPublication) {
554-
artifact project.tasks.shadowJar
555-
artifactId = project.archivesBaseName
556-
/*
557-
* Configure the pom to include the "shadow" as compile dependencies
558-
* because that is how we're using them but remove all other dependencies
559-
* because they've been shaded into the jar.
560-
*/
561-
pom.withXml { XmlProvider xml ->
562-
Node root = xml.asNode()
563-
root.remove(root.dependencies)
564-
Node dependenciesNode = root.appendNode('dependencies')
565-
project.configurations.shadow.allDependencies.each {
566-
if (false == it instanceof SelfResolvingDependency) {
567-
Node dependencyNode = dependenciesNode.appendNode('dependency')
568-
dependencyNode.appendNode('groupId', it.group)
569-
dependencyNode.appendNode('artifactId', it.name)
570-
dependencyNode.appendNode('version', it.version)
571-
dependencyNode.appendNode('scope', 'compile')
572-
}
573-
}
574-
// Be tidy and remove the element if it is empty
575-
if (dependenciesNode.children.empty) {
576-
root.remove(dependenciesNode)
577-
}
578-
}
565+
artifacts = [ project.tasks.shadowJar ]
579566
}
580567
}
581568
}
582569
}
583570
}
571+
}
584572

573+
/**
574+
* Add dependencies that we are going to bundle to the compile classpath.
575+
*/
576+
static void configureSourceSets(Project project) {
577+
project.plugins.withType(ShadowPlugin).whenPluginAdded {
578+
['main', 'test'].each {name ->
579+
SourceSet sourceSet = project.sourceSets.findByName(name)
580+
if (sourceSet != null) {
581+
sourceSet.compileClasspath += project.configurations.bundle
582+
}
583+
}
584+
}
585585
}
586586

587587
/** Adds compiler settings to the project */
@@ -601,7 +601,6 @@ class BuildPlugin implements Plugin<Project> {
601601
} else {
602602
options.fork = true
603603
options.forkOptions.javaHome = compilerJavaHomeFile
604-
options.forkOptions.memoryMaximumSize = "512m"
605604
}
606605
if (targetCompatibilityVersion == JavaVersion.VERSION_1_8) {
607606
// compile with compact 3 profile by default
@@ -761,9 +760,16 @@ class BuildPlugin implements Plugin<Project> {
761760
* better to be safe
762761
*/
763762
mergeServiceFiles()
763+
/*
764+
* Bundle dependencies of the "bundled" configuration.
765+
*/
766+
configurations = [project.configurations.bundle]
764767
}
765768
// Make sure we assemble the shadow jar
766769
project.tasks.assemble.dependsOn project.tasks.shadowJar
770+
project.artifacts {
771+
apiElements project.tasks.shadowJar
772+
}
767773
}
768774
}
769775

@@ -796,6 +802,8 @@ class BuildPlugin implements Plugin<Project> {
796802
systemProperty 'tests.task', path
797803
systemProperty 'tests.security.manager', 'true'
798804
systemProperty 'jna.nosys', 'true'
805+
// TODO: remove this deprecation compatibility setting for 7.0
806+
systemProperty 'es.aggregations.enable_scripted_metric_agg_param', 'false'
799807
systemProperty 'compiler.java', project.ext.compilerJavaVersion.getMajorVersion()
800808
if (project.ext.inFipsJvm) {
801809
systemProperty 'runtime.java', project.ext.runtimeJavaVersion.getMajorVersion() + "FIPS"
@@ -868,13 +876,8 @@ class BuildPlugin implements Plugin<Project> {
868876
exclude '**/*$*.class'
869877

870878
project.plugins.withType(ShadowPlugin).whenPluginAdded {
871-
/*
872-
* If we make a shaded jar we test against it.
873-
*/
879+
// Test against a shadow jar if we made one
874880
classpath -= project.tasks.compileJava.outputs.files
875-
classpath -= project.configurations.compile
876-
classpath -= project.configurations.runtime
877-
classpath += project.configurations.shadow
878881
classpath += project.tasks.shadowJar.outputs.files
879882
dependsOn project.tasks.shadowJar
880883
}
@@ -900,26 +903,6 @@ class BuildPlugin implements Plugin<Project> {
900903
additionalTest.dependsOn(project.tasks.testClasses)
901904
project.check.dependsOn(additionalTest)
902905
});
903-
904-
project.plugins.withType(ShadowPlugin).whenPluginAdded {
905-
/*
906-
* We need somewhere to configure dependencies that we don't wish
907-
* to shade into the jar. The shadow plugin creates a "shadow"
908-
* configuration which is *almost* exactly that. It is never
909-
* bundled into the shaded jar but is used for main source
910-
* compilation. Unfortunately, by default it is not used for
911-
* *test* source compilation and isn't used in tests at all. This
912-
* change makes it available for test compilation.
913-
*
914-
* Note that this isn't going to work properly with qa projects
915-
* but they have no business applying the shadow plugin in the
916-
* firstplace.
917-
*/
918-
SourceSet testSourceSet = project.sourceSets.findByName('test')
919-
if (testSourceSet != null) {
920-
testSourceSet.compileClasspath += project.configurations.shadow
921-
}
922-
}
923906
}
924907

925908
private static configurePrecommit(Project project) {
@@ -931,7 +914,7 @@ class BuildPlugin implements Plugin<Project> {
931914
it.group.startsWith('org.elasticsearch') == false
932915
} - project.configurations.compileOnly
933916
project.plugins.withType(ShadowPlugin).whenPluginAdded {
934-
project.dependencyLicenses.dependencies += project.configurations.shadow.fileCollection {
917+
project.dependencyLicenses.dependencies += project.configurations.bundle.fileCollection {
935918
it.group.startsWith('org.elasticsearch') == false
936919
}
937920
}
@@ -942,7 +925,7 @@ class BuildPlugin implements Plugin<Project> {
942925
deps.runtimeConfiguration = project.configurations.runtime
943926
project.plugins.withType(ShadowPlugin).whenPluginAdded {
944927
deps.runtimeConfiguration = project.configurations.create('infoDeps')
945-
deps.runtimeConfiguration.extendsFrom(project.configurations.runtime, project.configurations.shadow)
928+
deps.runtimeConfiguration.extendsFrom(project.configurations.runtime, project.configurations.bundle)
946929
}
947930
deps.compileOnlyConfiguration = project.configurations.compileOnly
948931
project.afterEvaluate {

0 commit comments

Comments
 (0)