mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-04 22:40:12 +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:([^\.]+\.[^\.]+).*'.*")
|
version_regex = re.compile(r".*'com\.android\.tools\.build:gradle:([^\.]+\.[^\.]+).*'.*")
|
||||||
gradlepluginver = None
|
gradlepluginver = None
|
||||||
|
|
||||||
with open(os.path.join(root_dir, 'build.gradle')) as f:
|
gradle_files = [os.path.join(root_dir, 'build.gradle')]
|
||||||
for line in f:
|
|
||||||
match = version_regex.match(line)
|
# Parent dir build.gradle
|
||||||
if match:
|
parent_dir = os.path.normpath(os.path.join(root_dir, '..'))
|
||||||
gradlepluginver = match.group(1)
|
if parent_dir.startswith(build_dir):
|
||||||
break
|
gradle_files.append(os.path.join(parent_dir, 'build.gradle'))
|
||||||
if '@' in build['gradle'] and not gradlepluginver:
|
|
||||||
gradle_dir = os.path.join(root_dir, build['gradle'].split('@', 1)[1])
|
# Gradle execution dir build.gradle
|
||||||
gradle_dir = os.path.normpath(gradle_dir)
|
if '@' in build['gradle']:
|
||||||
with open(os.path.join(gradle_dir, 'build.gradle')) as f:
|
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 not os.path.isfile(path):
|
||||||
|
continue
|
||||||
|
with open(path) as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
match = version_regex.match(line)
|
match = version_regex.match(line)
|
||||||
if match:
|
if match:
|
||||||
gradlepluginver = match.group(1)
|
gradlepluginver = match.group(1)
|
||||||
break
|
break
|
||||||
|
|
||||||
build['gradlepluginver'] = LooseVersion(gradlepluginver)
|
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']:
|
if build['target']:
|
||||||
n = build["target"].split('-')[1]
|
n = build["target"].split('-')[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user