Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions python/rpdk/java/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions tests/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down