1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix : get proper snapshotVersion when no classifier (#27102) (#27103)

This commit is contained in:
Laurent Ribot 2017-08-23 16:42:48 +02:00 committed by Chris Alfonso
parent f93515adb9
commit f92ae0831b

View file

@ -166,7 +166,7 @@ from ansible.module_utils.urls import fetch_url
class Artifact(object):
def __init__(self, group_id, artifact_id, version, classifier=None, extension='jar'):
def __init__(self, group_id, artifact_id, version, classifier='', extension='jar'):
if not group_id:
raise ValueError("group_id must be set")
if not artifact_id:
@ -261,10 +261,9 @@ class MavenDownloader:
timestamp = xml.xpath("/metadata/versioning/snapshot/timestamp/text()")[0]
buildNumber = xml.xpath("/metadata/versioning/snapshot/buildNumber/text()")[0]
for snapshotArtifact in xml.xpath("/metadata/versioning/snapshotVersions/snapshotVersion"):
if (len(snapshotArtifact.xpath("classifier/text()")) > 0 and
snapshotArtifact.xpath("classifier/text()")[0] == artifact.classifier and
len(snapshotArtifact.xpath("extension/text()")) > 0 and
snapshotArtifact.xpath("extension/text()")[0] == artifact.extension):
artifact_classifier = snapshotArtifact.xpath("classifier/text()")[0] if len(snapshotArtifact.xpath("classifier/text()")) > 0 else ''
artifact_extension = snapshotArtifact.xpath("extension/text()")[0] if len(snapshotArtifact.xpath("extension/text()")) > 0 else ''
if artifact_classifier == artifact.classifier and artifact_extension == artifact.extension:
return self._uri_for_artifact(artifact, snapshotArtifact.xpath("value/text()")[0])
return self._uri_for_artifact(artifact, artifact.version.replace("SNAPSHOT", timestamp + "-" + buildNumber))
@ -375,7 +374,7 @@ def main():
group_id = dict(default=None),
artifact_id = dict(default=None),
version = dict(default="latest"),
classifier = dict(default=None),
classifier = dict(default=''),
extension = dict(default='jar'),
repository_url = dict(default=None),
username = dict(default=None,aliases=['aws_secret_key']),