Skip to content

Commit 7ab6f92

Browse files
committed
Merge branch '6.x' into ccr-6.x
* 6.x: Move default location of dependencies report (#31228) Remove dependencies report task dependencies (#31227) Add recognition of MPL 2.0 (#31226) Fix unknown licenses (#31223) Fully encapsulate LocalCheckpointTracker inside of the engine (#31213) Remove version from license file name for GCS SDK (#31221) Remove DocumentFieldMappers#simpleMatchToFullName. (#31041) [DOCS] Removes 6.3.1 release notes [DOCS] Splits release notes by major version Remove DocumentFieldMappers#smartNameFieldMapper, as it is no longer needed. (#31018) Remove extraneous references to 'tokenized' in the mapper code. (#31010) SQL: Make a single JDBC driver jar (#31012) QA: Fix rolling restart tests some more Allow to trim all ops above a certain seq# with a term lower than X high level REST api: cancel task (#30745) Mute TokenBackwardsCompatibilityIT.testMixedCluster Mute WatchBackwardsCompatibilityIT.testWatcherRestart Enhance license detection for various licenses (#31198) [DOCS] Add note about long-lived idle connections (#30990) Add high-level client methods that accept RequestOptions (#31069) Remove RestGetAllMappingsAction (#31129) Move RestGetSettingsAction to RestToXContentListener (#31101) Move number of language analyzers to analysis-common module (#31143) flush job to ensure all results have been written (#31187)
2 parents a095780 + 33d5984 commit 7ab6f92

File tree

152 files changed

+5899
-3101
lines changed

Some content is hidden

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

152 files changed

+5899
-3101
lines changed

build.gradle

+6-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ subprojects { project ->
537537
}
538538
}
539539

