diff --git a/aws_lambda_builders/workflows/java_gradle/gradle_validator.py b/aws_lambda_builders/workflows/java_gradle/gradle_validator.py index 2972e75b..5107b9c2 100644 --- a/aws_lambda_builders/workflows/java_gradle/gradle_validator.py +++ b/aws_lambda_builders/workflows/java_gradle/gradle_validator.py @@ -83,5 +83,5 @@ def _get_jvm_string(self, gradle_path): for line in stdout.splitlines(): l_dec = decode(line) - if l_dec.startswith("JVM"): + if "JVM" in l_dec: return l_dec diff --git a/tests/unit/workflows/java_gradle/test_gradle_validator.py b/tests/unit/workflows/java_gradle/test_gradle_validator.py index 2815b4f6..f51bf5c9 100644 --- a/tests/unit/workflows/java_gradle/test_gradle_validator.py +++ b/tests/unit/workflows/java_gradle/test_gradle_validator.py @@ -78,6 +78,40 @@ def test_emits_warning_when_version_string_not_found(self): validator.validate(runtime_path=self.runtime_path) self.mock_log.warning.assert_called_with(GradleValidator.VERSION_STRING_WARNING, self.runtime_path) + @parameterized.expand( + [ + ("1.8.0", "java8"), + ("11.0.0", "java11"), + ("17.0.0", "java17"), + ("21.0.0", "java21"), + ] + ) + def test_does_not_emit_warning_for_version_string_in_gradle_lt_8_9(self, version, runtime): + version_string = f"JVM: {version}".encode() + self.mock_os_utils.popen.side_effect = [FakePopen(stdout=version_string, returncode=0)] + validator = GradleValidator( + runtime=runtime, architecture=self.architecture, os_utils=self.mock_os_utils, log=self.mock_log + ) + validator.validate(runtime_path=self.runtime_path) + self.mock_log.warning.assert_not_called() + + @parameterized.expand( + [ + ("1.8.0", "java8"), + ("11.0.0", "java11"), + ("17.0.0", "java17"), + ("21.0.0", "java21"), + ] + ) + def test_does_not_emit_warning_for_version_string_in_gradle_ge_8_9(self, version, runtime): + version_string = f"Launcher JVM: {version}".encode() + self.mock_os_utils.popen.side_effect = [FakePopen(stdout=version_string, returncode=0)] + validator = GradleValidator( + runtime=runtime, architecture=self.architecture, os_utils=self.mock_os_utils, log=self.mock_log + ) + validator.validate(runtime_path=self.runtime_path) + self.mock_log.warning.assert_not_called() + @parameterized.expand( [ ("11.0.0", "java11"),