Skip to content

Commit bca77c6

Browse files
committed
Merge branch '6.x' into ccr-6.x
* 6.x: Fix rollup on date fields that don't support epoch_millis (#31890) Revert "Introduce a Hashing Processor (#31087)" (#32179) [test] use randomized runner in packaging tests (#32109) Painless: Fix caching bug and clean up addPainlessClass. (#32142) Fix BwC Tests looking for UUID Pre 6.4 (#32158) (#32169) Call setReferences() on custom referring tokenfilters in _analyze (#32157) Add more contexts to painless execute api (#30511) Add EC2 credential test for repository-s3 (#31918) Fix CP for namingConventions when gradle home has spaces (#31914) Convert Version to Java - clusterformation part1 (#32009) Fix Java 11 javadoc compile problem Improve docs for search preferences (#32098) Configurable password hashing algorithm/cost(#31234) (#32092) [DOCS] Update TLS on Docker for 6.3 ESIndexLevelReplicationTestCase doesn't support replicated failures but it's good to know what they are Switch distribution to new style Requests (#30595) Build: Skip jar tests if jar disabled Build: Move shadow customizations into common code (#32014) Painless: Add PainlessClassBuilder (#32141) Fix accidental duplication of bwc test for script behavior Handle missing values in painless (#30975) (#31903) Build: Make additional test deps of check (#32015) Painless: Fix Bug with Duplicate PainlessClasses (#32110) Adjust translog after versionType removed in 7.0 (#32020) Disable C2 from using AVX-512 on JDK 10 (#32138) [Rollup] Add new capabilities endpoint for concrete rollup indices (#32111) Mute :qa:mixed-cluster indices.stats/10_index/Index - all’ [ML] Wait for aliases in multi-node tests (#32086) Ensure to release translog snapshot in primary-replica resync (#32045) Docs: Fix missing example script quote (#32010) Add Index UUID to `/_stats` Response (#31871) (#32113) [ML] Move analyzer dependencies out of categorization config (#32123) [ML][DOCS] Add missing 6.3.0 release notes (#32099) Updates the build to gradle 4.9 (#32087) Update monitoring template version to 6040099 (#32088) Fix put mappings java API documentation (#31955) Add exclusion option to `keep_types` token filter (#32012)
2 parents de94640 + 838a832 commit bca77c6

File tree

196 files changed

+5828
-2630
lines changed

Some content is hidden

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

196 files changed

+5828
-2630
lines changed

benchmarks/build.gradle

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@
1717
* under the License.
1818
*/
1919

20-
buildscript {
21-
repositories {
22-
maven {
23-
url 'https://plugins.gradle.org/m2/'
24-
}
25-
}
26-
dependencies {
27-
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
28-
}
29-
}
30-
3120
apply plugin: 'elasticsearch.build'
3221

3322
// order of this section matters, see: https://github.com/johnrengelman/shadow/issues/336
@@ -82,10 +71,6 @@ thirdPartyAudit.excludes = [
8271
'org.openjdk.jmh.util.Utils'
8372
]
8473

85-
shadowJar {
86-
classifier = 'benchmarks'
87-
}
88-
8974
runShadow {
9075
executable = new File(project.runtimeJavaHome, 'bin/java')
9176
}

