|
9 | 9 |
|
10 | 10 | package org.elasticsearch.gradle.internal.release;
|
11 | 11 |
|
12 |
| -import com.github.javaparser.StaticJavaParser; |
13 |
| -import com.github.javaparser.ast.CompilationUnit; |
14 |
| -import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; |
15 |
| -import com.github.javaparser.ast.expr.NameExpr; |
16 |
| -import com.github.javaparser.printer.lexicalpreservation.LexicalPreservingPrinter; |
17 |
| - |
18 | 12 | import org.elasticsearch.gradle.Version;
|
19 | 13 | import org.gradle.api.tasks.TaskAction;
|
20 | 14 | import org.gradle.api.tasks.options.Option;
|
21 | 15 | import org.gradle.initialization.layout.BuildLayout;
|
22 | 16 |
|
23 | 17 | import java.io.IOException;
|
24 |
| -import java.nio.file.Path; |
25 | 18 | import java.util.List;
|
26 | 19 | import java.util.Map;
|
27 |
| -import java.util.Optional; |
28 | 20 |
|
29 | 21 | import javax.inject.Inject;
|
30 | 22 |
|
@@ -68,34 +60,5 @@ public void executeTask() throws IOException {
|
68 | 60 | if (transportVersion == null) {
|
69 | 61 | throw new IllegalArgumentException("TransportVersion id not specified");
|
70 | 62 | }
|
71 |
| - Path versionJava = rootDir.resolve(TRANSPORT_VERSIONS_FILE_PATH); |
72 |
| - CompilationUnit file = LexicalPreservingPrinter.setup(StaticJavaParser.parse(versionJava)); |
73 |
| - |
74 |
| - Optional<CompilationUnit> modifiedFile; |
75 |
| - |
76 |
| - modifiedFile = setMinimumCcsTransportVersion(file, transportVersion); |
77 |
| - |
78 |
| - if (modifiedFile.isPresent()) { |
79 |
| - writeOutNewContents(versionJava, modifiedFile.get()); |
80 |
| - } |
81 |
| - } |
82 |
| - |
83 |
| - static Optional<CompilationUnit> setMinimumCcsTransportVersion(CompilationUnit unit, int transportVersion) { |
84 |
| - ClassOrInterfaceDeclaration transportVersions = unit.getClassByName("TransportVersions").get(); |
85 |
| - |
86 |
| - String tvConstantName = transportVersions.getFields().stream().filter(f -> { |
87 |
| - var i = findSingleIntegerExpr(f); |
88 |
| - return i.isPresent() && i.getAsInt() == transportVersion; |
89 |
| - }) |
90 |
| - .map(f -> f.getVariable(0).getNameAsString()) |
91 |
| - .findFirst() |
92 |
| - .orElseThrow(() -> new IllegalStateException("Could not find constant for id " + transportVersion)); |
93 |
| - |
94 |
| - transportVersions.getFieldByName("MINIMUM_CCS_VERSION") |
95 |
| - .orElseThrow(() -> new IllegalStateException("Could not find MINIMUM_CCS_VERSION constant")) |
96 |
| - .getVariable(0) |
97 |
| - .setInitializer(new NameExpr(tvConstantName)); |
98 |
| - |
99 |
| - return Optional.of(unit); |
100 | 63 | }
|
101 | 64 | }
|
0 commit comments