mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-04 14:30:11 +01:00
Better support for gradle plugin versions
This commit is contained in:
parent
69da721f02
commit
04b61302dc
@ -1136,23 +1136,37 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
||||
version_regex = re.compile(r".*'com\.android\.tools\.build:gradle:([^\.]+\.[^\.]+).*'.*")
|
||||
gradlepluginver = None
|
||||
|
||||
with open(os.path.join(root_dir, 'build.gradle')) as f:
|
||||
for line in f:
|
||||
match = version_regex.match(line)
|
||||
if match:
|
||||
gradlepluginver = match.group(1)
|
||||
gradle_files = [os.path.join(root_dir, 'build.gradle')]
|
||||
|
||||
# Parent dir build.gradle
|
||||
parent_dir = os.path.normpath(os.path.join(root_dir, '..'))
|
||||
if parent_dir.startswith(build_dir):
|
||||
gradle_files.append(os.path.join(parent_dir, 'build.gradle'))
|
||||
|
||||
# Gradle execution dir build.gradle
|
||||
if '@' in build['gradle']:
|
||||
gradle_file = os.path.join(root_dir, build['gradle'].split('@', 1)[1], 'build.gradle')
|
||||
gradle_file = os.path.normpath(gradle_file)
|
||||
if gradle_file not in gradle_files:
|
||||
gradle_files.append(gradle_file)
|
||||
|
||||
for path in gradle_files:
|
||||
if gradlepluginver:
|
||||
break
|
||||
if '@' in build['gradle'] and not gradlepluginver:
|
||||
gradle_dir = os.path.join(root_dir, build['gradle'].split('@', 1)[1])
|
||||
gradle_dir = os.path.normpath(gradle_dir)
|
||||
with open(os.path.join(gradle_dir, 'build.gradle')) as f:
|
||||
if not os.path.isfile(path):
|
||||
continue
|
||||
with open(path) as f:
|
||||
for line in f:
|
||||
match = version_regex.match(line)
|
||||
if match:
|
||||
gradlepluginver = match.group(1)
|
||||
break
|
||||
|
||||
if gradlepluginver:
|
||||
build['gradlepluginver'] = LooseVersion(gradlepluginver)
|
||||
else:
|
||||
logging.warn("Could not fetch the gradle plugin version, defaulting to 0.11")
|
||||
build['gradlepluginver'] = LooseVersion('0.11')
|
||||
|
||||
if build['target']:
|
||||
n = build["target"].split('-')[1]
|
||||
|
Loading…
Reference in New Issue
Block a user