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
This commit is contained in:
parent
4ea69c68c8
commit
777cd1a926
@ -16,6 +16,7 @@ GERRIT = 'GERRIT:'
|
||||
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 @@ def maven_jar(
|
||||
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'
|
||||
|
@ -20,6 +20,7 @@ REPO_ROOTS = {
|
||||
'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',
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user