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
This commit is contained in:
David Pursehouse 2015-03-05 12:23:13 +09:00
parent dcdddf2fc5
commit 371030566b

View File

@ -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,