build.gradle

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
20+
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
2121
import org.apache.tools.ant.taskdefs.condition.Os
2222
import org.apache.tools.ant.filters.ReplaceTokens
2323
import org.elasticsearch.gradle.BuildPlugin
@@ -297,18 +297,55 @@ subprojects {
297297
if (project.plugins.hasPlugin(BuildPlugin)) {
298298
String artifactsHost = VersionProperties.elasticsearch.isSnapshot() ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
299299
Closure sortClosure = { a, b -> b.group <=> a.group }
300-
Closure depJavadocClosure = { dep ->
301-
if (dep.group != null && dep.group.startsWith('org.elasticsearch')) {
302-
Project upstreamProject = dependencyToProject(dep)
303-
if (upstreamProject != null) {
304-
project.javadoc.dependsOn "${upstreamProject.path}:javadoc"
305-
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + dep.name.replaceAll('\\.', '/') + '/' + dep.version
306-
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${upstreamProject.buildDir}/docs/javadoc/"
300+
Closure depJavadocClosure = { shadowed, dep ->
301+
if (dep.group == null || false == dep.group.startsWith('org.elasticsearch')) {
302+
return
303+
}
304+
Project upstreamProject = dependencyToProject(dep)
305+
if (upstreamProject == null) {
306+
return
307+
}
308+
if (shadowed) {
309+
/*
310+
* Include the source of shadowed upstream projects so we don't
311+
* have to publish their javadoc.
312+
*/
313+
project.evaluationDependsOn(upstreamProject.path)
314+
project.javadoc.source += upstreamProject.javadoc.source
315+
/*
316+
* Do not add those projects to the javadoc classpath because
317+
* we are going to resolve them with their source instead.
318+
*/
319+
project.javadoc.classpath = project.javadoc.classpath.filter { f ->
320+
false == upstreamProject.configurations.archives.artifacts.files.files.contains(f)
307321
}
322+
/*
323+
* Instead we need the upstream project's javadoc classpath so
324+
* we don't barf on the classes that it references.
325+
*/
326+
project.javadoc.classpath += upstreamProject.javadoc.classpath
327+
} else {
328+
// Link to non-shadowed dependant projects
329+
project.javadoc.dependsOn "${upstreamProject.path}:javadoc"
330+
String artifactPath = dep.group.replaceAll('\\.', '/') + '/' + dep.name.replaceAll('\\.', '/') + '/' + dep.version
331+
project.javadoc.options.linksOffline artifactsHost + "/javadoc/" + artifactPath, "${upstreamProject.buildDir}/docs/javadoc/"
308332
}
309333
}
310-
project.configurations.compile.dependencies.findAll().toSorted(sortClosure).each(depJavadocClosure)
311-
project.configurations.compileOnly.dependencies.findAll().toSorted(sortClosure).each(depJavadocClosure)
334+
boolean hasShadow = project.plugins.hasPlugin(ShadowPlugin)
335+
project.configurations.compile.dependencies
336+
.findAll()
337+
.toSorted(sortClosure)
338+
.each({ c -> depJavadocClosure(hasShadow, c) })
339+
project.configurations.compileOnly.dependencies
340+
.findAll()
341+
.toSorted(sortClosure)
342+
.each({ c -> depJavadocClosure(hasShadow, c) })
343+
if (hasShadow) {
344+
project.configurations.shadow.dependencies
345+
.findAll()
346+
.toSorted(sortClosure)
347+
.each({ c -> depJavadocClosure(false, c) })
348+
}
312349
}
313350
}
314351
}
@@ -531,6 +568,7 @@ subprojects { project ->
531568
commandLine "${->new File(rootProject.compilerJavaHome, 'bin/jar')}",
532569
'xf', "${-> jarTask.outputs.files.singleFile}", 'META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'
533570
workingDir destination
571+
onlyIf {jarTask.enabled}
534572
doFirst {
535573
project.delete(destination)
536574
Files.createDirectories(destination)
@@ -539,6 +577,7 @@ subprojects { project ->
539577

540578
final Task checkNotice = project.task("verify${jarTask.name.capitalize()}Notice") {
541579
dependsOn extract
580+
onlyIf {jarTask.enabled}
542581
doLast {
543582
final List<String> noticeLines = Files.readAllLines(project.noticeFile.toPath())
544583
final Path noticePath = extract.destination.resolve('META-INF/NOTICE.txt')
@@ -549,6 +588,7 @@ subprojects { project ->
549588

550589
final Task checkLicense = project.task("verify${jarTask.name.capitalize()}License") {
551590
dependsOn extract
591+
onlyIf {jarTask.enabled}
552592
doLast {
553593
final List<String> licenseLines = Files.readAllLines(project.licenseFile.toPath())
554594
final Path licensePath = extract.destination.resolve('META-INF/LICENSE.txt')
@@ -590,7 +630,7 @@ if (System.properties.get("build.compare") != null) {
590630
}
591631
}
592632
sourceBuild {
593-
gradleVersion = "4.8.1" // does not default to gradle weapper of project dir, but current version
633+
gradleVersion = gradle.getGradleVersion()
594634
projectDir = referenceProject
595635
tasks = ["clean", "assemble"]
596636
arguments = ["-Dbuild.compare_friendly=true"]

buildSrc/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ dependencies {
104104
compile 'de.thetaphi:forbiddenapis:2.5'
105105
compile 'org.apache.rat:apache-rat:0.11'
106106
compile "org.elasticsearch:jna:4.5.1"
107+
compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
107108
testCompile "junit:junit:${props.getProperty('junit')}"
108109
}
109110

buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class RandomizedTestingPlugin implements Plugin<Project> {
7474
// since we can't be sure if the task was ever realized, we remove both the provider and the task
7575
TaskProvider<Test> oldTestProvider
7676
try {
77-
oldTestProvider = tasks.getByNameLater(Test, 'test')
77+
oldTestProvider = tasks.named('test')
7878
} catch (UnknownTaskException unused) {
7979
// no test task, ok, user will use testing task on their own
8080
return

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

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.elasticsearch.gradle
2020

2121
import com.carrotsearch.gradle.junit4.RandomizedTestingTask
22+
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
2223
import org.apache.tools.ant.taskdefs.condition.Os
2324
import org.eclipse.jgit.lib.Constants
2425
import org.eclipse.jgit.lib.RepositoryBuilder
@@ -36,12 +37,14 @@ import org.gradle.api.artifacts.ModuleDependency
3637
import org.gradle.api.artifacts.ModuleVersionIdentifier
3738
import org.gradle.api.artifacts.ProjectDependency
3839
import org.gradle.api.artifacts.ResolvedArtifact
40+
import org.gradle.api.artifacts.SelfResolvingDependency
3941
import org.gradle.api.artifacts.dsl.RepositoryHandler
4042
import org.gradle.api.execution.TaskExecutionGraph
4143
import org.gradle.api.plugins.JavaPlugin
4244
import org.gradle.api.publish.maven.MavenPublication
4345
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
4446
import org.gradle.api.publish.maven.tasks.GenerateMavenPom
47+
import org.gradle.api.tasks.SourceSet
4548
import org.gradle.api.tasks.bundling.Jar
4649
import org.gradle.api.tasks.compile.GroovyCompile
4750
import org.gradle.api.tasks.compile.JavaCompile
@@ -498,7 +501,41 @@ class BuildPlugin implements Plugin<Project> {
498501
}
499502
}
500503
}
504+
project.plugins.withType(ShadowPlugin).whenPluginAdded {
505+
project.publishing {
506+
publications {
507+
nebula(MavenPublication) {
508+
artifact project.tasks.shadowJar
509+
artifactId = project.archivesBaseName
510+
/*
511+
* Configure the pom to include the "shadow" as compile dependencies
512+
* because that is how we're using them but remove all other dependencies
513+
* because they've been shaded into the jar.
514+
*/
515+
pom.withXml { XmlProvider xml ->
516+
Node root = xml.asNode()
517+
root.remove(root.dependencies)
518+
Node dependenciesNode = root.appendNode('dependencies')
519+
project.configurations.shadow.allDependencies.each {
520+
if (false == it instanceof SelfResolvingDependency) {
521+
Node dependencyNode = dependenciesNode.appendNode('dependency')
522+
dependencyNode.appendNode('groupId', it.group)
523+
dependencyNode.appendNode('artifactId', it.name)
524+
dependencyNode.appendNode('version', it.version)
525+
dependencyNode.appendNode('scope', 'compile')
526+
}
527+
}
528+
// Be tidy and remove the element if it is empty
529+
if (dependenciesNode.children.empty) {
530+
root.remove(dependenciesNode)
531+
}
532+
}
533+
}
534+
}
535+
}
536+
}
501537
}
538+
502539
}
503540

504541
/** Adds compiler settings to the project */
@@ -660,6 +697,28 @@ class BuildPlugin implements Plugin<Project> {
660697
}
661698
}
662699
}
700+
project.plugins.withType(ShadowPlugin).whenPluginAdded {
701+
/*
702+
* When we use the shadow plugin we entirely replace the
703+
* normal jar with the shadow jar so we no longer want to run
704+
* the jar task.
705+
*/
706+
project.tasks.jar.enabled = false
707+
project.tasks.shadowJar {
708+
/*
709+
* Replace the default "shadow" classifier with null
710+
* which will leave the classifier off of the file name.
711+
*/
712+
classifier = null
713+
/*
714+
* Not all cases need service files merged but it is
715+
* better to be safe
716+
*/
717+
mergeServiceFiles()
718+
}
719+
// Make sure we assemble the shadow jar
720+
project.tasks.assemble.dependsOn project.tasks.shadowJar
721+
}
663722
}
664723

665724
/** Returns a closure of common configuration shared by unit and integration tests. */
@@ -691,6 +750,7 @@ class BuildPlugin implements Plugin<Project> {
691750
systemProperty 'tests.task', path
692751
systemProperty 'tests.security.manager', 'true'
693752
systemProperty 'jna.nosys', 'true'
753+
systemProperty 'es.scripting.exception_for_missing_value', 'true'
694754
// TODO: remove setting logging level via system property
695755
systemProperty 'tests.logger.level', 'WARN'
696756
for (Map.Entry<String, String> property : System.properties.entrySet()) {
@@ -743,6 +803,18 @@ class BuildPlugin implements Plugin<Project> {
743803
}
744804

745805
exclude '**/*$*.class'
806+
807+
project.plugins.withType(ShadowPlugin).whenPluginAdded {
808+
/*
809+
* If we make a shaded jar we test against it.
810+
*/
811+
classpath -= project.tasks.compileJava.outputs.files
812+
classpath -= project.configurations.compile
813+
classpath -= project.configurations.runtime
814+
classpath += project.configurations.shadow
815+
classpath += project.tasks.shadowJar.outputs.files
816+
dependsOn project.tasks.shadowJar
817+
}
746818
}
747819
}
748820

@@ -762,9 +834,29 @@ class BuildPlugin implements Plugin<Project> {
762834
additionalTest.testClassesDirs = test.testClassesDirs
763835
additionalTest.configure(commonTestConfig(project))
764836
additionalTest.configure(config)
765-
test.dependsOn(additionalTest)
837+
additionalTest.dependsOn(project.tasks.testClasses)
838+
project.check.dependsOn(additionalTest)
766839
});
767-
return test
840+
841+
project.plugins.withType(ShadowPlugin).whenPluginAdded {
842+
/*
843+
* We need somewhere to configure dependencies that we don't wish
844+
* to shade into the jar. The shadow plugin creates a "shadow"
845+
* configuration which is *almost* exactly that. It is never
846+
* bundled into the shaded jar but is used for main source
847+
* compilation. Unfortunately, by default it is not used for
848+
* *test* source compilation and isn't used in tests at all. This
849+
* change makes it available for test compilation.
850+
*
851+
* Note that this isn't going to work properly with qa projects
852+
* but they have no business applying the shadow plugin in the
853+
* firstplace.
854+
*/
855+
SourceSet testSourceSet = project.sourceSets.findByName('test')
856+
if (testSourceSet != null) {
857+
testSourceSet.compileClasspath += project.configurations.shadow
858+
}
859+
}
768860
}
769861

770862
private static configurePrecommit(Project project) {

buildSrc/src/main/groovy/org/elasticsearch/gradle/LoggedExec.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)