diff --git a/changelogs/fragments/713-maven-timestamp-snapshot.yml b/changelogs/fragments/713-maven-timestamp-snapshot.yml new file mode 100644 index 0000000000..1b308bbcfa --- /dev/null +++ b/changelogs/fragments/713-maven-timestamp-snapshot.yml @@ -0,0 +1,2 @@ +bugfixes: +- "maven_artifact - handle timestamped snapshot version strings properly (https://github.com/ansible-collections/community.general/issues/709)." diff --git a/plugins/modules/packaging/language/maven_artifact.py b/plugins/modules/packaging/language/maven_artifact.py index edd7078b45..03c3d4d44f 100644 --- a/plugins/modules/packaging/language/maven_artifact.py +++ b/plugins/modules/packaging/language/maven_artifact.py @@ -215,6 +215,7 @@ import shutil import io import tempfile import traceback +import re from ansible.module_utils.ansible_release import __version__ as ansible_version from re import match @@ -307,7 +308,11 @@ class Artifact(object): def path(self, with_version=True): base = posixpath.join(self.group_id.replace(".", "/"), self.artifact_id) if with_version and self.version: - base = posixpath.join(base, self.version) + timestamp_version_match = re.match("^(.*-)?([0-9]{8}\\.[0-9]{6}-[0-9]+)$", self.version) + if timestamp_version_match: + base = posixpath.join(base, timestamp_version_match.group(1) + "SNAPSHOT") + else: + base = posixpath.join(base, self.version) return base def _generate_filename(self):