Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gradle samples in maven doc of packages #23374

Merged
merged 3 commits into from
Mar 10, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion docs/content/doc/packages/maven.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand Down