0
0
Fork 0
mirror of https://codeberg.org/forgejo/docs.git synced 2024-12-27 23:03:38 -05:00
forgejo-docs/v1.19/admin/packages/maven.md

108 lines
3 KiB
Markdown
Raw Normal View History

2023-02-26 18:08:07 -05:00
---
layout: '~/layouts/Markdown.astro'
title: 'Maven Packages Repository'
2023-03-03 01:44:11 -05:00
license: 'Apache-2.0'
origin_url: 'https://github.com/go-gitea/gitea/blob/699f20234b9f7cdbbeeee3be004470c598fa1147/docs/content/doc/packages/maven.en-us.md'
2023-02-26 18:08:07 -05:00
---
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`.
## Configuring the package registry
To register the package registry you first need to add your access token to the [`settings.xml`](https://maven.apache.org/settings.html) file:
```xml
<settings>
<servers>
<server>
<id>forgejo</id>
<configuration>
<httpHeaders>
<property>
<name>Authorization</name>
<value>token {access_token}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
```
Afterwards add the following sections to your project `pom.xml` file:
```xml
<repositories>
<repository>
<id>forgejo</id>
<url>https://forgejo.example.com/api/packages/{owner}/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>forgejo</id>
<url>https://forgejo.example.com/api/packages/{owner}/maven</url>
</repository>
<snapshotRepository>
<id>forgejo</id>
<url>https://forgejo.example.com/api/packages/{owner}/maven</url>
</snapshotRepository>
</distributionManagement>
```
2023-03-03 01:44:11 -05:00
| Parameter | Description |
| -------------- | ------------------------------------------------------------------------------------------------ |
2023-02-26 18:08:07 -05:00
| `access_token` | Your [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}). |
2023-03-03 01:44:11 -05:00
| `owner` | The owner of the package. |
2023-02-26 18:08:07 -05:00
## Publish a package
To publish a package simply run:
```shell
mvn deploy
```
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
mvn deploy:deploy-file -Durl=https://forgejo.example.com/api/packages/{owner}/maven -DrepositoryId=forgejo -Dfile=/path/to/package.jar
```
2023-03-03 01:44:11 -05:00
| Parameter | Description |
| --------- | ------------------------- |
| `owner` | The owner of the package. |
2023-02-26 18:08:07 -05:00
You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
## Install a package
To install a Maven package from the package registry, add a new dependency to your project `pom.xml` file:
```xml
<dependency>
<groupId>com.test.package</groupId>
<artifactId>test_project</artifactId>
<version>1.0.0</version>
</dependency>
```
Afterwards run:
```shell
mvn install
```
## Supported commands
```
mvn install
mvn deploy
mvn dependency:get:
```