Skip to content

Commit ee42201

Browse files
author
Wenbing Li
authored
Not fail if java plugin don't in pom.xml (#295)
1 parent 682214d commit ee42201

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

python/rpdk/java/codegen.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -399,24 +399,34 @@ def generate(self, project):
399399
)
400400
project.overwrite(path, contents)
401401

402-
# Update settings
403-
java_plugin_dependency_version = self._get_java_plugin_dependency_version(
404-
project
405-
)
406-
if java_plugin_dependency_version < MINIMUM_JAVA_DEPENDENCY_VERSION:
407-
raise JavaPluginVersionNotSupportedError(
408-
"'aws-cloudformation-rpdk-java-plugin' {} is no longer supported."
409-
"Please update it in pom.xml to version {} or above.".format(
410-
java_plugin_dependency_version, MINIMUM_JAVA_DEPENDENCY_VERSION
402+
self._update_settings(project)
403+
404+
LOG.debug("Generate complete")
405+
406+
def _update_settings(self, project):
407+
try:
408+
java_plugin_dependency_version = self._get_java_plugin_dependency_version(
409+
project
410+
)
411+
if java_plugin_dependency_version < MINIMUM_JAVA_DEPENDENCY_VERSION:
412+
raise JavaPluginVersionNotSupportedError(
413+
"'aws-cloudformation-rpdk-java-plugin' {} is no longer supported."
414+
"Please update it in pom.xml to version {} or above.".format(
415+
java_plugin_dependency_version, MINIMUM_JAVA_DEPENDENCY_VERSION
416+
)
411417
)
418+
except JavaPluginNotFoundError:
419+
LOG.info(
420+
"Please make sure to have 'aws-cloudformation-rpdk-java-plugin' "
421+
"to version %s or above.",
422+
MINIMUM_JAVA_DEPENDENCY_VERSION,
412423
)
424+
413425
protocol_version = project.settings.get(PROTOCOL_VERSION_SETTING)
414426
if protocol_version != DEFAULT_PROTOCOL_VERSION:
415427
project.settings[PROTOCOL_VERSION_SETTING] = DEFAULT_PROTOCOL_VERSION
416428
project.write_settings()
417429

418-
LOG.debug("Generate complete")
419-
420430
@staticmethod
421431
def _find_jar(project):
422432
jar_glob = list(

tests/test_codegen.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ def test__get_plugin_version_not_found(project):
169169
project._plugin._get_java_plugin_dependency_version(project)
170170

171171

172+
def test_generate_without_java_plugin_in_pom_should_not_fail(project):
173+
make_pom_xml_without_plugin(project)
174+
project.generate()
175+
assert project.settings["protocolVersion"] == "2.0.0"
176+
177+
172178
def test__get_plugin_version_invalid_pom(project):
173179
pom = open(project.root / "pom.xml", "w")
174180
pom.write("invalid pom")

0 commit comments

Comments
 (0)