maven_jar: Support download of artifacts from Maven snapshot repo
When the repository type is MAVEN_SNAPSHOT, the artifact is downloaded
from the Maven snapshot repository [1].
The artifact ID is given in the form:
group:name:version:snapshot
where `group`, `name` and `version` are as before, and `snapshot` is
the snapshot timestamp (i.e. '20160407.201829-175').
[1] https://oss.sonatype.org/content/repositories/snapshots/
Change-Id: I992eb1461aa976ccc5137669270abe704f260500
diff --git a/lib/maven.defs b/lib/maven.defs
index 28c3146..913be35 100644
--- a/lib/maven.defs
+++ b/lib/maven.defs
@@ -16,6 +16,7 @@
GERRIT_API = 'GERRIT_API:'
MAVEN_CENTRAL = 'MAVEN_CENTRAL:'
MAVEN_LOCAL = 'MAVEN_LOCAL:'
+MAVEN_SNAPSHOT = 'MAVEN_SNAPSHOT:'
def define_license(name):
n = 'LICENSE-' + name
@@ -43,23 +44,48 @@
local_license = False):
from os import path
+ def maven_snapshot(parts):
+ if len(parts) != 4:
+ raise NameError('%s:\nexpected id="groupId:artifactId:version:snapshot]"'
+ % id)
+ group, artifact, version, snapshot = parts
+ jar = path.join(name,
+ version + '-SNAPSHOT',
+ '-'.join([artifact.lower(), version, snapshot]))
+ url = '/'.join([
+ repository,
+ group.replace('.', '/'),
+ artifact,
+ version + '-SNAPSHOT',
+ '-'.join([artifact.lower(), version, snapshot])])
+ return jar, url
+
+ def maven_release(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
+ file_version = version + '-' + classifier
+ else:
+ group, artifact, version = parts
+ file_version = version
+
+ jar = path.join(name, artifact.lower() + '-' + file_version)
+ url = '/'.join([
+ repository,
+ group.replace('.', '/'),
+ artifact,
+ version,
+ artifact + '-' + file_version])
+
+ return jar, url
+
parts = id.split(':')
- 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
- file_version = version + '-' + classifier
+ if repository.startswith(MAVEN_SNAPSHOT):
+ jar, url = maven_snapshot(parts)
else:
- group, artifact, version = parts
- file_version = version
-
- jar = path.join(name, artifact.lower() + '-' + file_version)
-
- url = '/'.join([
- repository,
- group.replace('.', '/'), artifact, version,
- artifact + '-' + file_version])
+ jar, url = maven_release(parts)
binjar = jar + '.jar'
binurl = url + '.jar'
diff --git a/tools/util.py b/tools/util.py
index 96f6047..08a803f 100644
--- a/tools/util.py
+++ b/tools/util.py
@@ -20,6 +20,7 @@
'GERRIT_API': 'https://gerrit-api.commondatastorage.googleapis.com/release',
'MAVEN_CENTRAL': 'http://repo1.maven.org/maven2',
'MAVEN_LOCAL': 'file://' + path.expanduser('~/.m2/repository'),
+ 'MAVEN_SNAPSHOT': 'https://oss.sonatype.org/content/repositories/snapshots',
}