@@ -18,7 +18,12 @@ import { getMavenConfig } from '../config'
1818import { extractArtifact , getPomCacheStats , normalizeScmUrl } from './extract'
1919import { isMavenFetchError , resolveVersionsList } from './metadata'
2020import { isPrerelease , parseRepoUrl } from './normalize'
21- import { resolveRegistryBaseUrl , resolveRegistryPageUrl } from './registry'
21+ import {
22+ MAVEN_CENTRAL_BASE_URL ,
23+ isAlternativeRegistry ,
24+ resolveRegistryBaseUrl ,
25+ resolveRegistryPageUrl ,
26+ } from './registry'
2227
2328const log = getServiceChildLogger ( 'maven' )
2429
@@ -115,10 +120,25 @@ async function processCriticalPackage(qx: QueryExecutor, pkg: PackageRow, forceF
115120 return { status : 'skipped' }
116121 }
117122
118- const baseUrl = resolveRegistryBaseUrl ( groupId )
123+ let baseUrl = resolveRegistryBaseUrl ( groupId )
119124
120125 // Phase 1: lightweight metadata fetch to get the current upstream version.
121- const metadata = await resolveVersionsList ( groupId , artifactId , baseUrl )
126+ let metadata = await resolveVersionsList ( groupId , artifactId , baseUrl )
127+
128+ // If the primary (non-Central) registry returned NOT_FOUND, try Maven Central as a
129+ // fallback. This handles artifacts that share a namespace with non-Central packages but
130+ // are themselves published on Central — e.g. com.google.firebase:firebase-admin is the
131+ // server-side Java SDK on Central, while most com.google.firebase artifacts are Android
132+ // SDKs on Google Maven.
133+ if ( isMavenFetchError ( metadata ) && metadata . kind === 'NOT_FOUND' && isAlternativeRegistry ( groupId ) ) {
134+ const centralUrl = process . env . MAVEN_FETCHER_BASE_URL ?? MAVEN_CENTRAL_BASE_URL
135+ const centralMetadata = await resolveVersionsList ( groupId , artifactId , centralUrl )
136+ if ( ! isMavenFetchError ( centralMetadata ) ) {
137+ log . info ( { groupId, artifactId } , 'Not found in primary registry — resolved via Maven Central fallback' )
138+ baseUrl = centralUrl
139+ metadata = centralMetadata
140+ }
141+ }
122142
123143 if ( isMavenFetchError ( metadata ) ) {
124144 if ( metadata . kind === 'NOT_FOUND' ) {
0 commit comments