gerrit/tools/maven/mvn.py
David Ostrovsky 38e6f4462c Buck: Decouple plugin-api installation from deployment
Currently the same pom_fake.xml controls both installing the plugin-api
in local Maven repository (typical use case for a contributor) and
deploying it on Google bucket (typical use case for a maintainer). To fit
the both use cases that file contains stuff needed for uploading to Google
bucket only: 'gs-maven-wagon' artifact and the repository to fetch it from.

Because the "best" build tool in the world randomly and unreproducible
fails to fetch that artifact [1], frustrating the potential contributors,
for reasons that nobody knows and understands, separate these use cases
from each other, and strip the stuff from pom_fake.xml needed for deployment
of plugin-api. The cost is code duplication. The advantage of doing it:

  buck build api_install

just works. Always.

[1] https://gist.github.com/mulby/092fee5f5962aafbbb25#file-gerrit-build-error-txt

Change-Id: I842335907ef8721f4126bcd90e395f7748aefc74
2014-02-10 23:20:09 +01:00

75 lines
2.2 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 os import path
from sys import stderr
from util import check_output
def mvn(action):
return ['mvn', '--file', path.join(self, 'fake_pom_%s.xml' % action)]
opts = OptionParser()
opts.add_option('--repository', help='maven repository id')
opts.add_option('--url', help='maven repository url')
opts.add_option('-o')
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,
]
self = path.dirname(path.abspath(__file__))
if 'install' == args.a:
cmd = mvn(args.a) + ['install:install-file'] + common
elif 'deploy' == args.a:
cmd = mvn(args.a) + [
'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, packaging_type, src = spec.split(':')
try:
check_output(cmd + [
'-DartifactId=%s' % artifact,
'-Dpackaging=%s' % packaging_type,
'-Dfile=%s' % src,
])
except Exception as e:
print('%s command failed: %s' % (args.a, e), file=stderr)
exit(1)
with open(args.o, 'w') as fd:
if args.repository:
print('Repository: %s' % args.repository, file=fd)
if args.url:
print('URL: %s' % args.url, file=fd)
print('Version: %s' % args.v, file=fd)