Colibre: tdf#146410 update Clone Formatting icons
[LibreOffice.git] / solenv / maven / mvn.py
blob5b45447daa07544c727cce2c598d78be64f1ef46
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',
21 'libreoffice': 'ridljar',
24 opts = OptionParser()
25 opts.add_option('--repository', help='maven repository id')
26 opts.add_option('--url', help='maven repository url')
27 opts.add_option('-o')
28 opts.add_option('-a', help='action (valid actions are: install,deploy)')
29 opts.add_option('-v', help='gerrit version')
30 opts.add_option('-s', action='append', help='triplet of artifactId:type:path')
32 args, ctx = opts.parse_args()
33 if not args.v:
34 print('version is empty', file=stderr)
35 exit(1)
37 root = path.abspath(__file__)
38 while not path.exists(path.join(root, '.buckconfig')):
39 root = path.dirname(root)
41 if 'install' == args.a:
42 cmd = [
43 'mvn',
44 'install:install-file',
45 '-Dversion=%s' % args.v,
47 elif 'deploy' == args.a:
48 cmd = [
49 'mvn',
50 'gpg:sign-and-deploy-file',
51 '-DrepositoryId=%s' % args.repository,
52 '-Durl=%s' % args.url,
54 else:
55 print("unknown action -a %s" % args.a, file=stderr)
56 exit(1)
58 for spec in args.s:
59 artifact, packaging_type, src = spec.split(':')
60 exe = cmd + [
61 '-DpomFile=%s' % path.join(root, '%s/pom.%s.xml' % (M[artifact], artifact)),
62 '-Dpackaging=%s' % packaging_type,
63 '-Dfile=%s' % src,
65 try:
66 if environ.get('VERBOSE'):
67 print(' '.join(exe), file=stderr)
68 check_output(exe)
69 except Exception as e:
70 print('%s command failed: %s' % (args.a, e), file=stderr)
71 exit(1)
73 with open(args.o, 'w') as fd:
74 if args.repository:
75 print('Repository: %s' % args.repository, file=fd)
76 if args.url:
77 print('URL: %s' % args.url, file=fd)
78 print('Version: %s' % args.v, file=fd)