prefer build.gradle with Android Plugin as source of package/version/code

These days, the location that overrides all the others is in the android{}
block of the build.gradle file that loads the com.android.application
plugin.  So this should be the preferred place to read these values.

test files GPL licensed: https://github.com/Integreight/1Sheeld-Android-App
This commit is contained in:
Hans-Christoph Steiner 2020-02-03 21:13:26 +01:00
parent d9722f4453
commit 83ffeb855f
17 changed files with 598 additions and 2 deletions

View file

@ -41,7 +41,6 @@ from .exception import FDroidException
SETTINGS_GRADLE = re.compile(r'settings\.gradle(?:\.kts)?')
GRADLE_SUBPROJECT = re.compile(r'''['"]:([^'"]+)['"]''')
ANDROID_PLUGIN = re.compile(r'''\s*(:?apply plugin:|id)\(?\s*['"](android|com\.android\.application)['"]\s*\)?''')
# Get the repo type and address from the given web page. The page is scanned
@ -197,7 +196,7 @@ def get_gradle_subdir(build_dir, paths):
line = fp.readline()
if not line:
break
if ANDROID_PLUGIN.match(line):
if common.ANDROID_PLUGIN_REGEX.match(line):
return os.path.relpath(os.path.dirname(f), build_dir)
if first_gradle_dir and first_gradle_dir != '.':
return first_gradle_dir