本项目的预发布版本(alpha / beta / rc
)会发布在 GitHub Packages
上。
- 虽然发布到 GitHub 的预发布版本是
Public的 - 但是需要
token才能下载(GitHub 的限制)
参考资料:
- 登录 GitHub
- 进入 Settings → Developer settings → Personal access tokens → Tokens (classic) → Generate new token
- 勾选 read:packages 权限
- 复制生成的 token(只显示一次)
在 ~/.m2/settings.xml 中添加:
<servers>
<server>
<!-- 注意这个 id 要和下面 respiratory 中一致 -->
<id>github</id>
<username>你的GitHub用户名</username>
<password>你的Personal Access Token</password>
</server>
</servers>在 pom.xml 中添加 GitHub Packages 仓库:
<repositories>
<repository>
<!-- 注意这个 id 要和上面 servers 中一致 -->
<id>github</id>
<url>https://maven.pkg.github.com/hylexus/xtream-codec</url>
</repository>
</repositories>使用依赖示例:
<dependency>
<groupId>com.github.hylexus</groupId>
<artifactId>xtream-codec-core</artifactId>
<version>0.1.1-alpha.11.git.4e97026</version>
</dependency>
在 build.gradle.kts 中添加仓库:
repositories {
maven {
url = uri("https://maven.pkg.github.com/hylexus/xtream-codec")
credentials {
username = System.getenv("GITHUB_USERNAME") // 或在 gradle.properties 中配置
password = System.getenv("GITHUB_TOKEN")
}
}
}使用依赖示例:
dependencies {
api("com.github.hylexus:xtream-codec-core:0.1.1-alpha.11.git.4e97026")
}- 正式版(如 1.0.0、1.1.0)会发布到 Maven Central,无需
token。 - 预发布版(
alpha/beta/rc)必须带token,否则会报401 Unauthorized。