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
diff --git a/maven_jar.bucklet b/maven_jar.bucklet
index bf25d6e..0692fc4 100644
--- a/maven_jar.bucklet
+++ b/maven_jar.bucklet
@@ -75,9 +75,14 @@
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
if 'SNAPSHOT' in version and repository != MAVEN_LOCAL:
file_version = version.replace('-SNAPSHOT', '')
@@ -85,6 +90,9 @@
else:
file_version = version
+ if classifier is not None:
+ file_version += '-' + classifier
+
jar = path.join(name, artifact.lower() + '-' + file_version)
url = '/'.join([
repository,