|
|
|
@@ -1,9 +1,9 @@ |
|
|
|
import asyncio |
|
|
|
import logging |
|
|
|
from typing import Optional, Iterable |
|
|
|
import asyncio |
|
|
|
from aiohttp import ClientSession |
|
|
|
from typing import Optional, Iterable |
|
|
|
|
|
|
|
from pom import PropertyMissing, PackagePOM, Properties |
|
|
|
from pom import PackagePOM |
|
|
|
|
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
@@ -12,52 +12,6 @@ class TooManyRequestsException(Exception): |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
async def get_effective_packages(package: str, mirrors: Iterable[str]) -> list[str]: |
|
|
|
""" |
|
|
|
Get a list of packages that is required for Gradle to fetch this package. |
|
|
|
|
|
|
|
For most packages, this just returns the package name. However, for BOMs, the full list of packages included |
|
|
|
in the BOM is returned (including the BOM itself). This is because Gradle doesn't fetch all packages of a BOM. |
|
|
|
|
|
|
|
This requires querying Maven and parsing the POM to check if the package is a BOM. |
|
|
|
""" |
|
|
|
packages = [] |
|
|
|
|
|
|
|
if pom := await fetch_pom(package, mirrors): |
|
|
|
packages.append(package) |
|
|
|
|
|
|
|
if pom.is_bom: |
|
|
|
try: |
|
|
|
packages.extend(pom.dependency_management) |
|
|
|
except PropertyMissing as e1: |
|
|
|
parent_props = await get_parent_props(pom.parent, mirrors) |
|
|
|
if parent_props: |
|
|
|
pom.set_properties(parent_props) |
|
|
|
try: |
|
|
|
packages.extend(pom.dependency_management) |
|
|
|
except PropertyMissing as e2: |
|
|
|
logger.warning( |
|
|
|
f'{package}: Could not resolve property {e2.prop}, which is necessary for resolving dependencies' |
|
|
|
) |
|
|
|
else: |
|
|
|
logger.warning( |
|
|
|
f'{package}: Could not resolve property {e1.prop}, and could not get properties from parent' |
|
|
|
) |
|
|
|
|
|
|
|
return packages |
|
|
|
|
|
|
|
|
|
|
|
async def get_parent_props(parent: Optional[str], mirrors: Iterable[str]) -> Properties: |
|
|
|
if parent: |
|
|
|
if pom := await fetch_pom(parent, mirrors): |
|
|
|
pom.set_properties(await get_parent_props(pom.parent, mirrors)) |
|
|
|
return pom.properties |
|
|
|
else: |
|
|
|
logger.warning(f'{parent}: Error fetching pom') |
|
|
|
|
|
|
|
return {} |
|
|
|
|
|
|
|
|
|
|
|
async def fetch_pom(package: str, mirrors: Iterable[str]) -> Optional[PackagePOM]: |
|
|
|
pom = await fetch_maven_file(package, 'pom', mirrors) |
|
|
|
return PackagePOM(package, pom) if pom else None |