1
1
mirror of https://github.com/go-gitea/gitea synced 2024-11-18 08:04:25 +00:00
gitea/docs/content/doc/packages/maven.en-us.md
silverwind ae52df6a64
Add markdownlint (#20512)
Add `markdownlint` linter and fix issues. Config is based on the one
from electron's repo with a few rules relaxed.
2022-07-28 09:22:47 +08:00

2.4 KiB

date title slug draft toc menu
2021-07-20T00:00:00+00:00 Maven Packages Repository packages/maven false false
sidebar
parent name weight identifier
packages Maven 60 maven

Maven Packages Repository

Publish Maven packages for your user or organization.

Table of Contents

{{< toc >}}

Requirements

To work with the Maven package registry, you can use Maven or Gradle. 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 file:

<settings>
  <servers>
    <server>
      <id>gitea</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:

<repositories>
  <repository>
    <id>gitea</id>
    <url>https://gitea.example.com/api/packages/{owner}/maven</url>
  </repository>
</repositories>
<distributionManagement>
  <repository>
    <id>gitea</id>
    <url>https://gitea.example.com/api/packages/{owner}/maven</url>
  </repository>
  <snapshotRepository>
    <id>gitea</id>
    <url>https://gitea.example.com/api/packages/{owner}/maven</url>
  </snapshotRepository>
</distributionManagement>
Parameter Description
access_token Your [personal access token]({{< relref "doc/developers/api-usage.en-us.md#authentication" >}}).
owner The owner of the package.

Publish a package

To publish a package simply run:

mvn deploy

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:

<dependency>
  <groupId>com.test.package</groupId>
  <artifactId>test_project</artifactId>
  <version>1.0.0</version>
</dependency>

Afterwards run:

mvn install

Supported commands

mvn install
mvn deploy
mvn dependency:get: