Skip to content

Commit c5bcc5d

Browse files
author
Christoph Büscher
committed
Merge branch 'master' into pr/30320
2 parents d95c6a0 + 86ab3a2 commit c5bcc5d

File tree

2,346 files changed

+41944
-23160
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,346 files changed

+41944
-23160
lines changed

Vagrantfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Vagrant.configure(2) do |config|
3131
# Give the box more memory and cpu because our tests are beasts!
3232
vbox.memory = Integer(ENV['VAGRANT_MEMORY'] || 8192)
3333
vbox.cpus = Integer(ENV['VAGRANT_CPUS'] || 4)
34+
35+
# see https://github.com/hashicorp/vagrant/issues/9524
36+
vbox.customize ["modifyvm", :id, "--audio", "none"]
3437
end
3538

3639
# Switch the default share for the project root from /vagrant to

build.gradle

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,23 @@ subprojects {
5353
description = "Elasticsearch subproject ${project.path}"
5454
}
5555

56+
apply plugin: 'nebula.info-scm'
57+
String licenseCommit
58+
if (VersionProperties.elasticsearch.toString().endsWith('-SNAPSHOT')) {
59+
licenseCommit = scminfo.change ?: "master" // leniency for non git builds
60+
} else {
61+
licenseCommit = "v${version}"
62+
}
63+
String elasticLicenseUrl = "https://raw.githubusercontent.com/elastic/elasticsearch/${licenseCommit}/licenses/ELASTIC-LICENSE.txt"
64+
5665
subprojects {
66+
// Default to the apache license
5767
project.ext.licenseName = 'The Apache Software License, Version 2.0'
5868
project.ext.licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
69+
70+
// But stick the Elastic license url in project.ext so we can get it if we need to switch to it
71+
project.ext.elasticLicenseUrl = elasticLicenseUrl
72+
5973
// we only use maven publish to add tasks for pom generation
6074
plugins.withType(MavenPublishPlugin).whenPluginAdded {
6175
publishing {
@@ -131,7 +145,7 @@ task verifyVersions {
131145
new URL('https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml').openStream().withStream { s ->
132146
xml = new XmlParser().parse(s)
133147
}
134-
Set<Version> knownVersions = new TreeSet<>(xml.versioning.versions.version.collect { it.text() }.findAll { it ==~ /\d\.\d\.\d/ }.collect { Version.fromString(it) })
148+
Set<Version> knownVersions = new TreeSet<>(xml.versioning.versions.version.collect { it.text() }.findAll { it ==~ /\d+\.\d+\.\d+/ }.collect { Version.fromString(it) })
135149

136150
// Limit the known versions to those that should be index compatible, and are not future versions
137151
knownVersions = knownVersions.findAll { it.major >= bwcVersions.currentVersion.major - 1 && it.before(VersionProperties.elasticsearch) }
@@ -205,9 +219,9 @@ subprojects {
205219
"org.elasticsearch.gradle:build-tools:${version}": ':build-tools',
206220
"org.elasticsearch:rest-api-spec:${version}": ':rest-api-spec',
207221
"org.elasticsearch:elasticsearch:${version}": ':server',
208-
"org.elasticsearch:elasticsearch-cli:${version}": ':server:cli',
209-
"org.elasticsearch:elasticsearch-core:${version}": ':libs:elasticsearch-core',
210-
"org.elasticsearch:elasticsearch-nio:${version}": ':libs:elasticsearch-nio',
222+
"org.elasticsearch:elasticsearch-cli:${version}": ':libs:cli',
223+
"org.elasticsearch:elasticsearch-core:${version}": ':libs:core',
224+
"org.elasticsearch:elasticsearch-nio:${version}": ':libs:nio',
211225
"org.elasticsearch:elasticsearch-x-content:${version}": ':libs:x-content',
212226
"org.elasticsearch:elasticsearch-secure-sm:${version}": ':libs:secure-sm',
213227
"org.elasticsearch.client:elasticsearch-rest-client:${version}": ':client:rest',
@@ -543,7 +557,7 @@ subprojects { project ->
543557
}
544558
}
545559

546-
/* Remove assemble on all qa projects because we don't need to publish
560+
/* Remove assemble/dependenciesInfo on all qa projects because we don't need to publish
547561
* artifacts for them. */
548562
gradle.projectsEvaluated {
549563
subprojects {
@@ -553,6 +567,11 @@ gradle.projectsEvaluated {
553567
project.tasks.remove(assemble)
554568
project.build.dependsOn.remove('assemble')
555569
}
570+
Task dependenciesInfo = project.tasks.findByName('dependenciesInfo')
571+
if (dependenciesInfo) {
572+
project.tasks.remove(dependenciesInfo)
573+
project.precommit.dependsOn.remove('dependenciesInfo')
574+
}
556575
}
557576
}
558577
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,10 @@ class BuildPlugin implements Plugin<Project> {
762762

763763
private static configureDependenciesInfo(Project project) {
764764
Task deps = project.tasks.create("dependenciesInfo", DependenciesInfoTask.class)
765-
deps.dependencies = project.configurations.compile.allDependencies
765+
deps.runtimeConfiguration = project.configurations.runtime
766+
deps.compileOnlyConfiguration = project.configurations.compileOnly
767+
project.afterEvaluate {
768+
deps.mappings = project.dependencyLicenses.mappings
769+
}
766770
}
767771
}

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

Lines changed: 122 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@
1919

2020
package org.elasticsearch.gradle
2121

22+
import org.elasticsearch.gradle.precommit.DependencyLicensesTask
2223
import org.gradle.api.DefaultTask
24+
import org.gradle.api.artifacts.Configuration
2325
import org.gradle.api.artifacts.Dependency
26+
import org.gradle.api.artifacts.DependencyResolutionListener
2427
import org.gradle.api.artifacts.DependencySet
2528
import org.gradle.api.tasks.Input
2629
import org.gradle.api.tasks.InputDirectory
2730
import org.gradle.api.tasks.OutputFile
2831
import org.gradle.api.tasks.TaskAction
2932

33+
import java.util.regex.Matcher
34+
import java.util.regex.Pattern
3035

3136
/**
3237
* A task to gather information about the dependencies and export them into a csv file.
@@ -44,7 +49,14 @@ public class DependenciesInfoTask extends DefaultTask {
4449

4550
/** Dependencies to gather information from. */
4651
@Input
47-
public DependencySet dependencies
52+
public Configuration runtimeConfiguration
53+
54+
/** We subtract compile-only dependencies. */
55+
@Input
56+
public Configuration compileOnlyConfiguration
57+
58+
@Input
59+
public LinkedHashMap<String, String> mappings
4860

4961
/** Directory to read license files */
5062
@InputDirectory
@@ -59,15 +71,34 @@ public class DependenciesInfoTask extends DefaultTask {
5971

6072
@TaskAction
6173
public void generateDependenciesInfo() {
74+
75+
final DependencySet runtimeDependencies = runtimeConfiguration.getAllDependencies()
76+
// we have to resolve the transitive dependencies and create a group:artifactId:version map
77+
final Set<String> compileOnlyArtifacts =
78+
compileOnlyConfiguration
79+
.getResolvedConfiguration()
80+
.resolvedArtifacts
81+
.collect { it -> "${it.moduleVersion.id.group}:${it.moduleVersion.id.name}:${it.moduleVersion.id.version}" }
82+
6283
final StringBuilder output = new StringBuilder()
6384

64-
for (Dependency dependency : dependencies) {
65-
// Only external dependencies are checked
66-
if (dependency.group != null && dependency.group.contains("elasticsearch") == false) {
67-
final String url = createURL(dependency.group, dependency.name, dependency.version)
68-
final String licenseType = getLicenseType(dependency.group, dependency.name)
69-
output.append("${dependency.group}:${dependency.name},${dependency.version},${url},${licenseType}\n")
85+
for (final Dependency dependency : runtimeDependencies) {
86+
// we do not need compile-only dependencies here
87+
if (compileOnlyArtifacts.contains("${dependency.group}:${dependency.name}:${dependency.version}")) {
88+
continue
7089
}
90+
// only external dependencies are checked
91+
if (dependency.group != null && dependency.group.contains("org.elasticsearch")) {
92+
continue
93+
}
94+
95+
final String url = createURL(dependency.group, dependency.name, dependency.version)
96+
final String dependencyName = DependencyLicensesTask.getDependencyName(mappings, dependency.name)
97+
logger.info("mapped dependency ${dependency.group}:${dependency.name} to ${dependencyName} for license info")
98+
99+
final String licenseType = getLicenseType(dependency.group, dependencyName)
100+
output.append("${dependency.group}:${dependency.name},${dependency.version},${url},${licenseType}\n")
101+
71102
}
72103
outputFile.setText(output.toString(), 'UTF-8')
73104
}
@@ -109,7 +140,8 @@ public class DependenciesInfoTask extends DefaultTask {
109140
}
110141

111142
if (license) {
112-
final String content = license.readLines("UTF-8").toString()
143+
// replace * because they are sometimes used at the beginning lines as if the license was a multi-line comment
144+
final String content = new String(license.readBytes(), "UTF-8").replaceAll("\\s+", " ").replaceAll("\\*", " ")
113145
final String spdx = checkSPDXLicense(content)
114146
if (spdx == null) {
115147
// License has not be identified as SPDX.
@@ -133,15 +165,88 @@ public class DependenciesInfoTask extends DefaultTask {
133165
private String checkSPDXLicense(final String licenseText) {
134166
String spdx = null
135167

136-
final String APACHE_2_0 = "Apache.*License.*(v|V)ersion 2.0"
137-
final String BSD_2 = "BSD 2-clause.*License"
168+
final String APACHE_2_0 = "Apache.*License.*(v|V)ersion.*2\\.0"
169+
170+
final String BSD_2 = """
171+
Redistribution and use in source and binary forms, with or without
172+
modification, are permitted provided that the following conditions
173+
are met:
174+
175+
1\\. Redistributions of source code must retain the above copyright
176+
notice, this list of conditions and the following disclaimer\\.
177+
2\\. Redistributions in binary form must reproduce the above copyright
178+
notice, this list of conditions and the following disclaimer in the
179+
documentation and/or other materials provided with the distribution\\.
180+
181+
THIS SOFTWARE IS PROVIDED BY .+ (``|''|")AS IS(''|") AND ANY EXPRESS OR
182+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
183+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED\\.
184+
IN NO EVENT SHALL .+ BE LIABLE FOR ANY DIRECT, INDIRECT,
185+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \\(INCLUDING, BUT
186+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
187+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION\\) HOWEVER CAUSED AND ON ANY
188+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
189+
\\(INCLUDING NEGLIGENCE OR OTHERWISE\\) ARISING IN ANY WAY OUT OF THE USE OF
190+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\\.
191+
""".replaceAll("\\s+", "\\\\s*")
192+
193+
final String BSD_3 = """
194+
Redistribution and use in source and binary forms, with or without
195+
modification, are permitted provided that the following conditions
196+
are met:
197+
198+
(1\\.)? Redistributions of source code must retain the above copyright
199+
notice, this list of conditions and the following disclaimer\\.
200+
(2\\.)? Redistributions in binary form must reproduce the above copyright
201+
notice, this list of conditions and the following disclaimer in the
202+
documentation and/or other materials provided with the distribution\\.
203+
((3\\.)? The name of .+ may not be used to endorse or promote products
204+
derived from this software without specific prior written permission\\.|
205+
(3\\.)? Neither the name of .+ nor the names of its
206+
contributors may be used to endorse or promote products derived from
207+
this software without specific prior written permission\\.)
208+
209+
THIS SOFTWARE IS PROVIDED BY .+ (``|''|")AS IS(''|") AND ANY EXPRESS OR
210+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
211+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED\\.
212+
IN NO EVENT SHALL .+ BE LIABLE FOR ANY DIRECT, INDIRECT,
213+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \\(INCLUDING, BUT
214+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
215+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION\\) HOWEVER CAUSED AND ON ANY
216+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
217+
\\(INCLUDING NEGLIGENCE OR OTHERWISE\\) ARISING IN ANY WAY OUT OF THE USE OF
218+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\\.
219+
""".replaceAll("\\s+", "\\\\s*")
220+
138221
final String CDDL_1_0 = "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE.*Version 1.0"
139222
final String CDDL_1_1 = "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE.*Version 1.1"
140223
final String ICU = "ICU License - ICU 1.8.1 and later"
141224
final String LGPL_3 = "GNU LESSER GENERAL PUBLIC LICENSE.*Version 3"
142-
final String MIT = "MIT License"
225+
226+
final String MIT = """
227+
Permission is hereby granted, free of charge, to any person obtaining a copy of
228+
this software and associated documentation files \\(the "Software"\\), to deal in
229+
the Software without restriction, including without limitation the rights to
230+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
231+
of the Software, and to permit persons to whom the Software is furnished to do
232+
so, subject to the following conditions:
233+
234+
The above copyright notice and this permission notice shall be included in all
235+
copies or substantial portions of the Software\\.
236+
237+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
238+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
239+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT\\. IN NO EVENT SHALL THE
240+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
241+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
242+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
243+
SOFTWARE\\.
244+
""".replaceAll("\\s+", "\\\\s*")
245+
143246
final String MOZILLA_1_1 = "Mozilla Public License.*Version 1.1"
144247

248+
final String MOZILLA_2_0 = "Mozilla\\s*Public\\s*License\\s*Version\\s*2\\.0"
249+
145250
switch (licenseText) {
146251
case ~/.*${APACHE_2_0}.*/:
147252
spdx = 'Apache-2.0'
@@ -152,6 +257,9 @@ public class DependenciesInfoTask extends DefaultTask {
152257
case ~/.*${BSD_2}.*/:
153258
spdx = 'BSD-2-Clause'
154259
break
260+
case ~/.*${BSD_3}.*/:
261+
spdx = 'BSD-3-Clause'
262+
break
155263
case ~/.*${LGPL_3}.*/:
156264
spdx = 'LGPL-3.0'
157265
break
@@ -167,6 +275,9 @@ public class DependenciesInfoTask extends DefaultTask {
167275
case ~/.*${MOZILLA_1_1}.*/:
168276
spdx = 'MPL-1.1'
169277
break
278+
case ~/.*${MOZILLA_2_0}.*/:
279+
spdx = 'MPL-2.0'
280+
break
170281
default:
171282
break
172283
}

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public class DocsTestPlugin extends RestTestPlugin {
3232
public void apply(Project project) {
3333
project.pluginManager.apply('elasticsearch.standalone-rest-test')
3434
super.apply(project)
35+
// The distribution can be configured with -Dtests.distribution on the command line
36+
project.integTestCluster.distribution = System.getProperty('tests.distribution', 'zip')
3537
// Docs are published separately so no need to assemble
3638
project.tasks.remove(project.assemble)
3739
project.build.dependsOn.remove('assemble')
@@ -43,6 +45,8 @@ public class DocsTestPlugin extends RestTestPlugin {
4345
'\\{version\\}':
4446
VersionProperties.elasticsearch.toString().replace('-SNAPSHOT', ''),
4547
'\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''),
48+
'\\{build_flavor\\}' :
49+
project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default',
4650
]
4751
Task listSnippets = project.tasks.create('listSnippets', SnippetsTask)
4852
listSnippets.group 'Docs'

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import org.gradle.api.tasks.OutputDirectory
2727

2828
import java.nio.file.Files
2929
import java.nio.file.Path
30-
import java.util.regex.Matcher
3130

3231
/**
3332
* Generates REST tests for each snippet marked // TEST.
@@ -100,6 +99,14 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
10099
return snippet.language == 'js' || snippet.curl
101100
}
102101

102+
/**
103+
* Certain requests should not have the shard failure check because the
104+
* format of the response is incompatible i.e. it is not a JSON object.
105+
*/
106+
static shouldAddShardFailureCheck(String path) {
107+
return path.startsWith('_cat') == false && path.startsWith('_xpack/ml/datafeeds/') == false
108+
}
109+
103110
/**
104111
* Converts Kibana's block quoted strings into standard JSON. These
105112
* {@code """} delimited strings can be embedded in CONSOLE and can
@@ -309,13 +316,11 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
309316
* no shard succeeds. But we need to fail the tests on all of these
310317
* because they mean invalid syntax or broken queries or something
311318
* else that we don't want to teach people to do. The REST test
312-
* framework doesn't allow us to has assertions in the setup
313-
* section so we have to skip it there. We also have to skip _cat
314-
* actions because they don't return json so we can't is_false
315-
* them. That is ok because they don't have this
316-
* partial-success-is-success thing.
319+
* framework doesn't allow us to have assertions in the setup
320+
* section so we have to skip it there. We also omit the assertion
321+
* from APIs that don't return a JSON object
317322
*/
318-
if (false == inSetup && false == path.startsWith('_cat')) {
323+
if (false == inSetup && shouldAddShardFailureCheck(path)) {
319324
current.println(" - is_false: _shards.failures")
320325
}
321326
}

0 commit comments

Comments
 (0)