Maven Dependency Repository (Public API Publishing)
About 549 wordsAbout 2 min
2026-09-05
Other Java mods can depend on this mod's API-only jar (jython-mod-api) via Maven, call JythonModApi.register(...) in their code, and expose their own APIs to Python scripts (see Public API).
The repository is hosted on Cloudflare Pages (free and accessible from within mainland China); CI publishes automatically when a tag is pushed.
Repository Coordinates
// 仓库地址(Cloudflare Pages 自定义域名)
maven { url = 'https://maven.luojiayuan.de5.net' }
// 依赖(把版本换成最新 tag)
modCompileOnly "net.luojiayuan.jython.mod:jython-mod-api:v1.2.0-pre"
jython-mod-apiis an API-only artifact (pure JDK, ~10 KB, containing onlyJythonModApi/ApiReflect). It is used only for compile-time calls to register APIs; at runtime you still need to put the full mod jar into mods/ / plugins/ (download the full fat jar from Releases).
1. Cloudflare Pages Initialization (one-time)
- Log in to the Cloudflare Dashboard;
- Workers & Pages → Create → Pages, fill in
jython-mod-mavenas the project name (can be changed, but must matchCLOUDFLARE_PAGES_PROJECTin CI); choose Direct Upload as the connection method (no Git connection needed, CI uploads files directly); - After the project is created: Custom domains → Set up a custom domain, fill in
maven.yourdomain.comand complete the DNS binding; - Note the Account ID (bottom-right of the Dashboard home page / the Workers page).
2. GitHub Actions Secrets (one-time)
In the repository Settings → Secrets and variables → Actions, add:
| Secret | Value |
|---|---|
CLOUDFLARE_API_TOKEN | Create an API Token in Cloudflare, choose the Pages:Edit permission (Account > Cloudflare Pages > Edit), and record the token as CLOUDFLARE_API_TOKEN |
CLOUDFLARE_ACCOUNT_ID | The Account ID (see above) |
Optional variable: CLOUDFLARE_PAGES_PROJECT (default jython-mod-maven).
3. Publishing Workflow
Push a tag (or manually trigger the Publish Maven API workflow):
git tag v1.2.0-pre && git push origin v1.2.0-preCI runs automatically:
./gradlew publishMavenApiPublicationToGithubPagesRepository # 生成 build/maven-repo
npx wrangler pages deploy build/maven-repo # 推到 Cloudflare PagesAfter publishing, verify (in a browser or via curl):
https://maven.luojiayuan.de5.net/net/luojiayuan/jython/mod/jython-mod-api/maven-metadata.xml4. Local Manual Publishing (for debugging, no CI needed)
# 生成 maven 目录到 build/maven-repo
./gradlew publishMavenApiPublicationToGithubPagesRepository
# 本地起个静态服务器验证(任选其一)
python3 -m http.server 8080 -d build/maven-repo
# 用 wrangler 手动部署(需本机登录 Cloudflare:npx wrangler login)
npx wrangler pages deploy build/maven-repo --project-name=jython-mod-maven5. Mod Author Integration Example
repositories {
maven { url = 'https://maven.luojiayuan.de5.net' }
// Fabric 还需 Fabric maven:
maven { url = 'https://maven.fabricmc.net/' }
}
dependencies {
// Fabric:modCompileOnly;NeoForge/Paper 用 compileOnly
modCompileOnly "net.luojiayuan.jython.mod:jython-mod-api:v1.2.0-pre"
}import net.luojiayuan.jython.mod.api.JythonModApi;
public class MyMod implements ModInitializer {
@Override
public void onInitialize() {
// 建议在各平台最早的初始化阶段注册(Fabric preLaunch / NeoForge
// 构造 / Paper onLoad),保证早于 Python 脚本运行,详见 api.md 时序一节。
JythonModApi.register("mymod", new MyApi());
JythonModApi.register("mymod", MyApiClass.class);
}
}Related Documentation
- Full usage and timing constraints of the public API: api.md
