mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
gradle file: use flavour specific versionCode/versionName, fall back to parsing line by line
This commit is contained in:
parent
5607ccdc41
commit
f8492f05a8
1 changed files with 48 additions and 19 deletions
|
@ -1299,7 +1299,36 @@ def parse_androidmanifests(paths, app):
|
|||
vercode = None
|
||||
package = None
|
||||
|
||||
flavour = app.builds[-1].gradle[-1]
|
||||
|
||||
if has_extension(path, 'gradle'):
|
||||
# first try to get version name and code from correct flavour
|
||||
with open(path, 'r') as f:
|
||||
buildfile = f.read()
|
||||
|
||||
regex_string = r"" + flavour + ".*?}"
|
||||
search = re.compile(regex_string, re.DOTALL)
|
||||
result = search.search(buildfile)
|
||||
|
||||
if result is not None:
|
||||
resultgroup = result.group()
|
||||
|
||||
if not package:
|
||||
matches = psearch_g(resultgroup)
|
||||
if matches:
|
||||
s = matches.group(2)
|
||||
if app_matches_packagename(app, s):
|
||||
package = s
|
||||
if not version:
|
||||
matches = vnsearch_g(resultgroup)
|
||||
if matches:
|
||||
version = matches.group(2)
|
||||
if not vercode:
|
||||
matches = vcsearch_g(resultgroup)
|
||||
if matches:
|
||||
vercode = matches.group(1)
|
||||
else:
|
||||
# fall back to parse file line by line
|
||||
with open(path, 'r') as f:
|
||||
for line in f:
|
||||
if gradle_comment.match(line):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue