Update README.md

This commit is contained in:
Fankesyooni
2023-09-08 14:57:40 +08:00
committed by GitHub
parent aa37837e3b
commit ce3f54bd63

104
README.md
View File

@@ -4,12 +4,8 @@
This is a simple Maven repository by using GitHub to manage dependencies.
You can fork this repository as a template to create your own personal Maven repository, provided it maintains and follows the `Apache-2.0` license.
这是一个使用 GitHub 管理依赖的简单 Maven 存储库。
你可以复刻此存储库作为模版创建自己的私人 Maven 存储库,但必须保持并遵循 `Apache-2.0` 许可协议。
## Usage
The directory `repository` is the repository, which contains two parts: `releases` (release version) and `snapshots` (snapshots), where all Maven project artifacts are stored.
@@ -19,13 +15,13 @@ Reference this repository using the link below.
> Releases
```
https://raw.githubusercontent.com/[organization name or username]/[repository name]/[branch name]/repository/releases
https://raw.githubusercontent.com/fankes/maven-repository/main/repository/releases
```
> SnapShots
```
https://raw.githubusercontent.com/[organization name or username]/[repository name]/[branch name]/repository/snapshots
https://raw.githubusercontent.com/fankes/maven-repository/main/repository/snapshots
```
### Usage in Gradle Projects
@@ -37,12 +33,12 @@ You can use this repository in any Gradle project.
```kotlin
repositories {
maven {
name = "personal-maven-repository-releases"
setUrl("https://raw.githubusercontent.com/[organization name or user name]/[repository name]/[branch name]/repository/releases")
name = "fankes-maven-releases"
setUrl("https://raw.githubusercontent.com/fankes/maven-repository/main/repository/releases")
}
maven {
name = "personal-maven-repository-snapshots"
setUrl("https://raw.githubusercontent.com/[organization name or username]/[repository name]/[branch name]/repository/snapshots")
name = "fankes-maven-snapshots"
setUrl("https://raw.githubusercontent.com/fankes/maven-repository/main/repository/snapshots")
}
}
```
@@ -51,40 +47,10 @@ You can also use [SweetDependency](https://github/HighCapable/SweetDependency) t
```yaml
repositories:
personal-maven-repository-releases:
url: https://raw.githubusercontent.com/[organization name or username]/[repository name]/[branch name]/repository/releases
personal-maven-repository-snapshots:
url: https://raw.githubusercontent.com/[organization name or username]/[repository name]/[branch name]/repository/snapshots
```
#### Publish Artifacts to Repository
It is recommended to use vanniktech's [gradle-maven-publish-plugin](https://vanniktech.github.io/gradle-maven-publish-plugin) to publish Maven artifacts.
Below is a reference for how to configure a repository to publish to.
You can publish the repository directly to the `.gradle/personal-maven-repository` directory under your local user directory, and then set `personal-maven-repository` as a git repository.
Connect the `personal-maven-repository` directory to GitHub.
After each release of artifacts, perform a `git commit` and `git push` to synchronize the current repository.
```kotlin
publishing {
repositories {
val repositoryDir = gradle.gradleUserHomeDir
.resolve("personal-maven-repository")
.resolve("repository")
maven {
name = "PersonalMavenReleases"
url = repositoryDir.resolve("releases").toURI()
}
maven {
name = "PersonalMavenSnapShots"
url = repositoryDir.resolve("snapshots").toURI()
}
}
}
fankes-maven-releases:
url: https://raw.githubusercontent.com/fankes/maven-repository/main/repository/releases
fankes-maven-snapshots:
url: https://raw.githubusercontent.com/fankes/maven-repository/main/repository/snapshots
```
## 使用方法
@@ -96,13 +62,13 @@ publishing {
> Releases
```
https://raw.githubusercontent.com/[组织名或用户名]/[存储库名]/[分支名]/repository/releases
https://raw.githubusercontent.com/fankes/maven-repository/main/repository/releases
```
> SnapShots
```
https://raw.githubusercontent.com/[组织名或用户名]/[存储库名]/[分支名]/repository/snapshots
https://raw.githubusercontent.com/fankes/maven-repository/main/repository/snapshots
```
针对中国大陆地区无法访问 `raw.githubusercontent.com` 可以使用加速服务,例如 [GitMirror](https://gitmirror.com/)。
@@ -116,12 +82,12 @@ https://raw.githubusercontent.com/[组织名或用户名]/[存储库名]/[分支
```kotlin
repositories {
maven {
name = "personal-maven-repository-releases"
setUrl("https://raw.githubusercontent.com/[组织名或用户名]/[存储库名]/[分支名]/repository/releases")
name = "fankes-maven-releases"
setUrl("https://raw.githubusercontent.com/fankes/maven-repository/main/repository/releases")
}
maven {
name = "personal-maven-repository-snapshots"
setUrl("https://raw.githubusercontent.com/[组织名或用户名]/[存储库名]/[分支名]/repository/snapshots")
name = "fankes-maven-snapshots"
setUrl("https://raw.githubusercontent.com/fankes/maven-repository/main/repository/snapshots")
}
}
```
@@ -130,40 +96,10 @@ repositories {
```yaml
repositories:
personal-maven-repository-releases:
url: https://raw.githubusercontent.com/[组织名或用户名]/[存储库名]/[分支名]/repository/releases
personal-maven-repository-snapshots:
url: https://raw.githubusercontent.com/[组织名或用户名]/[存储库名]/[分支名]/repository/snapshots
```
#### 发布工件到存储库
推荐使用 vanniktech 的 [gradle-maven-publish-plugin](https://vanniktech.github.io/gradle-maven-publish-plugin) 来发布 Maven 工件。
下面是一个配置发布到的存储库方式的参考。
你可以直接将存储库发布到本机用户目录下的 `.gradle/personal-maven-repository` 目录中,然后将 `personal-maven-repository` 设置为 git 存储库。
`personal-maven-repository` 目录连接到 GitHub。
每次发布工件后,进行一次 `git commit``git push` 即可同步当前存储库。
```kotlin
publishing {
repositories {
val repositoryDir = gradle.gradleUserHomeDir
.resolve("personal-maven-repository")
.resolve("repository")
maven {
name = "PersonalMavenReleases"
url = repositoryDir.resolve("releases").toURI()
}
maven {
name = "PersonalMavenSnapShots"
url = repositoryDir.resolve("snapshots").toURI()
}
}
}
fankes-maven-releases:
url: https://raw.githubusercontent.com/fankes/maven-repository/main/repository/releases
fankes-maven-snapshots:
url: https://raw.githubusercontent.com/fankes/maven-repository/main/repository/snapshots
```
## License