blob: a994bd85393aa800303d545c7e8b068c366f8e6e [file] [log] [blame]
David Pursehouse9a13f852014-03-26 14:45:02 -07001#!/usr/bin/python
2# Copyright (C) 2014 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16from __future__ import print_function
17from optparse import OptionParser
18import os.path
19import re
20import sys
21
22parser = OptionParser()
23opts, args = parser.parse_args()
24
25if not len(args):
26 parser.error('not enough arguments')
27elif len(args) > 1:
28 parser.error('too many arguments')
29
30new_version = args[0]
31pattern = re.compile(r'(\s*)<version>[-.\w]+</version>')
32
Edwin Kempinc7ddc2c2014-05-21 11:12:35 +020033for project in ['gerrit-extension-api', 'gerrit-plugin-api',
34 'gerrit-plugin-archetype', 'gerrit-plugin-gwt-archetype',
David Ostrovsky520f29c2014-05-22 21:44:29 +020035 'gerrit-plugin-gwtui', 'gerrit-plugin-js-archetype',
36 'gerrit-war']:
David Pursehouse9a13f852014-03-26 14:45:02 -070037 pom = os.path.join(project, 'pom.xml')
38 try:
39 outxml = ""
40 found = False
41 for line in open(pom, "r"):
42 m = pattern.match(line)
43 if m and not found:
44 outxml += "%s<version>%s</version>\n" % (m.group(1), new_version)
45 found = True
46 else:
47 outxml += line
48 with open(pom, "w") as outfile:
49 outfile.write(outxml)
50 except IOError as err:
51 print('error updating %s: %s' % (pom, err), file=sys.stderr)