This is an automated email from the ASF dual-hosted git repository. arm pushed a commit to branch maven_check_artifacts in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
commit 35cb9c98fcb4432f6d8df80ed32bbfdca256f905 Author: Alastair McFarlane <[email protected]> AuthorDate: Mon Jan 19 17:54:33 2026 +0000 Make Maven check use the CDN URLs instead of the search.maven api --- atr/models/sql.py | 5 ++-- atr/storage/writers/distributions.py | 46 ++++++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/atr/models/sql.py b/atr/models/sql.py index 444c134..3e71d2d 100644 --- a/atr/models/sql.py +++ b/atr/models/sql.py @@ -121,8 +121,9 @@ class DistributionPlatform(enum.Enum): MAVEN = DistributionPlatformValue( name="Maven Central", gh_slug="maven", - template_url="https://search.maven.org/solrsearch/select?q=g:{owner_namespace}+AND+a:{package}+AND+v:{version}&core=gav&rows=20&wt=json", - # Java ASF projects use staging URLs along the lines of + template_url="https://repo1.maven.org/maven2/{owner_namespace}/{package}/maven-metadata.xml", + # Below is the old template using the maven search API - but the index isn't updated quickly enough for us + # template_url="https://search.maven.org/solrsearch/select?q=g:{owner_namespace}+AND+a:{package}+AND+v:{version}&core=gav&rows=20&wt=json", template_staging_url="https://repository.apache.org:4443/repository/maven-staging/{owner_namespace}/{package}/maven-metadata.xml", # https://repository.apache.org/content/repositories/orgapachePROJECT-NNNN/ # There's no JSON, but each individual package has maven-metadata.xml diff --git a/atr/storage/writers/distributions.py b/atr/storage/writers/distributions.py index 4569b1c..d620592 100644 --- a/atr/storage/writers/distributions.py +++ b/atr/storage/writers/distributions.py @@ -197,8 +197,13 @@ class CommitteeMember(CommitteeParticipant): dd: distribution.Data, ) -> tuple[sql.Distribution, bool, distribution.Metadata]: template_url = await self.__template_url(dd, staging) - - if dd.platform == sql.DistributionPlatform.MAVEN and staging: + api_url = template_url.format( + owner_namespace=dd.owner_namespace, + package=dd.package, + version=dd.version, + ) + if dd.platform == sql.DistributionPlatform.MAVEN: + # We do this here because the CDNs break the namespace up into a / delimited URL owner = (dd.owner_namespace or "").replace(".", "/") api_url = template_url.format( owner_namespace=owner, @@ -207,11 +212,6 @@ class CommitteeMember(CommitteeParticipant): ) api_oc = await self.__json_from_maven_xml(api_url, dd.version) else: - api_url = template_url.format( - owner_namespace=dd.owner_namespace, - package=dd.package, - version=dd.version, - ) api_oc = await self.__json_from_distribution_platform(api_url, dd.platform, dd.version) match api_oc: case outcome.Result(result): @@ -347,6 +347,38 @@ class CommitteeMember(CommitteeParticipant): return outcome.Error(e) return outcome.Result(result) + async def __json_from_maven_cdn( + self, api_url: str, group_id: str, artifact_id: str, version: str + ) -> outcome.Outcome[basic.JSON]: + import datetime + + try: + async with aiohttp.ClientSession() as session: + async with session.get(api_url) as response: + response.raise_for_status() + + # Use current time as timestamp since we're just validating the package exists + timestamp_ms = int(datetime.datetime.now(datetime.UTC).timestamp() * 1000) + + # Convert to dict matching MavenResponse structure + result_dict = { + "response": { + "start": 0, + "docs": [ + { + "g": group_id, + "a": artifact_id, + "v": version, + "timestamp": timestamp_ms, + } + ], + } + } + result = basic.as_json(result_dict) + return outcome.Result(result) + except aiohttp.ClientError as e: + return outcome.Error(e) + async def __json_from_maven_xml(self, api_url: str, version: str) -> outcome.Outcome[basic.JSON]: import datetime import xml.etree.ElementTree as ET --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
