From 92d3e2a6f899347cfa47221d5b25cdcaf2cce486 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 10 Mar 2023 09:14:59 +0600 Subject: [PATCH] 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 --- docs/content/doc/packages/maven.en-us.md | 48 +++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/docs/content/doc/packages/maven.en-us.md b/docs/content/doc/packages/maven.en-us.md index 22da3c16d2..2ec5ca2ab7 100644 --- a/docs/content/doc/packages/maven.en-us.md +++ b/docs/content/doc/packages/maven.en-us.md @@ -23,7 +23,7 @@ Publish [Maven](https://maven.apache.org) packages for your user or organization ## Requirements To work with the Maven package registry, you can use [Maven](https://maven.apache.org/install.html) or [Gradle](https://gradle.org/install/). -The following examples use `Maven`. +The following examples use `Maven` and `Gradle Groovy`. ## Configuring the package registry @@ -73,6 +73,40 @@ Afterwards add the following sections to your project `pom.xml` file: | `access_token` | Your [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}). | | `owner` | The owner of the package. | +### Gradle variant + +When you plan to add some packages from Gitea instance in your project, you should add it in repositories section: + +```groovy +repositories { + // other repositories + maven { url "https://gitea.example.com/api/packages/{owner}/maven" } +} +``` + +In Groovy gradle you may include next script in your publishing part: + +```groovy +publishing { + // other settings of publication + repositories { + maven { + name = "Gitea" + url = uri("https://gitea.example.com/api/packages/{owner}/maven") + + credentials(HttpHeaderCredentials) { + name = "Authorization" + value = "token {access_token}" + } + + authentication { + header(HttpHeaderAuthentication) + } + } + } +} +``` + ## Publish a package To publish a package simply run: @@ -81,6 +115,12 @@ To publish a package simply run: mvn deploy ``` +Or call `gradle` with task `publishAllPublicationsToGiteaRepository` in case you are using gradle: + +```groovy +./gradlew publishAllPublicationsToGiteaRepository +``` + 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): ```shell @@ -105,6 +145,12 @@ To install a Maven package from the package registry, add a new dependency to yo ``` +And analog in gradle groovy: + +```groovy +implementation "com.test.package:test_project:1.0.0" +``` + Afterwards run: ```shell