diff options
author | InsanusMokrassar | 2023-03-10 09:14:59 +0600 |
---|---|---|
committer | GitHub | 2023-03-09 22:14:59 -0500 |
commit | 92d3e2a6f899347cfa47221d5b25cdcaf2cce486 (patch) | |
tree | db2b8389ec30866f222bae6d5b5161762504def7 | |
parent | 17c8a0523a9f1bf717046823d4c0f69d606fe90a (diff) |
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 <admin@oldschoolhack.me>
-rw-r--r-- | docs/content/doc/packages/maven.en-us.md | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/docs/content/doc/packages/maven.en-us.md b/docs/content/doc/packages/maven.en-us.md index 22da3c16d..2ec5ca2ab 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 </dependency> ``` +And analog in gradle groovy: + +```groovy +implementation "com.test.package:test_project:1.0.0" +``` + Afterwards run: ```shell |