Github Maven Repositories

Overview

  1. Generate Github Access Token
  2. Modify ~/.m2/settings.xml to include Access Token & Repository
  3. Modify ~/dev/MY-MAVEN-PROJECT/pom.xml to include distribution management
  4. Deploying and Viewing Maven Dependency

Part 1

Generate Github Access Token

Part 2

Modify ~/.m2/settings.xml to include Access Token & Repository

Note for Heroku Deployment:
include a copy of ~/.m2/settings.xml in the root directory of a maven project upon deploying to Heroku.

Include settings children: activeProfiles, profiles, and servers

<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 https://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>
        </repository>
        <repository>
          <id>github</id>
          <url>https://maven.pkg.github.com/USERNAME/*</url>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>

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

Part 3

Deploying Maven Package

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

Part 4

Viewing Maven Package