Skip to content

Commit 8418c15

Browse files
committed
Revert formatted ahead of merge with master
1 parent 7d69c76 commit 8418c15

File tree

73 files changed

+862
-1821
lines changed

Some content is hidden

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

73 files changed

+862
-1821
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@ package org.elasticsearch.gradle.doc
2121
import org.elasticsearch.gradle.OS
2222
import org.elasticsearch.gradle.Version
2323
import org.elasticsearch.gradle.VersionProperties
24-
import org.elasticsearch.gradle.test.RestTestPlugin
24+
import org.gradle.api.Plugin
2525
import org.gradle.api.Project
2626
import org.gradle.api.Task
27+
2728
/**
2829
* Sets up tests for documentation.
2930
*/
30-
public class DocsTestPlugin extends RestTestPlugin {
31+
class DocsTestPlugin implements Plugin<Project> {
3132

3233
@Override
33-
public void apply(Project project) {
34+
void apply(Project project) {
3435
project.pluginManager.apply('elasticsearch.testclusters')
3536
project.pluginManager.apply('elasticsearch.standalone-rest-test')
36-
super.apply(project)
37+
project.pluginManager.apply('elasticsearch.rest-test')
38+
3739
String distribution = System.getProperty('tests.distribution', 'default')
3840
// The distribution can be configured with -Dtests.distribution on the command line
3941
project.testClusters.integTest.testDistribution = distribution.toUpperCase()

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/DistroTestPlugin.java

Lines changed: 96 additions & 157 deletions
Large diffs are not rendered by default.

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

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,15 @@ public BwcVersions(List<String> versionLines) {
109109
}
110110

111111
protected BwcVersions(List<String> versionLines, Version currentVersionProperty) {
112-
this(
113-
versionLines.stream()
114-
.map(LINE_PATTERN::matcher)
115-
.filter(Matcher::matches)
116-
.map(
117-
match -> new Version(
118-
Integer.parseInt(match.group(1)),
119-
Integer.parseInt(match.group(2)),
120-
Integer.parseInt(match.group(3))
121-
)
122-
)
123-
.collect(Collectors.toCollection(TreeSet::new)),
124-
currentVersionProperty
125-
);
112+
this(versionLines.stream()
113+
.map(LINE_PATTERN::matcher)
114+
.filter(Matcher::matches)
115+
.map(match -> new Version(
116+
Integer.parseInt(match.group(1)),
117+
Integer.parseInt(match.group(2)),
118+
Integer.parseInt(match.group(3))
119+
))
120+
.collect(Collectors.toCollection(TreeSet::new)), currentVersionProperty);
126121
}
127122

128123
// for testkit tests, until BwcVersions is extracted into an extension
@@ -145,10 +140,8 @@ public BwcVersions(SortedSet<Version> allVersions, Version currentVersionPropert
145140

146141
Map<Version, UnreleasedVersionInfo> unreleased = new HashMap<>();
147142
for (Version unreleasedVersion : getUnreleased()) {
148-
unreleased.put(
149-
unreleasedVersion,
150-
new UnreleasedVersionInfo(unreleasedVersion, getBranchFor(unreleasedVersion), getGradleProjectPathFor(unreleasedVersion))
151-
);
143+
unreleased.put(unreleasedVersion,
144+
new UnreleasedVersionInfo(unreleasedVersion, getBranchFor(unreleasedVersion), getGradleProjectPathFor(unreleasedVersion)));
152145
}
153146
this.unreleased = Collections.unmodifiableMap(unreleased);
154147
}
@@ -182,8 +175,7 @@ public UnreleasedVersionInfo unreleasedInfo(Version version) {
182175
public void forPreviousUnreleased(Consumer<UnreleasedVersionInfo> consumer) {
183176
List<UnreleasedVersionInfo> collect = getUnreleased().stream()
184177
.filter(version -> version.equals(currentVersion) == false)
185-
.map(
186-
version -> new UnreleasedVersionInfo(
178+
.map(version -> new UnreleasedVersionInfo(
187179
version,
188180
getBranchFor(version),
189181
getGradleProjectPathFor(version)
@@ -210,7 +202,7 @@ private String getGradleProjectPathFor(Version version) {
210202
if (unreleasedStagedOrMinor.size() > 2) {
211203
if (unreleasedStagedOrMinor.get(unreleasedStagedOrMinor.size() - 2).equals(version)) {
212204
return ":distribution:bwc:minor";
213-
} else {
205+
} else{
214206
return ":distribution:bwc:staged";
215207
}
216208
} else {
@@ -237,7 +229,7 @@ private String getBranchFor(Version version) {
237229
return "master";
238230
case ":distribution:bwc:minor":
239231
// The .x branch will always point to the latest minor (for that major), so a "minor" project will be on the .x branch
240-
// unless there is more recent (higher) minor.
232+
// unless there is more recent (higher) minor.
241233
final Version latestInMajor = getLatestVersionByKey(groupByMajor, version.getMajor());
242234
if (latestInMajor.getMinor() == version.getMinor()) {
243235
return version.getMajor() + ".x";
@@ -296,16 +288,14 @@ public List<Version> getUnreleased() {
296288
}
297289

298290
private Version getLatestInMinor(int major, int minor) {
299-
return groupByMajor.get(major)
300-
.stream()
291+
return groupByMajor.get(major).stream()
301292
.filter(v -> v.getMinor() == minor)
302293
.max(Version::compareTo)
303294
.orElse(null);
304295
}
305296

306297
private Version getLatestVersionByKey(Map<Integer, List<Version>> groupByMajor, int key) {
307-
return groupByMajor.getOrDefault(key, emptyList())
308-
.stream()
298+
return groupByMajor.getOrDefault(key, emptyList()).stream()
309299
.max(Version::compareTo)
310300
.orElseThrow(() -> new IllegalStateException("Unexpected number of versions in collection"));
311301
}
@@ -350,8 +340,7 @@ public void compareToAuthoritative(List<Version> authoritativeReleasedVersions)
350340

351341
private List<Version> getReleased() {
352342
List<Version> unreleased = getUnreleased();
353-
return groupByMajor.values()
354-
.stream()
343+
return groupByMajor.values().stream()
355344
.flatMap(Collection::stream)
356345
.filter(each -> unreleased.contains(each) == false)
357346
.collect(Collectors.toList());
@@ -372,7 +361,10 @@ public List<Version> getWireCompatible() {
372361

373362
List<Version> prevMajors = groupByMajor.get(currentVersion.getMajor() - 1);
374363
int minor = prevMajors.get(prevMajors.size() - 1).getMinor();
375-
for (int i = prevMajors.size() - 1; i > 0 && prevMajors.get(i).getMinor() == minor; i--) {
364+
for (int i = prevMajors.size() - 1;
365+
i > 0 && prevMajors.get(i).getMinor() == minor;
366+
i--
367+
) {
376368
wireCompat.add(prevMajors.get(i));
377369
}
378370
wireCompat.addAll(groupByMajor.get(currentVersion.getMajor()));

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,15 @@ public void setFiles(FileTree files) {
5555
}
5656

5757
@InputFiles
58-
public FileTree getFiles() {
59-
return files;
60-
}
58+
public FileTree getFiles() { return files; }
6159

6260
public void setHeaderLine(String headerLine) {
6361
this.headerLine = headerLine;
6462
}
6563

6664
@Input
6765
@Optional
68-
public String getHeaderLine() {
69-
return headerLine;
70-
}
66+
public String getHeaderLine() { return headerLine; }
7167

7268
public void setTarget(File target) {
7369
this.target = target;
@@ -93,10 +89,7 @@ public void concatFiles() throws IOException {
9389
uniqueLines.addAll(Files.readAllLines(f.toPath(), StandardCharsets.UTF_8));
9490
}
9591
Files.write(
96-
getTarget().toPath(),
97-
uniqueLines,
98-
StandardCharsets.UTF_8,
99-
StandardOpenOption.APPEND
92+
getTarget().toPath(), uniqueLines, StandardCharsets.UTF_8, StandardOpenOption.APPEND
10093
);
10194
}
10295

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

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ void setupDistributions(Project project) {
9797
if (distribution.getType() != Type.RPM && distribution.getType() != Type.DEB) {
9898
// for the distribution extracted, add a root level task that does the extraction, and depend on that
9999
// extracted configuration as an artifact consisting of the extracted distribution directory
100-
dependencies.add(
101-
distribution.getExtracted().configuration.getName(),
102-
projectDependency(project, ":", configName("extracted_elasticsearch", distribution))
103-
);
100+
dependencies.add(distribution.getExtracted().configuration.getName(),
101+
projectDependency(project, ":", configName("extracted_elasticsearch", distribution)));
104102
// ensure a root level download task exists
105103
setupRootDownload(project.getRootProject(), distribution);
106104
}
@@ -133,7 +131,7 @@ private void setupRootDownload(Project rootProject, ElasticsearchDistribution di
133131
TaskProvider<Sync> extractTask = rootProject.getTasks().register(extractTaskName, Sync.class, syncTask -> {
134132
syncTask.dependsOn(downloadConfig);
135133
syncTask.into(extractDir);
136-
syncTask.from((Callable<FileTree>) () -> {
134+
syncTask.from((Callable<FileTree>)() -> {
137135
File archiveFile = archiveGetter.get();
138136
String archivePath = archiveFile.toString();
139137
if (archivePath.endsWith(".zip")) {
@@ -144,12 +142,9 @@ private void setupRootDownload(Project rootProject, ElasticsearchDistribution di
144142
throw new IllegalStateException("unexpected file extension on [" + archivePath + "]");
145143
});
146144
});
147-
rootProject.getArtifacts()
148-
.add(
149-
extractedConfigName,
150-
rootProject.getLayout().getProjectDirectory().dir(extractDir),
151-
artifact -> artifact.builtBy(extractTask)
152-
);
145+
rootProject.getArtifacts().add(extractedConfigName,
146+
rootProject.getLayout().getProjectDirectory().dir(extractDir),
147+
artifact -> artifact.builtBy(extractTask));
153148
}
154149
}
155150

@@ -162,13 +157,10 @@ private static void setupDownloadServiceRepo(Project project) {
162157
ivyRepo.setUrl("https://artifacts.elastic.co");
163158
ivyRepo.metadataSources(IvyArtifactRepository.MetadataSources::artifact);
164159
// this header is not a credential but we hack the capability to send this header to avoid polluting our download stats
165-
ivyRepo.credentials(
166-
HttpHeaderCredentials.class,
167-
creds -> {
168-
creds.setName("X-Elastic-No-KPI");
169-
creds.setValue("1");
170-
}
171-
);
160+
ivyRepo.credentials(HttpHeaderCredentials.class, creds -> {
161+
creds.setName("X-Elastic-No-KPI");
162+
creds.setValue("1");
163+
});
172164
ivyRepo.getAuthentication().create("header", HttpHeaderAuthentication.class);
173165
ivyRepo.patternLayout(layout -> layout.artifact("/downloads/elasticsearch/[module]-[revision](-[classifier]).[ext]"));
174166
ivyRepo.content(content -> content.includeGroup(FAKE_IVY_GROUP));

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

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,8 @@ public String toString() {
107107
private final Property<Flavor> flavor;
108108
private final Property<Boolean> bundledJdk;
109109

110-
ElasticsearchDistribution(
111-
String name, ObjectFactory objectFactory, Configuration fileConfiguration,
112-
Configuration extractedConfiguration
113-
) {
110+
ElasticsearchDistribution(String name, ObjectFactory objectFactory, Configuration fileConfiguration,
111+
Configuration extractedConfiguration) {
114112
this.name = name;
115113
this.configuration = fileConfiguration;
116114
this.version = objectFactory.property(Version.class);
@@ -174,10 +172,8 @@ public String toString() {
174172

175173
public Extracted getExtracted() {
176174
if (getType() == Type.RPM || getType() == Type.DEB) {
177-
throw new UnsupportedOperationException(
178-
"distribution type [" + getType() + "] for " +
179-
"elasticsearch distribution [" + name + "] cannot be extracted"
180-
);
175+
throw new UnsupportedOperationException("distribution type [" + getType() + "] for " +
176+
"elasticsearch distribution [" + name + "] cannot be extracted");
181177
}
182178
return extracted;
183179
}
@@ -203,18 +199,15 @@ void finalizeValues() {
203199
if (getType() == Type.INTEG_TEST_ZIP) {
204200
if (platform.isPresent()) {
205201
throw new IllegalArgumentException(
206-
"platform not allowed for elasticsearch distribution [" + name + "] of type [integ_test_zip]"
207-
);
202+
"platform not allowed for elasticsearch distribution [" + name + "] of type [integ_test_zip]");
208203
}
209204
if (flavor.isPresent()) {
210205
throw new IllegalArgumentException(
211-
"flavor not allowed for elasticsearch distribution [" + name + "] of type [integ_test_zip]"
212-
);
206+
"flavor not allowed for elasticsearch distribution [" + name + "] of type [integ_test_zip]");
213207
}
214208
if (bundledJdk.isPresent()) {
215209
throw new IllegalArgumentException(
216-
"bundledJdk not allowed for elasticsearch distribution [" + name + "] of type [integ_test_zip]"
217-
);
210+
"bundledJdk not allowed for elasticsearch distribution [" + name + "] of type [integ_test_zip]");
218211
}
219212
return;
220213
}
@@ -226,10 +219,8 @@ void finalizeValues() {
226219
}
227220
} else { // rpm or deb
228221
if (platform.isPresent()) {
229-
throw new IllegalArgumentException(
230-
"platform not allowed for elasticsearch distribution ["
231-
+ name + "] of type [" + getType() + "]"
232-
);
222+
throw new IllegalArgumentException("platform not allowed for elasticsearch distribution ["
223+
+ name + "] of type [" + getType() + "]");
233224
}
234225
}
235226

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ public void setOutputDir(DirectoryProperty outputDir) {
8484

8585
public File copy(String resource) {
8686
if (getState().getExecuted() || getState().getExecuting()) {
87-
throw new GradleException(
88-
"buildResources can't be configured after the task ran. " +
89-
"Make sure task is not used after configuration time"
87+
throw new GradleException("buildResources can't be configured after the task ran. " +
88+
"Make sure task is not used after configuration time"
9089
);
9190
}
9291
resources.add(resource);
@@ -98,8 +97,7 @@ public void doExport() {
9897
if (resources.isEmpty()) {
9998
throw new StopExecutionException();
10099
}
101-
resources.stream()
102-
.parallel()
100+
resources.stream().parallel()
103101
.forEach(resourcePath -> {
104102
Path destination = outputDir.get().file(resourcePath).getAsFile().toPath();
105103
try (InputStream is = getClass().getClassLoader().getResourceAsStream(resourcePath)) {

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ public String getPlatform() {
8787
public void setPlatform(String platform) {
8888
if (ALLOWED_PLATFORMS.contains(platform) == false) {
8989
throw new IllegalArgumentException(
90-
"unknown platform [" + platform + "] for jdk [" + name + "], must be one of " + ALLOWED_PLATFORMS
91-
);
90+
"unknown platform [" + platform + "] for jdk [" + name + "], must be one of " + ALLOWED_PLATFORMS);
9291
}
9392
this.platform.set(platform);
9493
}
@@ -125,8 +124,7 @@ void finalizeValues() {
125124
}
126125
version.finalizeValue();
127126
platform.finalizeValue();
128-
vendor.finalizeValue();
129-
;
127+
vendor.finalizeValue();;
130128
}
131129

132130
@Override

0 commit comments

Comments
 (0)