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