Skip to content

Commit 2a2d6b7

Browse files
Fix: Support JVM version string from old (< v8.9) and new (>= v8.9) gradle version (#683)
* fix(validator): support version string from old and newest gradle * fix(test): fix unit test * test: add more version and runtime to the test * refactor(validator): use full label instead * fix(validator): use in operator to check JVM substring --------- Co-authored-by: Mehmet Nuri Deveci <[email protected]>
1 parent 2b1aee1 commit 2a2d6b7

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

aws_lambda_builders/workflows/java_gradle/gradle_validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,5 @@ def _get_jvm_string(self, gradle_path):
8383

8484
for line in stdout.splitlines():
8585
l_dec = decode(line)
86-
if l_dec.startswith("JVM"):
86+
if "JVM" in l_dec:
8787
return l_dec

tests/unit/workflows/java_gradle/test_gradle_validator.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,40 @@ def test_emits_warning_when_version_string_not_found(self):
7878
validator.validate(runtime_path=self.runtime_path)
7979
self.mock_log.warning.assert_called_with(GradleValidator.VERSION_STRING_WARNING, self.runtime_path)
8080

81+
@parameterized.expand(
82+
[
83+
("1.8.0", "java8"),
84+
("11.0.0", "java11"),
85+
("17.0.0", "java17"),
86+
("21.0.0", "java21"),
87+
]
88+
)
89+
def test_does_not_emit_warning_for_version_string_in_gradle_lt_8_9(self, version, runtime):
90+
version_string = f"JVM: {version}".encode()
91+
self.mock_os_utils.popen.side_effect = [FakePopen(stdout=version_string, returncode=0)]
92+
validator = GradleValidator(
93+
runtime=runtime, architecture=self.architecture, os_utils=self.mock_os_utils, log=self.mock_log
94+
)
95+
validator.validate(runtime_path=self.runtime_path)
96+
self.mock_log.warning.assert_not_called()
97+
98+
@parameterized.expand(
99+
[
100+
("1.8.0", "java8"),
101+
("11.0.0", "java11"),
102+
("17.0.0", "java17"),
103+
("21.0.0", "java21"),
104+
]
105+
)
106+
def test_does_not_emit_warning_for_version_string_in_gradle_ge_8_9(self, version, runtime):
107+
version_string = f"Launcher JVM: {version}".encode()
108+
self.mock_os_utils.popen.side_effect = [FakePopen(stdout=version_string, returncode=0)]
109+
validator = GradleValidator(
110+
runtime=runtime, architecture=self.architecture, os_utils=self.mock_os_utils, log=self.mock_log
111+
)
112+
validator.validate(runtime_path=self.runtime_path)
113+
self.mock_log.warning.assert_not_called()
114+
81115
@parameterized.expand(
82116
[
83117
("11.0.0", "java11"),

0 commit comments

Comments
 (0)