Files
gerrit/tools/maven/mvn.py
Shawn Pearce 064978650b Move Maven support to //tools/maven
Rewrite the Maven tool to accept a spec of things to process on the
command line and use $(location) in the invoking genrule() to locate
the necessary files from Buck.  This gets rid of special cases in the
mvn wrapper tool and allows the definition to be given completely from
Buck as part of the build description.

Maven needs to be single threaded to perform repository updates safely
so only one genrule() target is declared to buck for the deploy or
install action. The rule is given all artifact information in a single
pass, allowing the mvn.py wrapper to execute them.

Change-Id: Idbcf645b69280420987a0e8f52947ba93ac9e6f0
2013-07-29 17:30:58 -07:00

62 lines
1.8 KiB
Python

#!/usr/bin/python
# Copyright (C) 2013 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from optparse import OptionParser
from sys import stderr
from util import check_output
opts = OptionParser()
opts.add_option('--repository', help='maven repository id')
opts.add_option('--url', help='maven repository url')
opts.add_option('-a', help='action (valid actions are: install,deploy)')
opts.add_option('-v', help='gerrit version')
opts.add_option('-s', action='append', help='triplet of artifactId:type:path')
args, ctx = opts.parse_args()
if not args.v:
print('version is empty', file=stderr)
exit(1)
common = [
'-DgroupId=com.google.gerrit',
'-Dversion=%s' % args.v,
]
if 'install' == args.a:
cmd = ['mvn', 'install:install-file'] + common
elif 'deploy' == args.a:
cmd = [
'mvn',
'deploy:deploy-file',
'-DrepositoryId=%s' % args.repository,
'-Durl=%s' % args.url,
] + common
else:
print("unknown action -a %s" % args.a, file=stderr)
exit(1)
for spec in args.s:
artifact, type, src = spec.split(':')
try:
check_output(cmd + [
'-DartifactId=%s' % artifact,
'-Dpackaging=%s' % type,
'-Dfile=%s' % src,
])
except Exception as e:
print('%s command failed: %s' % (action, e), file=stderr)
exit(1)