Skip to content

Commit

Permalink
Merge branch 'master' into feature-ml-data-frame-analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitris-athanasiou committed Jun 4, 2019
2 parents 7d43d6e + b37c3bd commit 0939119
Show file tree
Hide file tree
Showing 314 changed files with 4,638 additions and 5,093 deletions.
2 changes: 1 addition & 1 deletion benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ archivesBaseName = 'elasticsearch-benchmarks'
test.enabled = false

dependencies {
compile("org.elasticsearch:elasticsearch:${version}") {
compile(project(":server")) {
// JMH ships with the conflicting version 4.6. This prevents us from using jopt-simple in benchmarks (which should be ok) but allows
// us to invoke the JMH uberjar as usual.
exclude group: 'net.sf.jopt-simple', module: 'jopt-simple'
Expand Down
69 changes: 4 additions & 65 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -209,68 +209,7 @@ allprojects {
javadoc.options.addStringOption('Xdoclint:all,-missing', '-quiet')
}

/* Sets up the dependencies that we build as part of this project but
register as though they were external to resolve internally. We register
them as external dependencies so the build plugin that we use can be used
to build elasticsearch plugins outside of the elasticsearch source tree. */
ext.projectSubstitutions = [
"org.elasticsearch.gradle:build-tools:${version}": ':build-tools',
"org.elasticsearch:rest-api-spec:${version}": ':rest-api-spec',
"org.elasticsearch:elasticsearch:${version}": ':server',
"org.elasticsearch:elasticsearch-cli:${version}": ':libs:elasticsearch-cli',
"org.elasticsearch:elasticsearch-core:${version}": ':libs:core',
"org.elasticsearch:elasticsearch-nio:${version}": ':libs:nio',
"org.elasticsearch:elasticsearch-x-content:${version}": ':libs:x-content',
"org.elasticsearch:elasticsearch-geo:${version}": ':libs:elasticsearch-geo',
"org.elasticsearch:elasticsearch-secure-sm:${version}": ':libs:secure-sm',
"org.elasticsearch:elasticsearch-ssl-config:${version}": ':libs:elasticsearch-ssl-config',
"org.elasticsearch.client:elasticsearch-rest-client:${version}": ':client:rest',
"org.elasticsearch.client:elasticsearch-rest-client-sniffer:${version}": ':client:sniffer',
"org.elasticsearch.client:elasticsearch-rest-high-level-client:${version}": ':client:rest-high-level',
"org.elasticsearch.client:test:${version}": ':client:test',
"org.elasticsearch.client:transport:${version}": ':client:transport',
"org.elasticsearch.plugin:elasticsearch-scripting-painless-spi:${version}": ':modules:lang-painless:spi',
"org.elasticsearch.test:framework:${version}": ':test:framework',
"org.elasticsearch.test:logger-usage:${version}": ':test:logger-usage',
"org.elasticsearch.xpack.test:feature-aware:${version}": ':x-pack:test:feature-aware',
// for transport client
"org.elasticsearch.plugin:transport-netty4-client:${version}": ':modules:transport-netty4',
"org.elasticsearch.plugin:reindex-client:${version}": ':modules:reindex',
"org.elasticsearch.plugin:lang-mustache-client:${version}": ':modules:lang-mustache',
"org.elasticsearch.plugin:parent-join-client:${version}": ':modules:parent-join',
"org.elasticsearch.plugin:aggs-matrix-stats-client:${version}": ':modules:aggs-matrix-stats',
"org.elasticsearch.plugin:percolator-client:${version}": ':modules:percolator',
"org.elasticsearch.plugin:rank-eval-client:${version}": ':modules:rank-eval',
// for security example plugins
"org.elasticsearch.plugin:x-pack-core:${version}": ':x-pack:plugin:core'
]

/*
* Gradle only resolve project substitutions during dependency resolution but
* we sometimes want to do the resolution at other times. This creates a
* convenient method we can call to do it.
*/
ext.dependencyToProject = { Dependency dep ->
if (dep instanceof ProjectDependency) {
return dep.dependencyProject
} else {
String substitution = projectSubstitutions.get("${dep.group}:${dep.name}:${dep.version}")
if (substitution != null) {
return findProject(substitution)
}
return null
}
}

project.afterEvaluate {
configurations.matching { it.canBeResolved }.all {
resolutionStrategy.dependencySubstitution { DependencySubstitutions subs ->
projectSubstitutions.each { k,v ->
subs.substitute(subs.module(k)).with(subs.project(v))
}
}
}

// Handle javadoc dependencies across projects. Order matters: the linksOffline for
// org.elasticsearch:elasticsearch must be the last one or all the links for the
// other packages (e.g org.elasticsearch.client) will point to server rather than
Expand All @@ -279,10 +218,10 @@ allprojects {
String artifactsHost = VersionProperties.elasticsearch.endsWith("-SNAPSHOT") ? "https://snapshots.elastic.co" : "https://artifacts.elastic.co"
Closure sortClosure = { a, b -> b.group <=> a.group }
Closure depJavadocClosure = { shadowed, dep ->
if (dep.group == null || false == dep.group.startsWith('org.elasticsearch')) {
if ((dep instanceof ProjectDependency) == false) {
return
}
Project upstreamProject = project.ext.dependencyToProject(dep)
Project upstreamProject = dep.dependencyProject
if (upstreamProject == null) {
return
}
Expand Down Expand Up @@ -338,8 +277,8 @@ gradle.projectsEvaluated {
integTest.mustRunAfter test
}
configurations.matching { it.canBeResolved }.all { Configuration configuration ->
dependencies.all { Dependency dep ->
Project upstreamProject = dependencyToProject(dep)
dependencies.matching { it instanceof ProjectDependency }.all { ProjectDependency dep ->
Project upstreamProject = dep.dependencyProject
if (upstreamProject != null) {
if (project.path == upstreamProject.path) {
// TODO: distribution integ tests depend on themselves (!), fix that
Expand Down
5 changes: 5 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ if (project != rootProject) {
distribution project(':distribution:archives:linux-tar')
distribution project(':distribution:archives:oss-linux-tar')
}

// for external projects we want to remove the marker file indicating we are running the Elasticsearch project
processResources {
exclude 'buildSrc.marker'
}

String localDownloads = "${rootProject.buildDir}/local-downloads"
task setupLocalDownloads(type:Copy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.elasticsearch.gradle

import com.github.jengelman.gradle.plugins.shadow.ShadowExtension
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import groovy.transform.CompileDynamic
Expand Down Expand Up @@ -77,7 +78,6 @@ import org.gradle.authentication.http.HttpHeaderAuthentication
import org.gradle.external.javadoc.CoreJavadocOptions
import org.gradle.internal.jvm.Jvm
import org.gradle.language.base.plugins.LifecycleBasePlugin
import org.gradle.process.CommandLineArgumentProvider
import org.gradle.process.ExecResult
import org.gradle.process.ExecSpec
import org.gradle.util.GradleVersion
Expand Down Expand Up @@ -259,7 +259,7 @@ class BuildPlugin implements Plugin<Project> {
if (ext.get('buildDocker')) {
(ext.get('requiresDocker') as List<Task>).add(task)
} else {
task.enabled = false
task.onlyIf { false }
}
}

Expand Down Expand Up @@ -530,39 +530,43 @@ class BuildPlugin implements Plugin<Project> {
static void configurePomGeneration(Project project) {
// Only works with `enableFeaturePreview('STABLE_PUBLISHING')`
// https://github.com/gradle/gradle/issues/5696#issuecomment-396965185
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom generatePOMTask ->
// The GenerateMavenPom task is aggressive about setting the destination, instead of fighting it,
// just make a copy.
ExtraPropertiesExtension ext = generatePOMTask.extensions.getByType(ExtraPropertiesExtension)
ext.set('pomFileName', null)
generatePOMTask.doLast {
project.copy { CopySpec spec ->
spec.from generatePOMTask.destination
spec.into "${project.buildDir}/distributions"
spec.rename {
ext.has('pomFileName') && ext.get('pomFileName') == null ?
"${project.convention.getPlugin(BasePluginConvention).archivesBaseName}-${project.version}.pom" :
ext.get('pomFileName')
// dummy task to depend on the real pom generation
project.plugins.withType(MavenPublishPlugin).whenPluginAdded {
Task generatePomTask = project.tasks.create("generatePom")
Task assemble = project.tasks.findByName('assemble')
if (assemble) {
assemble.dependsOn(generatePomTask)
}
project.tasks.withType(GenerateMavenPom.class) { GenerateMavenPom pomTask ->
// The GenerateMavenPom task is aggressive about setting the destination, instead of fighting it,
// just make a copy.
ExtraPropertiesExtension ext = pomTask.extensions.getByType(ExtraPropertiesExtension)
ext.set('pomFileName', null)
pomTask.doLast {
project.copy { CopySpec spec ->
spec.from pomTask.destination
spec.into "${project.buildDir}/distributions"
spec.rename {
ext.has('pomFileName') && ext.get('pomFileName') == null ?
"${project.convention.getPlugin(BasePluginConvention).archivesBaseName}-${project.version}.pom" :
ext.get('pomFileName')
}
}
}
}
// build poms with assemble (if the assemble task exists)
Task assemble = project.tasks.findByName('assemble')
if (assemble && assemble.enabled) {
assemble.dependsOn(generatePOMTask)
}
}
project.plugins.withType(MavenPublishPlugin).whenPluginAdded {
generatePomTask.dependsOn = ['generatePomFileForNebulaPublication']
PublishingExtension publishing = project.extensions.getByType(PublishingExtension)
publishing.publications.all { MavenPublication publication -> // we only deal with maven
// add exclusions to the pom directly, for each of the transitive deps of this project's deps
publication.pom.withXml(fixupDependencies(project))
}
project.plugins.withType(ShadowPlugin).whenPluginAdded {
MavenPublication publication = publishing.publications.maybeCreate('nebula', MavenPublication)
MavenPublication publication = publishing.publications.maybeCreate('shadow', MavenPublication)
publication.with {
artifacts = [ project.tasks.getByName('shadowJar') ]
ShadowExtension shadow = project.extensions.getByType(ShadowExtension)
shadow.component(publication)
}
generatePomTask.dependsOn = ['generatePomFileForShadowPublication']
}
}
}
Expand Down Expand Up @@ -690,6 +694,12 @@ class BuildPlugin implements Plugin<Project> {
project.tasks.withType(Jar) { Jar jarTask ->
// we put all our distributable files under distributions
jarTask.destinationDir = new File(project.buildDir, 'distributions')
project.plugins.withType(ShadowPlugin).whenPluginAdded {
// ensure the original jar task places its output in 'libs' so we don't overwrite it with the shadowjar
if (jarTask instanceof ShadowJar == false) {
jarTask.destinationDir = new File(project.buildDir, 'libs')
}
}
// fixup the jar manifest
jarTask.doFirst {
// this doFirst is added before the info plugin, therefore it will run
Expand Down Expand Up @@ -740,12 +750,6 @@ class BuildPlugin implements Plugin<Project> {
}
}
project.plugins.withType(ShadowPlugin).whenPluginAdded {
/*
* When we use the shadow plugin we entirely replace the
* normal jar with the shadow jar so we no longer want to run
* the jar task.
*/
project.tasks.getByName(JavaPlugin.JAR_TASK_NAME).enabled = false
project.tasks.getByName('shadowJar').configure { ShadowJar shadowJar ->
/*
* Replace the default "shadow" classifier with null
Expand All @@ -764,7 +768,6 @@ class BuildPlugin implements Plugin<Project> {
}
// Make sure we assemble the shadow jar
project.tasks.getByName(BasePlugin.ASSEMBLE_TASK_NAME).dependsOn project.tasks.getByName('shadowJar')
project.artifacts.add('apiElements', project.tasks.getByName('shadowJar'))
}
}

Expand Down Expand Up @@ -878,6 +881,7 @@ class BuildPlugin implements Plugin<Project> {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.test.RestIntegTestTask
import org.elasticsearch.gradle.test.RunTask
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
import org.elasticsearch.gradle.tool.ClasspathUtils
import org.gradle.api.InvalidUserDataException
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand Down Expand Up @@ -136,8 +137,13 @@ class PluginBuildPlugin implements Plugin<Project> {

private static void configureDependencies(Project project) {
project.dependencies {
compileOnly "org.elasticsearch:elasticsearch:${project.versions.elasticsearch}"
testCompile "org.elasticsearch.test:framework:${project.versions.elasticsearch}"
if (ClasspathUtils.isElasticsearchProject()) {
compileOnly project.project(':server')
testCompile project.project(':test:framework')
} else {
compileOnly "org.elasticsearch:elasticsearch:${project.versions.elasticsearch}"
testCompile "org.elasticsearch.test:framework:${project.versions.elasticsearch}"
}
// we "upgrade" these optional deps to provided for plugins, since they will run
// with a full elasticsearch server that includes optional deps
compileOnly "org.locationtech.spatial4j:spatial4j:${project.versions.spatial4j}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.tool.ClasspathUtils
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.plugins.quality.Checkstyle

/**
* Validation tasks which should be run before committing. These run before tests.
*/
Expand All @@ -40,18 +42,18 @@ class PrecommitTasks {
public static Task create(Project project, boolean includeDependencyLicenses) {
project.configurations.create("forbiddenApisCliJar")
project.dependencies {
forbiddenApisCliJar ('de.thetaphi:forbiddenapis:2.6')
forbiddenApisCliJar('de.thetaphi:forbiddenapis:2.6')
}

List<Task> precommitTasks = [
configureCheckstyle(project),
configureForbiddenApisCli(project),
project.tasks.create('forbiddenPatterns', ForbiddenPatternsTask.class),
project.tasks.create('licenseHeaders', LicenseHeadersTask.class),
project.tasks.create('filepermissions', FilePermissionsTask.class),
configureJarHell(project),
configureThirdPartyAudit(project),
configureTestingConventions(project)
configureCheckstyle(project),
configureForbiddenApisCli(project),
project.tasks.create('forbiddenPatterns', ForbiddenPatternsTask.class),
project.tasks.create('licenseHeaders', LicenseHeadersTask.class),
project.tasks.create('filepermissions', FilePermissionsTask.class),
configureJarHell(project),
configureThirdPartyAudit(project),
configureTestingConventions(project)
]

// tasks with just tests don't need dependency licenses, so this flag makes adding
Expand Down Expand Up @@ -85,10 +87,10 @@ class PrecommitTasks {
}

return project.tasks.create([
name: 'precommit',
group: JavaBasePlugin.VERIFICATION_GROUP,
description: 'Runs all non-test checks.',
dependsOn: precommitTasks
name : 'precommit',
group : JavaBasePlugin.VERIFICATION_GROUP,
description: 'Runs all non-test checks.',
dependsOn : precommitTasks
])
}

Expand Down Expand Up @@ -168,7 +170,7 @@ class PrecommitTasks {
)
}
}
Task forbiddenApis = project.tasks.getByName("forbiddenApis")
Task forbiddenApis = project.tasks.getByName("forbiddenApis")
forbiddenApis.group = ""
return forbiddenApis
}
Expand Down Expand Up @@ -211,7 +213,7 @@ class PrecommitTasks {
project.checkstyle {
config = project.resources.text.fromFile(checkstyleConf, 'UTF-8')
configProperties = [
suppressions: checkstyleSuppressions
suppressions: checkstyleSuppressions
]
toolVersion = CHECKSTYLE_VERSION
}
Expand All @@ -229,9 +231,11 @@ class PrecommitTasks {
}

private static Task configureLoggerUsage(Project project) {
Object dependency = ClasspathUtils.isElasticsearchProject() ? project.project(':test:logger-usage') :
"org.elasticsearch.test:logger-usage:${VersionProperties.elasticsearch}"

project.configurations.create('loggerUsagePlugin')
project.dependencies.add('loggerUsagePlugin',
"org.elasticsearch.test:logger-usage:${VersionProperties.elasticsearch}")
project.dependencies.add('loggerUsagePlugin', dependency)
return project.tasks.create('loggerUsageCheck', LoggerUsageTask.class) {
classpath = project.configurations.loggerUsagePlugin
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class RestIntegTestTask extends DefaultTask {
restSpec
}
project.dependencies {
restSpec "org.elasticsearch:rest-api-spec:${VersionProperties.elasticsearch}"
restSpec project.project(':rest-api-spec')
}
Task copyRestSpec = project.tasks.findByName('copyRestSpec')
if (copyRestSpec != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class StandaloneRestTestPlugin implements Plugin<Project> {

// create a compileOnly configuration as others might expect it
project.configurations.create("compileOnly")
project.dependencies.add('testCompile', "org.elasticsearch.test:framework:${VersionProperties.elasticsearch}")
project.dependencies.add('testCompile', project.project(':test:framework'))

EclipseModel eclipse = project.extensions.getByType(EclipseModel)
eclipse.classpath.sourceSets = [testSourceSet]
Expand Down
Loading

0 comments on commit 0939119

Please sign in to comment.