Skip to content

Commit 192e6de

Browse files
author
Hendrik Muhs
committed
Merge branch 'master' of github.com:elastic/elasticsearch into feature/fib
2 parents a0b72c9 + a296829 commit 192e6de

File tree

2,105 files changed

+75953
-25042
lines changed

Some content is hidden

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

2,105 files changed

+75953
-25042
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>

benchmarks/build.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ apply plugin: 'elasticsearch.build'
2121
apply plugin: 'application'
2222
mainClassName = 'org.openjdk.jmh.Main'
2323

24-
// Not published so no need to assemble
25-
tasks.remove(assemble)
26-
build.dependsOn.remove('assemble')
27-
24+
assemble.enabled = false
2825
archivesBaseName = 'elasticsearch-benchmarks'
2926

3027
test.enabled = false

build.gradle

Lines changed: 35 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,15 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19+
1920
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
21+
import org.apache.tools.ant.taskdefs.condition.Os
2022
import org.elasticsearch.gradle.BuildPlugin
21-
import org.elasticsearch.gradle.LoggedExec
2223
import org.elasticsearch.gradle.Version
2324
import org.elasticsearch.gradle.VersionCollection
2425
import org.elasticsearch.gradle.VersionProperties
26+
import org.elasticsearch.gradle.plugin.PluginBuildPlugin
2527
import org.gradle.plugins.ide.eclipse.model.SourceFolder
26-
import org.gradle.util.GradleVersion
27-
import org.gradle.util.DistributionLocator
28-
import org.apache.tools.ant.taskdefs.condition.Os
29-
import org.apache.tools.ant.filters.ReplaceTokens
30-
31-
import java.nio.file.Files
32-
import java.nio.file.Path
33-
import java.security.MessageDigest
3428

