|
14 | 14 | import com.github.javaparser.ast.expr.NameExpr;
|
15 | 15 | import com.github.javaparser.printer.lexicalpreservation.LexicalPreservingPrinter;
|
16 | 16 |
|
| 17 | +import org.elasticsearch.gradle.Version; |
17 | 18 | import org.gradle.api.tasks.TaskAction;
|
18 | 19 | import org.gradle.api.tasks.options.Option;
|
19 | 20 | import org.gradle.initialization.layout.BuildLayout;
|
|
28 | 29 |
|
29 | 30 | public class SetCompatibleVersionsTask extends AbstractVersionsTask {
|
30 | 31 |
|
| 32 | + private Version thisVersion; |
| 33 | + private Version releaseVersion; |
31 | 34 | private Map<String, Integer> versionIds = Map.of();
|
32 | 35 |
|
33 | 36 | @Inject
|
34 | 37 | public SetCompatibleVersionsTask(BuildLayout layout) {
|
35 | 38 | super(layout);
|
36 | 39 | }
|
37 | 40 |
|
| 41 | + public void setThisVersion(Version version) { |
| 42 | + thisVersion = version; |
| 43 | + } |
| 44 | + |
38 | 45 | @Option(option = "version-id", description = "Version id used for the release. Of the form <VersionType>:<id>.")
|
39 | 46 | public void versionIds(List<String> version) {
|
40 | 47 | this.versionIds = splitVersionIds(version);
|
41 | 48 | }
|
42 | 49 |
|
| 50 | + @Option(option = "release", description = "The version being released") |
| 51 | + public void releaseVersion(String version) { |
| 52 | + releaseVersion = Version.fromString(version); |
| 53 | + } |
| 54 | + |
43 | 55 | @TaskAction
|
44 | 56 | public void executeTask() throws IOException {
|
45 | 57 | if (versionIds.isEmpty()) {
|
46 | 58 | throw new IllegalArgumentException("No version ids specified");
|
47 | 59 | }
|
| 60 | + |
| 61 | + if (releaseVersion.getMajor() < thisVersion.getMajor()) { |
| 62 | + // don't need to update CCS version - this is for a different major |
| 63 | + return; |
| 64 | + } |
| 65 | + |
48 | 66 | Integer transportVersion = versionIds.get(TRANSPORT_VERSION_TYPE);
|
49 | 67 | if (transportVersion == null) {
|
50 | 68 | throw new IllegalArgumentException("TransportVersion id not specified");
|
51 | 69 | }
|
52 |
| - |
53 | 70 | Path versionJava = rootDir.resolve(TRANSPORT_VERSIONS_FILE_PATH);
|
54 | 71 | CompilationUnit file = LexicalPreservingPrinter.setup(StaticJavaParser.parse(versionJava));
|
55 | 72 |
|
|
0 commit comments