docs: add Gradle dependency tutorial in README#4304
Conversation
|
|
There was a problem hiding this comment.
Pull request overview
Adds Gradle dependency usage instructions to the project documentation (English + Chinese) so users can consume release and snapshot BOMs (including GitHub Packages authentication for snapshots), addressing the missing Gradle tutorial requested in #217.
Changes:
- Document Gradle BOM import for release versions.
- Document Gradle snapshot repository + credentials configuration for GitHub Packages.
- Mirror the above additions in both
README.mdandREADME-zh.md.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| README.md | Adds Gradle dependency (release + snapshot) setup instructions and credential guidance. |
| README-zh.md | Adds the same Gradle dependency instructions in Chinese. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Use Maven Central BOM in your `build.gradle` (or `build.gradle.kts`) via `platform`: | ||
|
|
||
| ```groovy | ||
| dependencies { | ||
| implementation platform("com.alibaba.cloud:spring-cloud-alibaba-dependencies:2025.1.0.0") | ||
|
|
||
| // choose starter(s) as needed | ||
| implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config" | ||
| } |
There was a problem hiding this comment.
The section mentions build.gradle.kts, but the example is Groovy DSL (and will not paste directly into Kotlin DSL). Either add a Kotlin DSL variant (including dependencies { implementation(platform("...")) } syntax) or adjust the text to only reference build.gradle/Groovy.
| repositories { | ||
| mavenCentral() | ||
| maven { | ||
| url = uri("https://maven.pkg.github.com/alibaba/spring-cloud-alibaba") | ||
| credentials { | ||
| username = findProperty("gpr.user") ?: System.getenv("GITHUB_USERNAME") | ||
| password = findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN") | ||
| } | ||
| } |
There was a problem hiding this comment.
For the GitHub Packages repository used only for snapshots, consider restricting it to snapshots (Gradle equivalent of the earlier Maven <releases><enabled>false</enabled></releases> / <snapshots><enabled>true</enabled></snapshots>). Without this, Gradle may attempt release resolution against GitHub Packages, which can slow dependency resolution and cause surprising results.
| 在 `build.gradle`(或 `build.gradle.kts`)中通过 `platform` 引入 BOM: | ||
|
|
||
| ```groovy | ||
| dependencies { | ||
| implementation platform("com.alibaba.cloud:spring-cloud-alibaba-dependencies:2025.1.0.0") | ||
|
|
||
| // 按需选择 starter | ||
| implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config" | ||
| } | ||
| ``` |
There was a problem hiding this comment.
这里提到可用于 build.gradle.kts,但示例代码块是 Groovy DSL(Kotlin DSL 不能直接复制粘贴使用)。建议补充一个 Kotlin DSL 版本的示例,或把文案调整为仅针对 build.gradle。

Summary\nAdd Gradle dependency usage documentation to both English and Chinese README files, including release and snapshot configuration examples.\n\n## Changes\n- Add Gradle release BOM usage examples.\n- Add Gradle snapshot repository and credentials examples.\n- Update both \README.md\ and \README-zh.md.\n\nCloses #217