3529
plugins {
3630
id 'com.gradle.build-scan' version '1.13.2'
@@ -87,8 +81,15 @@ subprojects {
8781
}
8882
}
8983
}
84+
repositories {
85+
maven {
86+
name = 'localTest'
87+
url = "${rootProject.buildDir}/local-test-repo"
88+
}
89+
}
9090
}
9191
}
92+
9293
plugins.withType(BuildPlugin).whenPluginAdded {
9394
project.licenseFile = project.rootProject.file('licenses/APACHE-LICENSE-2.0.txt')
9495
project.noticeFile = project.rootProject.file('NOTICE.txt')
@@ -228,6 +229,7 @@ subprojects {
228229
"org.elasticsearch.client:elasticsearch-rest-high-level-client:${version}": ':client:rest-high-level',
229230
"org.elasticsearch.client:test:${version}": ':client:test',
230231
"org.elasticsearch.client:transport:${version}": ':client:transport',
232+
"org.elasticsearch.plugin:elasticsearch-scripting-painless-spi:${version}": ':modules:lang-painless:spi',
231233
"org.elasticsearch.test:framework:${version}": ':test:framework',
232234
"org.elasticsearch.distribution.integ-test-zip:elasticsearch:${version}": ':distribution:archives:integ-test-zip',
233235
"org.elasticsearch.distribution.zip:elasticsearch:${version}": ':distribution:archives:zip',
@@ -296,7 +298,7 @@ subprojects {
296298
// org.elasticsearch:elasticsearch must be the last one or all the links for the
297299
// other packages (e.g org.elasticsearch.client) will point to server rather than
298300
// their own artifacts.
299-
if (project.plugins.hasPlugin(BuildPlugin)) {
301+
if (project.plugins.hasPlugin(BuildPlugin) || project.plugins.hasPlugin(PluginBuildPlugin)) {
300302
String artifactsHost = VersionProperties.elasticsearch.isSnapshot() ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
301303
Closure sortClosure = { a, b -> b.group <=> a.group }
302304
Closure depJavadocClosure = { shadowed, dep ->
@@ -314,13 +316,6 @@ subprojects {
314316
*/
315317
project.evaluationDependsOn(upstreamProject.path)
316318
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-
}
324319
/*
325320
* Instead we need the upstream project's javadoc classpath so
326321
* we don't barf on the classes that it references.
@@ -337,16 +332,16 @@ subprojects {
337332
project.configurations.compile.dependencies
338333
.findAll()
339334
.toSorted(sortClosure)
340-
.each({ c -> depJavadocClosure(hasShadow, c) })
335+
.each({ c -> depJavadocClosure(false, c) })
341336
project.configurations.compileOnly.dependencies
342337
.findAll()
343338
.toSorted(sortClosure)
344-
.each({ c -> depJavadocClosure(hasShadow, c) })
339+
.each({ c -> depJavadocClosure(false, c) })
345340
if (hasShadow) {
346-
project.configurations.shadow.dependencies
341+
project.configurations.bundle.dependencies
347342
.findAll()
348343
.toSorted(sortClosure)
349-
.each({ c -> depJavadocClosure(false, c) })
344+
.each({ c -> depJavadocClosure(true, c) })
350345
}
351346
}
352347
}
@@ -510,30 +505,33 @@ allprojects {
510505
tasks.cleanEclipse.dependsOn(wipeEclipseSettings)
511506
// otherwise the eclipse merging is *super confusing*
512507
tasks.eclipse.dependsOn(cleanEclipse, copyEclipseSettings)
508+
509+
// work arround https://github.com/gradle/gradle/issues/6582
510+
tasks.eclipseProject.mustRunAfter tasks.cleanEclipseProject
511+
tasks.matching { it.name == 'eclipseClasspath' }.all {
512+
it.mustRunAfter { tasks.cleanEclipseClasspath }
513+
}
514+
tasks.matching { it.name == 'eclipseJdt' }.all {
515+
it.mustRunAfter { tasks.cleanEclipseJdt }
516+
}
517+
tasks.copyEclipseSettings.mustRunAfter tasks.wipeEclipseSettings
513518
}
514519

515520
allprojects {
516521
/*
517522
* 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
523+
* in "IntelliJ mode" or "Eclipse mode" switch "bundle" dependencies into
524+
* regular "compile" dependencies. This isn't needed for the project
523525
* itself because the IDE configuration is done by SourceSets but it is
524526
* *is* needed for projects that depends on the project doing the shadowing.
525527
* Without this they won't properly depend on the shadowed project.
526528
*/
527529
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-
}
530+
project.plugins.withType(ShadowPlugin).whenPluginAdded {
531+
project.afterEvaluate {
532+
project.configurations.compile.extendsFrom project.configurations.bundle
533+
}
534+
}
537535
}
538536
}
539537

@@ -574,76 +572,18 @@ wrapper {
574572
}
575573
}
576574

577-
static void assertLinesInFile(final Path path, final List<String> expectedLines) {
578-
final List<String> actualLines = Files.readAllLines(path)
579-
int line = 0
580-
for (final String expectedLine : expectedLines) {
581-
final String actualLine = actualLines.get(line)
582-
if (expectedLine != actualLine) {
583-
throw new GradleException("expected line [${line + 1}] in [${path}] to be [${expectedLine}] but was [${actualLine}]")
584-
}
585-
line++
586-
}
587-
}
588-
589-
/*
590-
* Check that all generated JARs have our NOTICE.txt and an appropriate
591-
* LICENSE.txt in them. We configurate this in gradle but we'd like to
592-
* be extra paranoid.
593-
*/
594-
subprojects { project ->
595-
project.tasks.withType(Jar).whenTaskAdded { jarTask ->
596-
final Task extract = project.task("extract${jarTask.name.capitalize()}", type: LoggedExec) {
597-
dependsOn jarTask
598-
ext.destination = project.buildDir.toPath().resolve("jar-extracted/${jarTask.name}")
599-
commandLine "${->new File(rootProject.compilerJavaHome, 'bin/jar')}",
600-
'xf', "${-> jarTask.outputs.files.singleFile}", 'META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'
601-
workingDir destination
602-
onlyIf {jarTask.enabled}
603-
doFirst {
604-
project.delete(destination)
605-
Files.createDirectories(destination)
606-
}
607-
}
608-
609-
final Task checkNotice = project.task("verify${jarTask.name.capitalize()}Notice") {
610-
dependsOn extract
611-
onlyIf {jarTask.enabled}
612-
doLast {
613-
final List<String> noticeLines = Files.readAllLines(project.noticeFile.toPath())
614-
final Path noticePath = extract.destination.resolve('META-INF/NOTICE.txt')
615-
assertLinesInFile(noticePath, noticeLines)
616-
}
617-
}
618-
project.check.dependsOn checkNotice
619-
620-
final Task checkLicense = project.task("verify${jarTask.name.capitalize()}License") {
621-
dependsOn extract
622-
onlyIf {jarTask.enabled}
623-
doLast {
624-
final List<String> licenseLines = Files.readAllLines(project.licenseFile.toPath())
625-
final Path licensePath = extract.destination.resolve('META-INF/LICENSE.txt')
626-
assertLinesInFile(licensePath, licenseLines)
627-
}
628-
}
629-
project.check.dependsOn checkLicense
630-
}
631-
}
632-
633575
/* Remove assemble/dependenciesInfo on all qa projects because we don't need to publish
634576
* artifacts for them. */
635577
gradle.projectsEvaluated {
636578
subprojects {
637579
if (project.path.startsWith(':qa')) {
638580
Task assemble = project.tasks.findByName('assemble')
639581
if (assemble) {
640-
project.tasks.remove(assemble)
641-
project.build.dependsOn.remove('assemble')
582+
assemble.enabled = false
642583
}
643584
Task dependenciesInfo = project.tasks.findByName('dependenciesInfo')
644585
if (dependenciesInfo) {
645-
project.tasks.remove(dependenciesInfo)
646-
project.precommit.dependsOn.remove('dependenciesInfo')
586+
dependenciesInfo.enabled = false
647587
}
648588
}
649589
}

buildSrc/build.gradle

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* under the License.
1818
*/
1919
import java.nio.file.Files
20+
import org.gradle.util.GradleVersion
2021

2122
plugins {
2223
id 'java-gradle-plugin'
@@ -102,7 +103,6 @@ dependencies {
102103
compile 'com.netflix.nebula:gradle-info-plugin:3.0.3'
103104
compile 'org.eclipse.jgit:org.eclipse.jgit:3.2.0.201312181205-r'
104105
compile 'com.perforce:p4java:2012.3.551082' // THIS IS SUPPOSED TO BE OPTIONAL IN THE FUTURE....
105-
compile 'de.thetaphi:forbiddenapis:2.5'
106106
compile 'org.apache.rat:apache-rat:0.11'
107107
compile "org.elasticsearch:jna:4.5.1"
108108
compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
@@ -162,11 +162,23 @@ if (project != rootProject) {
162162
// it's fine as we run them as part of :buildSrc
163163
test.enabled = false
164164
task integTest(type: Test) {
165+
// integration test requires the local testing repo for example plugin builds
166+
dependsOn project.rootProject.allprojects.collect {
167+
it.tasks.matching { it.name == 'publishNebulaPublicationToLocalTestRepository'}
168+
}
165169
exclude "**/*Tests.class"
166-
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

0 commit comments

Comments
 (0)