diff --git a/python/rpdk/java/codegen.py b/python/rpdk/java/codegen.py index 9d03c919..6a8e6d27 100644 --- a/python/rpdk/java/codegen.py +++ b/python/rpdk/java/codegen.py @@ -399,24 +399,34 @@ def generate(self, project): ) project.overwrite(path, contents) - # Update settings - java_plugin_dependency_version = self._get_java_plugin_dependency_version( - project - ) - if java_plugin_dependency_version < MINIMUM_JAVA_DEPENDENCY_VERSION: - raise JavaPluginVersionNotSupportedError( - "'aws-cloudformation-rpdk-java-plugin' {} is no longer supported." - "Please update it in pom.xml to version {} or above.".format( - java_plugin_dependency_version, MINIMUM_JAVA_DEPENDENCY_VERSION + self._update_settings(project) + + LOG.debug("Generate complete") + + def _update_settings(self, project): + try: + java_plugin_dependency_version = self._get_java_plugin_dependency_version( + project + ) + if java_plugin_dependency_version < MINIMUM_JAVA_DEPENDENCY_VERSION: + raise JavaPluginVersionNotSupportedError( + "'aws-cloudformation-rpdk-java-plugin' {} is no longer supported." + "Please update it in pom.xml to version {} or above.".format( + java_plugin_dependency_version, MINIMUM_JAVA_DEPENDENCY_VERSION + ) ) + except JavaPluginNotFoundError: + LOG.info( + "Please make sure to have 'aws-cloudformation-rpdk-java-plugin' " + "to version %s or above.", + MINIMUM_JAVA_DEPENDENCY_VERSION, ) + protocol_version = project.settings.get(PROTOCOL_VERSION_SETTING) if protocol_version != DEFAULT_PROTOCOL_VERSION: project.settings[PROTOCOL_VERSION_SETTING] = DEFAULT_PROTOCOL_VERSION project.write_settings() - LOG.debug("Generate complete") - @staticmethod def _find_jar(project): jar_glob = list( diff --git a/tests/test_codegen.py b/tests/test_codegen.py index 57ead838..0d8926c8 100644 --- a/tests/test_codegen.py +++ b/tests/test_codegen.py @@ -169,6 +169,12 @@ def test__get_plugin_version_not_found(project): project._plugin._get_java_plugin_dependency_version(project) +def test_generate_without_java_plugin_in_pom_should_not_fail(project): + make_pom_xml_without_plugin(project) + project.generate() + assert project.settings["protocolVersion"] == "2.0.0" + + def test__get_plugin_version_invalid_pom(project): pom = open(project.root / "pom.xml", "w") pom.write("invalid pom")