Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / solenv / maven / mvn.py
blobcaa15eeb9fd8543960d2ee7abe8774155fbd9672
1 #!/usr/bin/python
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 from __future__ import print_function
9 from optparse import OptionParser
10 from os import path, environ
11 from subprocess import check_output
12 from sys import stderr
14 M = {
15 'juh': 'javaunohelper',
16 'jurt': 'jurt',
17 'officebean': 'bean',
18 'ridl': 'ridljar',
19 'unoil': 'unoil',
20 'unoloader': 'ridljar',
23 opts = OptionParser()
24 opts.add_option('--repository', help='maven repository id')
25 opts.add_option('--url', help='maven repository url')
26 opts.add_option('-o')
27 opts.add_option('-a', help='action (valid actions are: install,deploy)')
28 opts.add_option('-v', help='gerrit version')
29 opts.add_option('-s', action='append', help='triplet of artifactId:type:path')
31 args, ctx = opts.parse_args()
32 if not args.v:
33 print('version is empty', file=stderr)
34 exit(1)
36 root = path.abspath(__file__)
37 while not path.exists(path.join(root, '.buckconfig')):
38 root = path.dirname(root)
40 if 'install' == args.a:
41 cmd = [
42 'mvn',
43 'install:install-file',
44 '-Dversion=%s' % args.v,
46 elif 'deploy' == args.a:
47 cmd = [
48 'mvn',
49 'gpg:sign-and-deploy-file',
50 '-DrepositoryId=%s' % args.repository,
51 '-Durl=%s' % args.url,
53 else:
54 print("unknown action -a %s" % args.a, file=stderr)
55 exit(1)
57 for spec in args.s:
58 artifact, packaging_type, src = spec.split(':')
59 exe = cmd + [
60 '-DpomFile=%s' % path.join(root, '%s/pom.%s.xml' % (M[artifact], artifact)),
61 '-Dpackaging=%s' % packaging_type,
62 '-Dfile=%s' % src,
64 try:
65 if environ.get('VERBOSE'):
66 print(' '.join(exe), file=stderr)
67 check_output(exe)
68 except Exception as e:
69 print('%s command failed: %s' % (args.a, e), file=stderr)
70 exit(1)
72 with open(args.o, 'w') as fd:
73 if args.repository:
74 print('Repository: %s' % args.repository, file=fd)
75 if args.url:
76 print('URL: %s' % args.url, file=fd)
77 print('Version: %s' % args.v, file=fd)