mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-09-17 10:40:12 +02:00
Merge branch 'master' into 'master'
Added support for gradle flavor specific dependencies in usual suspects check When you have flavor specific dependencies in your project, you specify them in the build.gradle file with a prefixed *compile* command: ``` compile 'normal dependency' myflavorCompile 'only for myflavor' ``` The usual suspects check just searches for some often used library names in the whole build.gradle file. I added another condition, so dependencies for not build flavors are not checked. See merge request !77
This commit is contained in:
commit
6c5bbb2431
@ -31,6 +31,15 @@ config = None
|
|||||||
options = None
|
options = None
|
||||||
|
|
||||||
|
|
||||||
|
def get_gradle_compile_commands(thisbuild):
|
||||||
|
compileCommands = ['compile', 'releaseCompile']
|
||||||
|
if thisbuild['gradle'] != ['yes']:
|
||||||
|
compileCommands += [flavor + 'Compile' for flavor in thisbuild['gradle']]
|
||||||
|
compileCommands += [flavor + 'ReleaseCompile' for flavor in thisbuild['gradle']]
|
||||||
|
|
||||||
|
return [re.compile(r'\s*' + c, re.IGNORECASE) for c in compileCommands]
|
||||||
|
|
||||||
|
|
||||||
# Scan the source code in the given directory (and all subdirectories)
|
# Scan the source code in the given directory (and all subdirectories)
|
||||||
# and return the number of fatal problems encountered
|
# and return the number of fatal problems encountered
|
||||||
def scan_source(build_dir, root_dir, thisbuild):
|
def scan_source(build_dir, root_dir, thisbuild):
|
||||||
@ -114,6 +123,11 @@ def scan_source(build_dir, root_dir, thisbuild):
|
|||||||
d = f.read(1024)
|
d = f.read(1024)
|
||||||
return bool(d.translate(None, textchars))
|
return bool(d.translate(None, textchars))
|
||||||
|
|
||||||
|
gradle_compile_commands = get_gradle_compile_commands(thisbuild)
|
||||||
|
|
||||||
|
def is_used_by_gradle(line):
|
||||||
|
return any(command.match(line) for command in gradle_compile_commands)
|
||||||
|
|
||||||
# Iterate through all files in the source code
|
# Iterate through all files in the source code
|
||||||
for r, d, f in os.walk(build_dir, topdown=True):
|
for r, d, f in os.walk(build_dir, topdown=True):
|
||||||
|
|
||||||
@ -157,8 +171,9 @@ def scan_source(build_dir, root_dir, thisbuild):
|
|||||||
continue
|
continue
|
||||||
for i, line in enumerate(file(fp)):
|
for i, line in enumerate(file(fp)):
|
||||||
i = i + 1
|
i = i + 1
|
||||||
for name in suspects_found(line):
|
if is_used_by_gradle(line):
|
||||||
count += handleproblem('usual supect \'%s\' at line %d' % (name, i), fd, fp)
|
for name in suspects_found(line):
|
||||||
|
count += handleproblem('usual supect \'%s\' at line %d' % (name, i), fd, fp)
|
||||||
|
|
||||||
elif ext in ['', 'bin', 'out', 'exe']:
|
elif ext in ['', 'bin', 'out', 'exe']:
|
||||||
if is_binary(fp):
|
if is_binary(fp):
|
||||||
|
Loading…
Reference in New Issue
Block a user