Skip to content

Maven GitHub

Adrian Wilke edited this page Nov 5, 2019 · 2 revisions

Note: For Maven, we're using Maven-AKSW instead of GitHub.

GitHub Maven Repository: Configuration steps for OPAL

Using existing packages

Currently, a manual download and installation of packages at GitHub is needed. That is described in the OPAL common README and Maven: Guide to installing 3rd party JARs.

Publishing at GitHub Maven Repository

1. Authentication

Use the information in the GitHub article Creating a personal access token for the command line to create a token at GitHub settings: tokens. You need to set the read:packages and write:packages scopes. You can copy the token only one time, directly after generation.

2. Add the repository to your system

Edit the file ~/.m2/settings.xml and insert the code below.
Replace TOKEN with the data from the step above and replace also USERNAME with your GitHub username.

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <activeProfiles>
    <activeProfile>github</activeProfile>
  </activeProfiles>

  <profiles>
    <profile>
      <id>github</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
        <repository>
          <id>github-projekt-opal</id>
          <name>GitHub projekt-opal Apache Maven Packages</name>
          <url>https://maven.pkg.github.com/projekt-opal</url>
        </repository>
      </repositories>
    </profile>
  </profiles>

  <servers>
    <server>
      <id>github-projekt-opal</id>
      <username>USERNAME</username>
      <password>TOKEN</password>
    </server>
  </servers>
</settings>

3. Configure your Java project

Edit the pom.xml of your project. Replace REPOSITORY with the name of your GitHub repository.

<distributionManagement>
   <repository>
     <id>github-projekt-opal</id>
     <name>GitHub projekt-opal Apache Maven Packages</name>
     <url>https://maven.pkg.github.com/projekt-opal/REPOSITORY</url>
   </repository>
</distributionManagement>

Now you should be able to execute mvn deploy.

General information on GitHub