mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-16 11:50:10 +01:00
Merge branch 'catalog' into 'master'
scanner: catalog: dependency declaration can be declared as a simple string See merge request fdroid/fdroidserver!1536
This commit is contained in:
commit
66018d3f09
@ -33,6 +33,7 @@ from datetime import datetime, timedelta
|
||||
from enum import IntEnum
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
from typing import Union
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
import tomllib
|
||||
@ -114,7 +115,7 @@ class GradleVersionCatalog:
|
||||
"""
|
||||
return alias.replace("-", ".").replace("_", ".")
|
||||
|
||||
def get_version(self, version: dict) -> str:
|
||||
def get_version(self, version: Union[dict, str]) -> str:
|
||||
if isinstance(version, str):
|
||||
return version
|
||||
ref = version.get("ref")
|
||||
@ -126,8 +127,10 @@ class GradleVersionCatalog:
|
||||
or version.get("strictly", "")
|
||||
)
|
||||
|
||||
def library_to_coordinate(self, library: dict) -> str:
|
||||
def library_to_coordinate(self, library: Union[dict, str]) -> str:
|
||||
"""Generate the Gradle dependency coordinate from catalog."""
|
||||
if isinstance(library, str):
|
||||
return library
|
||||
module = library.get("module")
|
||||
if not module:
|
||||
group = library.get("group")
|
||||
@ -143,8 +146,10 @@ class GradleVersionCatalog:
|
||||
else:
|
||||
return module
|
||||
|
||||
def plugin_to_coordinate(self, plugin: dict) -> str:
|
||||
def plugin_to_coordinate(self, plugin: Union[dict, str]) -> str:
|
||||
"""Generate the Gradle plugin coordinate from catalog."""
|
||||
if isinstance(plugin, str):
|
||||
return plugin
|
||||
id = plugin.get("id")
|
||||
if not id:
|
||||
return ""
|
||||
@ -155,7 +160,7 @@ class GradleVersionCatalog:
|
||||
else:
|
||||
return id
|
||||
|
||||
def bundle_to_coordinates(self, bundle) -> list[str]:
|
||||
def bundle_to_coordinates(self, bundle: list[str]) -> list[str]:
|
||||
"""Generate the Gradle dependency bundle coordinate from catalog."""
|
||||
coordinates = []
|
||||
for alias in bundle:
|
||||
|
@ -143,6 +143,7 @@ class ScannerTest(unittest.TestCase):
|
||||
'firebase.crash': ['com.google.firebase:firebase-crash:1.1.1'],
|
||||
'firebase.core': ['com.google.firebase:firebase-core:2.2.2'],
|
||||
'play.service.ads': ['com.google.android.gms:play-services-ads:1.2.1'],
|
||||
'jacoco': ['org.jacoco:org.jacoco.core:0.8.7'],
|
||||
'plugins.google.services': ['com.google.gms.google-services:1.2.1'],
|
||||
'plugins.firebase.crashlytics': ['com.google.firebase.crashlytics:1.1.1'],
|
||||
'bundles.firebase': [
|
||||
|
@ -6,6 +6,7 @@ gms = "1.2.1"
|
||||
firebase-crash = { module = "com.google.firebase:firebase-crash", version.ref = "firebase" }
|
||||
firebase_core = { module = "com.google.firebase:firebase-core", version = "2.2.2" }
|
||||
"play.service.ads" = { module = "com.google.android.gms:play-services-ads", version.ref = "gms"}
|
||||
jacoco = "org.jacoco:org.jacoco.core:0.8.7"
|
||||
|
||||
[plugins]
|
||||
google-services = { id = "com.google.gms.google-services", version.ref = "gms" }
|
||||
|
Loading…
Reference in New Issue
Block a user