Branch libreoffice-5-0-4
[LibreOffice.git] / bin / mvn.py
blobd5a1c9a0d16569cfde30fc6e011dcf9889732d31
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
11 from sys import stderr
12 try:
13 from subprocess import check_output
14 except ImportError:
15 from subprocess import Popen, PIPE
16 def check_output(*cmd):
17 return Popen(*cmd, stdout=PIPE).communicate()[0]
18 opts = OptionParser()
19 opts.add_option('--repository', help='maven repository id')
20 opts.add_option('--url', help='maven repository url')
21 opts.add_option('-a', help='action (valid actions are: install,deploy)')
22 opts.add_option('-v', help='libreoffice version')
23 opts.add_option('-s', action='append', help='triplet of artifactId:type:path')
25 args, ctx = opts.parse_args()
26 if not args.v:
27 print('version is empty', file=stderr)
28 exit(1)
30 common = [
31 '-DgroupId=org.libreoffice',
32 '-Dversion=%s' % args.v,
35 self = path.dirname(path.abspath(__file__))
36 mvn = ['mvn', '--file', path.join(self, 'fake_pom.xml')]
38 if 'install' == args.a:
39 cmd = mvn + ['install:install-file'] + common
40 elif 'deploy' == args.a:
41 cmd = mvn + [
42 'deploy:deploy-file',
43 '-DrepositoryId=%s' % args.repository,
44 '-Durl=%s' % args.url,
45 ] + common
46 else:
47 print("unknown action -a %s" % args.a, file=stderr)
48 exit(1)
50 for spec in args.s:
51 artifact, packaging_type, src = spec.split(':')
52 try:
53 check_output(cmd + [
54 '-DartifactId=%s' % artifact,
55 '-Dpackaging=%s' % packaging_type,
56 '-Dfile=%s' % src,
58 except Exception as e:
59 print('%s command failed: %s' % (args.a, e), file=stderr)
60 exit(1)