Skip to content

Commit 077e89d

Browse files
author
Christoph Büscher
committed
Merge branch 'master' into shortCut-Exists-Query-37475
2 parents a40e583 + 5c732b3 commit 077e89d

File tree

43 files changed

+560
-153
lines changed

Some content is hidden

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

43 files changed

+560
-153
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ allprojects {
241241
"org.elasticsearch.plugin:rank-eval-client:${version}": ':modules:rank-eval',
242242
// for security example plugins
243243
"org.elasticsearch.plugin:x-pack-core:${version}": ':x-pack:plugin:core',
244-
"org.elasticsearch.client.x-pack-transport:${version}": ':x-pack:transport-client'
244+
"org.elasticsearch.client:x-pack-transport:${version}": ':x-pack:transport-client'
245245
]
246246

247247
/*

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class ClusterFormationTasks {
224224
classifier = "" // for bwc, before we had classifiers
225225
}
226226
// group does not matter as it is not used when we pull from the ivy repo that points to the download service
227-
dependency = "dnm:${artifactName}:${elasticsearchVersion}${classifier}@${packaging}"
227+
dependency = "dnm:${artifactName}:${elasticsearchVersion}-${classifier}@${packaging}"
228228
}
229229
project.dependencies.add(configuration.name, dependency)
230230
}

buildSrc/src/main/java/org/elasticsearch/GradleServicesAdapter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
*/
1919
package org.elasticsearch;
2020

21+
import org.elasticsearch.gradle.LoggedExec;
2122
import org.gradle.api.Action;
2223
import org.gradle.api.Project;
2324
import org.gradle.api.file.CopySpec;
2425
import org.gradle.api.file.FileCollection;
2526
import org.gradle.api.file.FileTree;
2627
import org.gradle.api.tasks.WorkResult;
2728
import org.gradle.process.ExecResult;
29+
import org.gradle.process.ExecSpec;
2830
import org.gradle.process.JavaExecSpec;
2931

3032
import java.io.File;
@@ -70,4 +72,8 @@ public FileTree zipTree(File zipPath) {
7072
public FileCollection fileTree(File dir) {
7173
return project.fileTree(dir);
7274
}
75+
76+
public void loggedExec(Action<ExecSpec> action) {
77+
LoggedExec.exec(project, action);
78+
}
7379
}

buildSrc/src/main/java/org/elasticsearch/gradle/Distribution.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,36 @@
2020

2121
public enum Distribution {
2222

23-
INTEG_TEST("integ-test", "zip"),
24-
ZIP("elasticsearch", "zip"),
25-
ZIP_OSS("elasticsearch-oss", "zip");
23+
INTEG_TEST("integ-test"),
24+
DEFAULT("elasticsearch"),
25+
OSS("elasticsearch-oss");
2626

2727
private final String fileName;
28-
private final String fileExtension;
2928

30-
Distribution(String name, String fileExtension) {
29+
Distribution(String name) {
3130
this.fileName = name;
32-
this.fileExtension = fileExtension;
3331
}
3432

35-
public String getFileName() {
33+
public String getArtifactName() {
3634
return fileName;
3735
}
3836

3937
public String getFileExtension() {
40-
return fileExtension;
38+
if (this.equals(INTEG_TEST)) {
39+
return "zip";
40+
} else {
41+
return OS.conditionalString()
42+
.onUnix(() -> "tar.gz")
43+
.onWindows(() -> "zip")
44+
.supply();
45+
}
46+
}
47+
48+
public String getClassifier() {
49+
return OS.<String>conditional()
50+
.onLinux(() -> "linux-x86_64")
51+
.onWindows(() -> "windows-x86_64")
52+
.onMac(() -> "darwin-x86_64")
53+
.supply();
4154
}
4255
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.elasticsearch.gradle;
20+
21+
import java.util.Arrays;
22+
import java.util.HashMap;
23+
import java.util.HashSet;
24+
import java.util.Map;
25+
import java.util.function.Supplier;
26+
27+
public enum OS {
28+
WINDOWS,
29+
MAC,
30+
LINUX;
31+
32+
public static OS current() {
33+
String os = System.getProperty("os.name", "");
34+
if (os.startsWith("Windows")) {
35+
return OS.WINDOWS;
36+
}
37+
if (os.startsWith("Linux") || os.startsWith("LINUX")) {
38+
return OS.LINUX;
39+
}
40+
if (os.startsWith("Mac")) {
41+
return OS.MAC;
42+
}
43+
throw new IllegalStateException("Can't determine OS from: " + os);
44+
}
45+
46+
public static class Conditional<T> {
47+
48+
private final Map<OS, Supplier<T>> conditions = new HashMap<>();
49+
50+
public Conditional<T> onWindows(Supplier<T> supplier) {
51+
conditions.put(WINDOWS, supplier);
52+
return this;
53+
}
54+
55+
public Conditional<T> onLinux(Supplier<T> supplier) {
56+
conditions.put(LINUX, supplier);
57+
return this;
58+
}
59+
60+
public Conditional<T> onMac(Supplier<T> supplier) {
61+
conditions.put(MAC, supplier);
62+
return this;
63+
}
64+
65+
public Conditional<T> onUnix(Supplier<T> supplier) {
66+
conditions.put(MAC, supplier);
67+
conditions.put(LINUX, supplier);
68+
return this;
69+
}
70+
71+
public T supply() {
72+
HashSet<OS> missingOS = new HashSet<>(Arrays.asList(OS.values()));
73+
missingOS.removeAll(conditions.keySet());
74+
if (missingOS.isEmpty() == false) {
75+
throw new IllegalArgumentException("No condition specified for " + missingOS);
76+
}
77+
return conditions.get(OS.current()).get();
78+
}
79+
80+
}
81+
82+
public static <T> Conditional<T> conditional() {
83+
return new Conditional<>();
84+
}
85+
86+
public static Conditional<String> conditionalString() {
87+
return conditional();
88+
}
89+
90+
}

0 commit comments

Comments
 (0)