1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-15 03:20:10 +01:00

scanner: catalog: get catalog from parent dirs

When walking through the repo, there may be another settings.gradle in a
sub project with a different catalog. In the subdir the catalog of the
sub project shuold be used and in other subdir the catalog of the root
project should be used.
This commit is contained in:
linsui 2024-09-28 01:31:36 +08:00
parent 399ac608c7
commit 4c3dd9c76c
8 changed files with 71 additions and 3 deletions

View File

@ -742,7 +742,12 @@ include tests/signindex/testy.jar
include tests/signindex/unsigned.jar include tests/signindex/unsigned.jar
include tests/source-files/at.bitfire.davdroid/build.gradle include tests/source-files/at.bitfire.davdroid/build.gradle
include tests/source-files/catalog.test/app/build.gradle include tests/source-files/catalog.test/app/build.gradle
include tests/source-files/catalog.test/buildSrc/build.gradle.kts
include tests/source-files/catalog.test/buildSrc/settings.gradle.kts
include tests/source-files/catalog.test/buildSrc2/build.gradle.kts
include tests/source-files/catalog.test/buildSrc2/settings.gradle.kts
include tests/source-files/catalog.test/build.gradle.kts include tests/source-files/catalog.test/build.gradle.kts
include tests/source-files/catalog.test/core/build.gradle
include tests/source-files/catalog.test/libs.versions.toml include tests/source-files/catalog.test/libs.versions.toml
include tests/source-files/catalog.test/gradle/libs.versions.toml include tests/source-files/catalog.test/gradle/libs.versions.toml
include tests/source-files/catalog.test/settings.gradle.kts include tests/source-files/catalog.test/settings.gradle.kts

View File

@ -891,7 +891,7 @@ def scan_source(build_dir, build=metadata.Build(), json_per_build=None):
if m: if m:
return m return m
catalogs = {} all_catalogs = {}
# Iterate through all files in the source code # Iterate through all files in the source code
for root, dirs, files in os.walk(build_dir, topdown=True): for root, dirs, files in os.walk(build_dir, topdown=True):
# It's topdown, so checking the basename is enough # It's topdown, so checking the basename is enough
@ -900,7 +900,7 @@ def scan_source(build_dir, build=metadata.Build(), json_per_build=None):
dirs.remove(ignoredir) dirs.remove(ignoredir)
if "settings.gradle" in files or "settings.gradle.kts" in files: if "settings.gradle" in files or "settings.gradle.kts" in files:
catalogs = get_catalogs(root) all_catalogs[str(root)] = get_catalogs(root)
for curfile in files: for curfile in files:
if curfile in ['.DS_Store']: if curfile in ['.DS_Store']:
@ -983,6 +983,13 @@ def scan_source(build_dir, build=metadata.Build(), json_per_build=None):
break break
elif curfile.endswith('.gradle') or curfile.endswith('.gradle.kts'): elif curfile.endswith('.gradle') or curfile.endswith('.gradle.kts'):
catalog_path = str(build_dir)
# Find the longest path of dir that the curfile is in
for p in all_catalogs:
if os.path.commonpath([root, p]) == p:
catalog_path = p
catalogs = all_catalogs.get(catalog_path, {})
if not os.path.isfile(filepath): if not os.path.isfile(filepath):
continue continue
with open(filepath, 'r', errors='replace') as f: with open(filepath, 'r', errors='replace') as f:

View File

@ -74,7 +74,7 @@ class ScannerTest(unittest.TestCase):
'se.manyver': 3, 'se.manyver': 3,
'lockfile.test': 1, 'lockfile.test': 1,
'com.lolo.io.onelist': 6, 'com.lolo.io.onelist': 6,
'catalog.test': 10, 'catalog.test': 22,
} }
for d in glob.glob(os.path.join(source_files, '*')): for d in glob.glob(os.path.join(source_files, '*')):
build = fdroidserver.metadata.Build() build = fdroidserver.metadata.Build()

View File

@ -0,0 +1,5 @@
plugins {
alias(libs.plugins.google.services)
alias(libs.plugins.firebase.crashlytics)
alias(projectLibs.plugins.firebase.crashlytics)
}

View File

@ -0,0 +1,22 @@
pluginManagement {
repositories {
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
rootProject.name = "buildSrc"
rootProject.buildFileName = "buildSrc.gradle.kts"

View File

@ -0,0 +1,5 @@
plugins {
alias(libs.plugins.google.services)
alias(libs.plugins.firebase.crashlytics)
alias(projectLibs.plugins.firebase.crashlytics)
}

View File

@ -0,0 +1,22 @@
pluginManagement {
repositories {
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
rootProject.name = "buildSrc"
rootProject.buildFileName = "buildSrc.gradle.kts"

View File

@ -0,0 +1,2 @@
implementation libs.bundles.firebase
implementation libs.play.service.ads