Skip to content

Only match the beginning of the line in is_used_by_gradle()

Pierre Rudloff requested to merge Rudloff/fdroidserver:flavor into master

get_gradle_compile_commands() generates an overly broad regexp that will match non-free libraries in any flavor (instead of just the flavor we are using).

This can be seen on fdroiddata!8505 (merged).

get_gradle_compile_commands() will generate the following regexps:

[
    re.compile('\\s*compile', re.IGNORECASE),
    re.compile('\\s*provided', re.IGNORECASE),
    re.compile('\\s*apk', re.IGNORECASE),
    re.compile('\\s*implementation', re.IGNORECASE),
    re.compile('\\s*api', re.IGNORECASE),
    re.compile('\\s*compileOnly', re.IGNORECASE),
    re.compile('\\s*runtimeOnly', re.IGNORECASE),
    re.compile('\\s*releasecompile', re.IGNORECASE),
    re.compile('\\s*releaseprovided', re.IGNORECASE),
    re.compile('\\s*releaseapk', re.IGNORECASE),
    re.compile('\\s*releaseimplementation', re.IGNORECASE),
    re.compile('\\s*releaseapi', re.IGNORECASE),
    re.compile('\\s*releasecompileOnly', re.IGNORECASE),
    re.compile('\\s*releaseruntimeOnly', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorcompile', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorprovided', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorapk', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorimplementation', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorapi', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorcompileOnly', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorruntimeOnly', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorreleasecompile', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorreleaseprovided', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorreleaseapk', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorreleaseimplementation', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorreleaseapi', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorreleasecompileOnly', re.IGNORECASE),
    re.compile('\\s*fdroidFlavorreleaseruntimeOnly', re.IGNORECASE)
]

\s*implementation will match any line containing implementation, so it will match this line:

    apkFlavorImplementation 'com.google.firebase:firebase-appindexing:19.2.0'

This MR changes the regexps to only match the beginning of a line.

Merge request reports