From 371030566b77de627cdb133b39f7f3abd4afbd9e Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 5 Mar 2015 12:23:13 +0900 Subject: [PATCH] Buck: Support download of artifacts with classifier Beside the main artifact there can be additional files which are attached to a project. Such attached files can be recognized and accessed by their classifier. Extend the `maven_jar` wrapper to support optionally specifying the classifier in the `id` field, for example: maven_jar( name = 'example', id = 'org.example:example-foo:1.0:extra', ..., ) Change-Id: Ic0a4fbafffe6625b21324e836cde1a2b3a3e4b1c --- lib/maven.defs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/maven.defs b/lib/maven.defs index 4edba9c268..cc45212ac2 100644 --- a/lib/maven.defs +++ b/lib/maven.defs @@ -46,9 +46,14 @@ def maven_jar( from os import path parts = id.split(':') - if len(parts) != 3: - raise NameError('expected id="groupId:artifactId:version"') - group, artifact, version = parts + if len(parts) not in [3, 4]: + raise NameError('%s:\nexpected id="groupId:artifactId:version[:classifier]"' + % id) + if len(parts) == 4: + group, artifact, version, classifier = parts + else: + group, artifact, version = parts + classifier = None # SNAPSHOT artifacts are handled differently on Google storage bucket: # 'SNAPSHOT' is discarded from the directory name. However on other @@ -62,7 +67,11 @@ def maven_jar( else: file_version = version + if classifier is not None: + file_version += '-' + classifier + jar = path.join(name, artifact.lower() + '-' + file_version) + url = '/'.join([ repository, group.replace('.', '/'), artifact, version,