Skip to content

Commit 29d6676

Browse files
committed
feat: add jit registry
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent 28d70de commit 29d6676

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

services/apps/packages_worker/src/maven/__tests__/registry.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,22 @@ describe('resolveRegistryBaseUrl', () => {
148148
'https://repo.jenkins-ci.org/public',
149149
)
150150
})
151+
152+
it('returns JitPack for io.github namespace', () => {
153+
expect(resolveRegistryBaseUrl('io.github.resilience4j')).toBe('https://jitpack.io')
154+
})
155+
156+
it('returns JitPack for bare io.github (exact match)', () => {
157+
expect(resolveRegistryBaseUrl('io.github')).toBe('https://jitpack.io')
158+
})
159+
160+
it('returns JitPack for com.github namespace', () => {
161+
expect(resolveRegistryBaseUrl('com.github.ben-manes')).toBe('https://jitpack.io')
162+
})
163+
164+
it('does not match io.githubfoo — prefix boundary must end at a dot', () => {
165+
expect(resolveRegistryBaseUrl('io.githubfoo')).toBe(MAVEN_CENTRAL_BASE_URL)
166+
})
151167
})
152168

153169
describe('resolveRegistryPageUrl', () => {
@@ -174,6 +190,22 @@ describe('resolveRegistryPageUrl', () => {
174190
'https://central.sonatype.com/artifact/org.apache.commons/commons-lang3',
175191
)
176192
})
193+
194+
it('returns JitPack browse URL for io.github', () => {
195+
expect(resolveRegistryPageUrl('io.github.resilience4j', 'resilience4j-core')).toBe(
196+
'https://jitpack.io/#resilience4j/resilience4j-core',
197+
)
198+
})
199+
200+
it('returns JitPack browse URL for com.github', () => {
201+
expect(resolveRegistryPageUrl('com.github.ben-manes', 'caffeine')).toBe(
202+
'https://jitpack.io/#ben-manes/caffeine',
203+
)
204+
})
205+
206+
it('returns JitPack browse URL for bare io.github prefix without leaking the prefix into the path', () => {
207+
expect(resolveRegistryPageUrl('io.github', 'some-lib')).toBe('https://jitpack.io/#/some-lib')
208+
})
177209
})
178210

179211
describe('resolveRegistryPageUrlFromBase', () => {

services/apps/packages_worker/src/maven/registry.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ const ALTERNATIVE_REGISTRIES: RegistryEntry[] = [
9999
baseUrl: 'https://plugins.gradle.org/m2',
100100
pageUrl: (g, a) => `https://plugins.gradle.org/m2/${g.replace(/\./g, '/')}/${a}/`,
101101
},
102+
// JitPack builds and serves artifacts directly from GitHub/GitLab/Bitbucket source repos.
103+
// The io.github.<username> and com.github.<username> groupId conventions are JitPack-specific
104+
// and will never resolve on Maven Central.
105+
{
106+
prefix: 'io.github',
107+
baseUrl: 'https://jitpack.io',
108+
pageUrl: (g, a) =>
109+
`https://jitpack.io/#${g.startsWith('io.github.') ? g.slice('io.github.'.length) : ''}/${a}`,
110+
},
111+
{
112+
prefix: 'com.github',
113+
baseUrl: 'https://jitpack.io',
114+
pageUrl: (g, a) =>
115+
`https://jitpack.io/#${g.startsWith('com.github.') ? g.slice('com.github.'.length) : ''}/${a}`,
116+
},
102117
{
103118
prefix: 'com.cloudbees.plugins',
104119
baseUrl: 'https://repo.jenkins-ci.org/public',

0 commit comments

Comments
 (0)