Skip to content

Commit d4fc3a8

Browse files
author
Mateusz (Mati) Kepa
committed
Update gradle with the configurable plugin support
1 parent f2a5b70 commit d4fc3a8

13 files changed

Lines changed: 452 additions & 30 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
fetch-depth: 0
2020
persist-credentials: false
2121

22-
- uses: sigstore/cosign-installer@cad07c2e89fa2edd6e2d7bab4c1aa38e53f76003 # v4.1.1
22+
- uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
2323

2424
- name: Set up Go
2525
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,18 @@ Add to your `~/.m2/settings.xml`:
210210
</settings>
211211
```
212212

213+
The `/maven/` endpoint uses Maven Central as primary upstream and falls back to the Gradle Plugin Portal for Gradle plugin marker metadata and related artifacts when the primary upstream returns not found.
214+
215+
For Gradle plugin resolution via the same proxy endpoint:
216+
217+
```kotlin
218+
pluginManagement {
219+
repositories {
220+
maven(url = "http://localhost:8080/maven/")
221+
}
222+
}
223+
```
224+
213225
### Gradle HTTP Build Cache
214226

215227
Configure in `settings.gradle(.kts)`:
@@ -219,10 +231,10 @@ buildCache {
219231
local {
220232
enabled = false
221233
}
222-
remote<HttpBuildCache> {
223-
url = uri("http://localhost:8080/gradle/")
234+
remote<HttpBuildCache> {
235+
url = uri("http://localhost:8080/gradle/")
224236
push = true
225-
}
237+
}
226238
}
227239
```
228240

@@ -386,6 +398,7 @@ sudo dnf update
386398
## Configuration
387399

388400
The proxy can be configured via:
401+
389402
1. Command line flags (highest priority)
390403
2. Environment variables
391404
3. Configuration file (YAML or JSON)
@@ -958,6 +971,7 @@ The proxy will recreate the database on next start.
958971
## Building from Source
959972

960973
Requirements:
974+
961975
- Go 1.25 or later
962976

963977
```bash

cmd/proxy/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
// PROXY_DATABASE_URL - PostgreSQL connection URL
7373
// PROXY_LOG_LEVEL - Log level
7474
// PROXY_LOG_FORMAT - Log format
75+
// PROXY_UPSTREAM_MAVEN - Maven repository upstream URL
76+
// PROXY_UPSTREAM_GRADLE_PLUGIN_PORTAL - Gradle Plugin Portal upstream URL
7577
// PROXY_GRADLE_BUILD_CACHE_READ_ONLY - Disable Gradle PUT uploads
7678
// PROXY_GRADLE_BUILD_CACHE_MAX_UPLOAD_SIZE - Max Gradle PUT request body size
7779
// PROXY_GRADLE_BUILD_CACHE_MAX_AGE - Gradle cache max age eviction
@@ -198,6 +200,8 @@ func runServe() {
198200
fmt.Fprintf(os.Stderr, " PROXY_DATABASE_URL PostgreSQL connection URL\n")
199201
fmt.Fprintf(os.Stderr, " PROXY_LOG_LEVEL Log level\n")
200202
fmt.Fprintf(os.Stderr, " PROXY_LOG_FORMAT Log format\n")
203+
fmt.Fprintf(os.Stderr, " PROXY_UPSTREAM_MAVEN Maven repository upstream URL\n")
204+
fmt.Fprintf(os.Stderr, " PROXY_UPSTREAM_GRADLE_PLUGIN_PORTAL Gradle Plugin Portal upstream URL\n")
201205
fmt.Fprintf(os.Stderr, " PROXY_GRADLE_BUILD_CACHE_READ_ONLY Disable Gradle PUT uploads\n")
202206
fmt.Fprintf(os.Stderr, " PROXY_GRADLE_BUILD_CACHE_MAX_UPLOAD_SIZE Max Gradle PUT request body size\n")
203207
fmt.Fprintf(os.Stderr, " PROXY_GRADLE_BUILD_CACHE_MAX_AGE Gradle cache max age eviction\n")

config.example.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ upstream:
7171
# npm registry URL
7272
npm: "https://registry.npmjs.org"
7373

74+
# Maven repository URL (used by /maven endpoint)
75+
maven: "https://repo1.maven.org/maven2"
76+
77+
# Gradle Plugin Portal Maven URL (fallback for plugin marker artifacts)
78+
gradle_plugin_portal: "https://plugins.gradle.org/m2"
79+
7480
# Cargo sparse index URL
7581
cargo: "https://index.crates.io"
7682

docs/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ Override default upstream registry URLs:
114114
```yaml
115115
upstream:
116116
npm: "https://registry.npmjs.org"
117+
maven: "https://repo1.maven.org/maven2"
118+
gradle_plugin_portal: "https://plugins.gradle.org/m2"
117119
cargo: "https://index.crates.io"
118120
cargo_download: "https://static.crates.io/crates"
119121
```

internal/config/config.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@ type UpstreamConfig struct {
210210
// Default: https://registry.npmjs.org
211211
NPM string `json:"npm" yaml:"npm"`
212212

213+
// Maven is the upstream Maven repository URL.
214+
// Default: https://repo1.maven.org/maven2
215+
Maven string `json:"maven" yaml:"maven"`
216+
217+
// GradlePluginPortal is the upstream Gradle Plugin Portal Maven URL.
218+
// Used to resolve Gradle plugin marker artifacts.
219+
// Default: https://plugins.gradle.org/m2
220+
GradlePluginPortal string `json:"gradle_plugin_portal" yaml:"gradle_plugin_portal"`
221+
213222
// Cargo is the upstream cargo index URL.
214223
// Default: https://index.crates.io
215224
Cargo string `json:"cargo" yaml:"cargo"`
@@ -287,9 +296,11 @@ func Default() *Config {
287296
Format: "text",
288297
},
289298
Upstream: UpstreamConfig{
290-
NPM: "https://registry.npmjs.org",
291-
Cargo: "https://index.crates.io",
292-
CargoDownload: "https://static.crates.io/crates",
299+
NPM: "https://registry.npmjs.org",
300+
Maven: "https://repo1.maven.org/maven2",
301+
GradlePluginPortal: "https://plugins.gradle.org/m2",
302+
Cargo: "https://index.crates.io",
303+
CargoDownload: "https://static.crates.io/crates",
293304
},
294305
Gradle: GradleConfig{
295306
BuildCache: GradleBuildCacheConfig{
@@ -383,6 +394,12 @@ func (c *Config) LoadFromEnv() {
383394
if v := os.Getenv("PROXY_LOG_FORMAT"); v != "" {
384395
c.Log.Format = v
385396
}
397+
if v := os.Getenv("PROXY_UPSTREAM_MAVEN"); v != "" {
398+
c.Upstream.Maven = v
399+
}
400+
if v := os.Getenv("PROXY_UPSTREAM_GRADLE_PLUGIN_PORTAL"); v != "" {
401+
c.Upstream.GradlePluginPortal = v
402+
}
386403
if v := os.Getenv("PROXY_COOLDOWN_DEFAULT"); v != "" {
387404
c.Cooldown.Default = v
388405
}

internal/config/config_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ func TestDefault(t *testing.T) {
3131
if cfg.Gradle.BuildCache.MaxAge != "168h" {
3232
t.Errorf("Gradle.BuildCache.MaxAge = %q, want %q", cfg.Gradle.BuildCache.MaxAge, "168h")
3333
}
34+
if cfg.Upstream.Maven != "https://repo1.maven.org/maven2" {
35+
t.Errorf("Upstream.Maven = %q, want %q", cfg.Upstream.Maven, "https://repo1.maven.org/maven2")
36+
}
37+
if cfg.Upstream.GradlePluginPortal != "https://plugins.gradle.org/m2" {
38+
t.Errorf("Upstream.GradlePluginPortal = %q, want %q", cfg.Upstream.GradlePluginPortal, "https://plugins.gradle.org/m2")
39+
}
3440
}
3541

3642
func TestValidate(t *testing.T) {
@@ -264,6 +270,8 @@ func TestLoadFromEnv(t *testing.T) {
264270
t.Setenv("PROXY_BASE_URL", "https://env.example.com")
265271
t.Setenv("PROXY_STORAGE_PATH", "/env/cache")
266272
t.Setenv("PROXY_LOG_LEVEL", testLevelDebug)
273+
t.Setenv("PROXY_UPSTREAM_MAVEN", "https://maven.example.com/repository/maven-public")
274+
t.Setenv("PROXY_UPSTREAM_GRADLE_PLUGIN_PORTAL", "https://plugins.example.com/m2")
267275
t.Setenv("PROXY_GRADLE_BUILD_CACHE_READ_ONLY", "true")
268276
t.Setenv("PROXY_GRADLE_BUILD_CACHE_MAX_UPLOAD_SIZE", "32MB")
269277
t.Setenv("PROXY_GRADLE_BUILD_CACHE_MAX_AGE", "12h")
@@ -284,6 +292,12 @@ func TestLoadFromEnv(t *testing.T) {
284292
if cfg.Log.Level != testLevelDebug {
285293
t.Errorf("Log.Level = %q, want %q", cfg.Log.Level, testLevelDebug)
286294
}
295+
if cfg.Upstream.Maven != "https://maven.example.com/repository/maven-public" {
296+
t.Errorf("Upstream.Maven = %q, want %q", cfg.Upstream.Maven, "https://maven.example.com/repository/maven-public")
297+
}
298+
if cfg.Upstream.GradlePluginPortal != "https://plugins.example.com/m2" {
299+
t.Errorf("Upstream.GradlePluginPortal = %q, want %q", cfg.Upstream.GradlePluginPortal, "https://plugins.example.com/m2")
300+
}
287301
if !cfg.Gradle.BuildCache.ReadOnly {
288302
t.Error("Gradle.BuildCache.ReadOnly = false, want true")
289303
}

0 commit comments

Comments
 (0)