Skip to content

Commit 92d3e2a

Browse files
Add gradle samples in maven doc of packages (#23374)
Samples for gitea.io docs to help to use maven packages with gradle-oriented projects --------- Co-authored-by: KN4CK3R <[email protected]>
1 parent 17c8a05 commit 92d3e2a

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

docs/content/doc/packages/maven.en-us.md

+47-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Publish [Maven](https://maven.apache.org) packages for your user or organization
2323
## Requirements
2424

2525
To work with the Maven package registry, you can use [Maven](https://maven.apache.org/install.html) or [Gradle](https://gradle.org/install/).
26-
The following examples use `Maven`.
26+
The following examples use `Maven` and `Gradle Groovy`.
2727

2828
## Configuring the package registry
2929

@@ -73,6 +73,40 @@ Afterwards add the following sections to your project `pom.xml` file:
7373
| `access_token` | Your [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}). |
7474
| `owner` | The owner of the package. |
7575

76+
### Gradle variant
77+
78+
When you plan to add some packages from Gitea instance in your project, you should add it in repositories section:
79+
80+
```groovy
81+
repositories {
82+
// other repositories
83+
maven { url "https://gitea.example.com/api/packages/{owner}/maven" }
84+
}
85+
```
86+
87+
In Groovy gradle you may include next script in your publishing part:
88+
89+
```groovy
90+
publishing {
91+
// other settings of publication
92+
repositories {
93+
maven {
94+
name = "Gitea"
95+
url = uri("https://gitea.example.com/api/packages/{owner}/maven")
96+
97+
credentials(HttpHeaderCredentials) {
98+
name = "Authorization"
99+
value = "token {access_token}"
100+
}
101+
102+
authentication {
103+
header(HttpHeaderAuthentication)
104+
}
105+
}
106+
}
107+
}
108+
```
109+
76110
## Publish a package
77111

78112
To publish a package simply run:
@@ -81,6 +115,12 @@ To publish a package simply run:
81115
mvn deploy
82116
```
83117

118+
Or call `gradle` with task `publishAllPublicationsToGiteaRepository` in case you are using gradle:
119+
120+
```groovy
121+
./gradlew publishAllPublicationsToGiteaRepository
122+
```
123+
84124
If you want to publish a prebuild package to the registry, you can use [`mvn deploy:deploy-file`](https://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html):
85125

86126
```shell
@@ -105,6 +145,12 @@ To install a Maven package from the package registry, add a new dependency to yo
105145
</dependency>
106146
```
107147

148+
And analog in gradle groovy:
149+
150+
```groovy
151+
implementation "com.test.package:test_project:1.0.0"
152+
```
153+
108154
Afterwards run:
109155

110156
```shell

0 commit comments

Comments
 (0)