forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
component_opensearch_min.py
47 lines (38 loc) · 1.7 KB
/
component_opensearch_min.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
from typing import Any, List
from git.git_repository import GitRepository
from manifests_workflow.component import Component
from manifests_workflow.component_opensearch import ComponentOpenSearch
from system.properties_file import PropertiesFile
class ComponentOpenSearchMin(Component):
def __init__(self, repo: GitRepository, snapshot: bool = False) -> None:
super().__init__(
"OpenSearch",
repo,
snapshot,
["gradle:publish", "gradle:properties:version"],
)
@classmethod
def branches(self, url: str = "https://github.com/opensearch-project/OpenSearch.git") -> List[str]:
return Component.branches(url)
@classmethod
def checkout(self, path: str, branch: str = "main", snapshot: bool = False) -> 'ComponentOpenSearchMin':
return ComponentOpenSearchMin(
GitRepository("https://github.com/opensearch-project/OpenSearch.git", branch, path),
snapshot,
)
def publish_to_maven_local(self) -> None:
cmd = ComponentOpenSearch.gradle_cmd("publishToMavenLocal", {"build.snapshot": str(self.snapshot).lower()})
self.git_repo.execute_silent(cmd)
@property
def properties(self) -> PropertiesFile:
cmd = ComponentOpenSearch.gradle_cmd("properties", {"build.snapshot": str(self.snapshot).lower()})
return PropertiesFile(self.git_repo.output(cmd))
@property
def version(self) -> Any:
self.publish_to_maven_local()
return self.properties.get_value("version")