Maven Package Registry

Publish Maven packages for your user or organization.

Requirements

To work with the Maven package registry, you can use Maven or Gradle. The following examples use Maven and Gradle Groovy.

Configuring the package registry

To register the package registry you first need to add your access token to the settings.xml file:

  1. <settings>
  2. <servers>
  3. <server>
  4. <id>gitea</id>
  5. <configuration>
  6. <httpHeaders>
  7. <property>
  8. <name>Authorization</name>
  9. <value>token {access_token}</value>
  10. </property>
  11. </httpHeaders>
  12. </configuration>
  13. </server>
  14. </servers>
  15. </settings>

Afterwards add the following sections to your project pom.xml file:

  1. <repositories>
  2. <repository>
  3. <id>gitea</id>
  4. <url>https://gitea.example.com/api/packages/{owner}/maven</url>
  5. </repository>
  6. </repositories>
  7. <distributionManagement>
  8. <repository>
  9. <id>gitea</id>
  10. <url>https://gitea.example.com/api/packages/{owner}/maven</url>
  11. </repository>
  12. <snapshotRepository>
  13. <id>gitea</id>
  14. <url>https://gitea.example.com/api/packages/{owner}/maven</url>
  15. </snapshotRepository>
  16. </distributionManagement>
ParameterDescription
access_tokenYour personal access token.
ownerThe 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:

  1. repositories {
  2. // other repositories
  3. maven { url "https://gitea.example.com/api/packages/{owner}/maven" }
  4. }

In Groovy gradle you may include next script in your publishing part:

  1. publishing {
  2. // other settings of publication
  3. repositories {
  4. maven {
  5. name = "Gitea"
  6. url = uri("https://gitea.example.com/api/packages/{owner}/maven")
  7. credentials(HttpHeaderCredentials) {
  8. name = "Authorization"
  9. value = "token {access_token}"
  10. }
  11. authentication {
  12. header(HttpHeaderAuthentication)
  13. }
  14. }
  15. }
  16. }

Publish a package

To publish a package simply run:

  1. mvn deploy

Or call gradle with task publishAllPublicationsToGiteaRepository in case you are using gradle:

  1. ./gradlew publishAllPublicationsToGiteaRepository

If you want to publish a prebuild package to the registry, you can use mvn deploy:deploy-file:

  1. mvn deploy:deploy-file -Durl=https://gitea.example.com/api/packages/{owner}/maven -DrepositoryId=gitea -Dfile=/path/to/package.jar
ParameterDescription
ownerThe owner of the package.

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:

  1. <dependency>
  2. <groupId>com.test.package</groupId>
  3. <artifactId>test_project</artifactId>
  4. <version>1.0.0</version>
  5. </dependency>

And analog in gradle groovy:

  1. implementation "com.test.package:test_project:1.0.0"

Afterwards run:

  1. mvn install

Supported commands

  1. mvn install
  2. mvn deploy
  3. mvn dependency:get: