Skip to content

Commit 0b88326

Browse files
committed
docs: Document custom repositories for dependency delivery
1 parent d38f1df commit 0b88326

1 file changed

Lines changed: 37 additions & 4 deletions

File tree

README.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
*A Gradle plugin that streamlines using KPaper in your PaperMC plugins*
1111

12-
[🚀 Quick Start](#-quick-start)[✨ Features](#-key-features)[🧩 How-It-Works](#-how-it-works)[🛠 configuration](#-configuration)[🤝 Contributing](#-contributing)
12+
[🚀 Quick Start](#-quick-start)[✨ Features](#-key-features)[🧩 How-It-Works](#-how-it-works)[🛠 configuration](#-configuration)[🌐 Custom Repos](#-custom-repositories-for-dependency-delivery)[🤝 Contributing](#-contributing)
1313

1414
</div>
1515

@@ -26,6 +26,7 @@ KPaperGradle automates integrating [KPaper](https://github.com/ModLabsCC/KPaper)
2626
- **🧩 Paper integration** — Patches `paper-plugin.yml` to include `loader` and `bootstrapper` if missing
2727
- **📚 Convention‑based registration** — Auto‑registers commands; discovers listeners (manual call required)
2828
- **🚚 Deliver extra libs** — Simple `deliver("group:artifact:version")` DSL for runtime libraries
29+
- **🌐 Custom repos for delivery** — Add Maven repositories used by the runtime dependency loader via `repository(...)` DSL
2930

3031
## 🚀 Quick Start
3132

@@ -68,6 +69,12 @@ kpaper {
6869
deliver(
6970
"com.github.ben-manes.caffeine:caffeine:3.1.8"
7071
)
72+
73+
// Optional: Repositories used by the runtime dependency loader
74+
// Either with generated id from host:
75+
repository("https://repo1.maven.org/maven2/")
76+
// Or explicitly provide an id and url:
77+
repository("papermc", "https://repo.papermc.io/repository/maven-public/")
7178
}
7279
```
7380

@@ -149,20 +156,46 @@ KPaperGradle wires a few build steps into your project:
149156
- `RegisterManager` — scans your `registrationBasePackage` for `CommandBuilder` and `Listener` classes
150157
- `DependencyLoader` — resolves and attaches declared libraries at runtime via Paper's `MavenLibraryResolver`
151158
- Registration behavior: Commands are auto-registered; listeners are discovered but must be registered manually via `RegisterManager.registerListeners(plugin)`
152-
- Creates `.dependencies` under `build/generated-resources/` and copies it into `build/resources/main/`
159+
- Creates `.dependencies` under `build/generated-resources/` and copies it into `build/resources/main/`. If you declare custom repositories, also creates `.repositories` and copies it alongside
153160
- Patches `paper-plugin.yml` to add `loader` and `bootstrapper` if missing
154161
- Adds `cc.modlabs:KPaper:<version>` to the `api` configuration
155162
- Ensures Java/Kotlin compilation depends on the generation task and sees the generated sources
156163

157164
## 🔧 Configuration
158165

159-
The `kpaper` extension exposes the following properties:
166+
The `kpaper` extension exposes the following properties and DSL helpers:
160167

161168
- `javaVersion: Property<Int>` — Java toolchain and `--release` (default `21`)
162169
- `registrationBasePackage: Property<String>` — base package to scan (default `"cc.modlabs"`)
163170
- `deliver(vararg deps: String)` — declare runtime libraries, e.g. `deliver("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")`
171+
- `repository(url: String)` — add a Maven repository used by the runtime dependency loader; an id is inferred from the URL host
172+
- `repository(id: String, url: String)` — same as above but with an explicit id
173+
174+
Notes:
175+
- These repositories are used only by the generated runtime loader (`MavenLibraryResolver`) to resolve delivered libraries on the server. They do not affect Gradle resolution.
176+
- The ModLabs mirror `https://nexus.modlabs.cc/repository/maven-mirrors/` is always added by default.
177+
178+
## 🌐 Custom repositories for dependency delivery
179+
180+
You can declare additional Maven repositories that the runtime dependency loader will use when resolving libraries from your `deliver(...)` block. Example:
181+
182+
```kotlin
183+
kpaper {
184+
deliver("com.squareup.okio:okio:3.9.0")
185+
186+
// Add Maven Central explicitly (id inferred from host)
187+
repository("https://repo1.maven.org/maven2/")
188+
189+
// Add PaperMC public repository with a custom id
190+
repository("papermc", "https://repo.papermc.io/repository/maven-public/")
191+
}
192+
```
193+
194+
Under the hood, the plugin writes a `.repositories` file next to `.dependencies` in your built resources. The generated runtime `DependencyLoader` reads this file and appends each entry to the `MavenLibraryResolver`.
164195

165-
Environment variables (for building this Gradle plugin itself):
196+
Accepted `.repositories` line formats:
197+
- `url` (id inferred from host), e.g. `https://repo1.maven.org/maven2/`
198+
- `id url`, e.g. `papermc https://repo.papermc.io/repository/maven-public/`
166199

167200
- `KPAPER_VERSION` — pinned KPaper version embedded into the plugin (falls back to a timestamped default)
168201
- `VERSION_OVERRIDE` — override the plugin’s published version

0 commit comments

Comments
 (0)