540-
/* Remove assemble on all qa projects because we don't need to publish
540+
/* Remove assemble/dependenciesInfo on all qa projects because we don't need to publish
541541
* artifacts for them. */
542542
gradle.projectsEvaluated {
543543
subprojects {
@@ -547,6 +547,11 @@ gradle.projectsEvaluated {
547547
project.tasks.remove(assemble)
548548
project.build.dependsOn.remove('assemble')
549549
}
550+
Task dependenciesInfo = project.tasks.findByName('dependenciesInfo')
551+
if (dependenciesInfo) {
552+
project.tasks.remove(dependenciesInfo)
553+
project.precommit.dependsOn.remove('dependenciesInfo')
554+
}
550555
}
551556
}
552557
}

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,10 @@ class BuildPlugin implements Plugin<Project> {
761761

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

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

+122-11
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/precommit/DependencyLicensesTask.groovy

+22-15
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ public class DependencyLicensesTask extends DefaultTask {
109109
mappings.put(from, to)
110110
}
111111

112+
public LinkedHashMap<String, String> getMappings() {
113+
return new LinkedHashMap<>(mappings)
114+
}
115+
112116
/**
113117
* Add a rule which will skip SHA checking for the given dependency name. This should be used for
114118
* locally build dependencies, which cause the sha to change constantly.
@@ -129,10 +133,6 @@ public class DependencyLicensesTask extends DefaultTask {
129133
throw new GradleException("Licences dir ${licensesDir} does not exist, but there are dependencies")
130134
}
131135

132-
133-
// order is the same for keys and values iteration since we use a linked hashmap
134-
List<String> mapped = new ArrayList<>(mappings.values())
135-
Pattern mappingsPattern = Pattern.compile('(' + mappings.keySet().join(')|(') + ')')
136136
Map<String, Integer> licenses = new HashMap<>()
137137
Map<String, Integer> notices = new HashMap<>()
138138
Set<File> shaFiles = new HashSet<File>()
@@ -151,7 +151,7 @@ public class DependencyLicensesTask extends DefaultTask {
151151

152152
for (File dependency : dependencies) {
153153
String jarName = dependency.getName()
154-
String depName = jarName - ~/\-\d+.*/
154+
String depName = jarName - ~/\-v?\d+.*/
155155
if (ignoreShas.contains(depName)) {
156156
// local deps should not have sha files!
157157
if (getShaFile(jarName).exists()) {
@@ -162,16 +162,10 @@ public class DependencyLicensesTask extends DefaultTask {
162162
checkSha(dependency, jarName, shaFiles)
163163
}
164164

165-
logger.info("Checking license/notice for " + depName)
166-
Matcher match = mappingsPattern.matcher(depName)
167-
if (match.matches()) {
168-
int i = 0
169-
while (i < match.groupCount() && match.group(i + 1) == null) ++i;
170-
logger.info("Mapped dependency name ${depName} to ${mapped.get(i)} for license check")
171-
depName = mapped.get(i)
172-
}
173-
checkFile(depName, jarName, licenses, 'LICENSE')
174-
checkFile(depName, jarName, notices, 'NOTICE')
165+
final String dependencyName = getDependencyName(mappings, depName)
166+
logger.info("mapped dependency name ${depName} to ${dependencyName} for license/notice check")
167+
checkFile(dependencyName, jarName, licenses, 'LICENSE')
168+
checkFile(dependencyName, jarName, notices, 'NOTICE')
175169
}
176170

177171
licenses.each { license, count ->
@@ -189,6 +183,19 @@ public class DependencyLicensesTask extends DefaultTask {
189183
}
190184
}
191185

186+
public static String getDependencyName(final LinkedHashMap<String, String> mappings, final String dependencyName) {
187+
// order is the same for keys and values iteration since we use a linked hashmap
188+
List<String> mapped = new ArrayList<>(mappings.values())
189+
Pattern mappingsPattern = Pattern.compile('(' + mappings.keySet().join(')|(') + ')')
190+
Matcher match = mappingsPattern.matcher(dependencyName)
191+
if (match.matches()) {
192+
int i = 0
193+
while (i < match.groupCount() && match.group(i + 1) == null) ++i;
194+
return mapped.get(i)
195+
}
196+
return dependencyName
197+
}
198+
192199
private File getShaFile(String jarName) {
193200
return new File(licensesDir, jarName + SHA_EXTENSION)
194201
}

client/client-benchmark-noop-api-plugin/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ esplugin {
3131
tasks.remove(assemble)
3232
build.dependsOn.remove('assemble')
3333

34+
dependencyLicenses.enabled = false
35+
dependenciesInfo.enabled = false
36+
3437
compileJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-rawtypes,-try,-unchecked"
3538

3639
// no unit tests

client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java

+34-2
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,55 @@ public final class ClusterClient {
4141
}
4242

4343
/**
44-
* Updates cluster wide specific settings using the Cluster Update Settings API
44+
* Updates cluster wide specific settings using the Cluster Update Settings API.
45+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html"> Cluster Update Settings
46+
* API on elastic.co</a>
47+
* @param clusterUpdateSettingsRequest the request
48+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
49+
* @return the response
50+
* @throws IOException in case there is a problem sending the request or parsing back the response
51+
*/
52+
public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, RequestOptions options)
53+
throws IOException {
54+
return restHighLevelClient.performRequestAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings,
55+
options, ClusterUpdateSettingsResponse::fromXContent, emptySet());
56+
}
57+
58+
/**
59+
* Updates cluster wide specific settings using the Cluster Update Settings API.
4560
* <p>
4661
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html"> Cluster Update Settings
4762
* API on elastic.co</a>
63+
* @deprecated Prefer {@link #putSettings(ClusterUpdateSettingsRequest, RequestOptions)}
4864
*/
65+
@Deprecated
4966
public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, Header... headers)
5067
throws IOException {
5168
return restHighLevelClient.performRequestAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings,
5269
ClusterUpdateSettingsResponse::fromXContent, emptySet(), headers);
5370
}
5471

5572
/**
56-
* Asynchronously updates cluster wide specific settings using the Cluster Update Settings API
73+
* Asynchronously updates cluster wide specific settings using the Cluster Update Settings API.
74+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html"> Cluster Update Settings
75+
* API on elastic.co</a>
76+
* @param clusterUpdateSettingsRequest the request
77+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
78+
* @param listener the listener to be notified upon request completion
79+
*/
80+
public void putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, RequestOptions options,
81+
ActionListener<ClusterUpdateSettingsResponse> listener) {
82+
restHighLevelClient.performRequestAsyncAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings,
83+
options, ClusterUpdateSettingsResponse::fromXContent, listener, emptySet());
84+
}
85+
/**
86+
* Asynchronously updates cluster wide specific settings using the Cluster Update Settings API.
5787
* <p>
5888
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html"> Cluster Update Settings
5989
* API on elastic.co</a>
90+
* @deprecated Prefer {@link #putSettingsAsync(ClusterUpdateSettingsRequest, RequestOptions, ActionListener)}
6091
*/
92+
@Deprecated
6193
public void putSettingsAsync(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest,
6294
ActionListener<ClusterUpdateSettingsResponse> listener, Header... headers) {
6395
restHighLevelClient.performRequestAsyncAndParseEntity(clusterUpdateSettingsRequest, RequestConverters::clusterPutSettings,

0 commit comments

Comments
 (0)