Christian Screen
Christian Screen

Build a Github Package on a Mac : .m2/settings.xml on a Mac

Twitter
LinkedIn

So much code is available as open source and our friends at github have given us mere mortal developers the ability to harness code packages as a way of building code bases on-demand when cloning other projects for a smaller overall footprint. In using Java Maven dependencies the consumer of the github repository will need a maven, obviously, but also to update the Maven settings file on their local machine. To do this Github has provided a fairly long-winded document, https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry to build a github package on a mac by modifying or creating the .md2/settings.xml file on a mac os.

Use a terminal or a finder capable of viewing hidden files and navigate to the ~/.m2/ directory. A simple preview of this using the following terminal command should pose no problem to make sure you are in the right place.

ls -lah ~/.m2

This is technically the same thing as accessing the /Users/<username>/.m2 directory, but your mileage may vary.

If you do not see the settings.xml file you will need to create it and typically an the following information after you have received your PERSONAL TOKEN from your Github developer settings,

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

You can find or create your personal access token by clicking on your Profile > Settings > Developer Settings (left bottom of settings page)

Once you click on Developer settings you will need to create a “Personal access token” so click that option and typically you will choose the “(classic)” option. We’ve found that most integrations still us this classic option thought at the time of this writing the newer fined grained token is still in beta.

For packages you can check usually the READ option unless you need to create and store thus write a package back to Github. Most cloned repositories require you to only read, so usually selecting on that option is sufficient.

Add the token and your username to your existing settings.xml file. If you do not have an existing settings.xml file create one using the following structure:

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

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

Run the appropriate maven build commands and tweak as needed.

More to explorer

International Women's Day 2024

International Women’s Day 2024: Empowerment and Progress

As we commemorate International Women’s Day on March 8th each year, it’s a time to honor the resilience, accomplishments, and contributions of women worldwide. In 2024, this day holds particular significance as we take stock of the strides made, acknowledge persistent challenges, and recommit ourselves to the pursuit of gender equality.

Bank grade security

5 Steps to Configure Key Pair Authentication in Snowflake

Key pair authentication is a secure way to access your Snowflake data warehouse without relying solely on traditional username and password authentication. In this step-by-step guide, we will walk you through the process of setting up key pair authentication in Snowflake. We’ll also cover how to install OpenSSL, a crucial tool for generating the necessary key pair.

streamline-processes

Streamlining Your Bullhorn CRM: Mastering Duplicate Data Management

Discover the most effective strategies for eliminating duplicate records in your Bullhorn CRM. Duplicates can hinder your productivity, lead to data inaccuracies, and impact your relationships with clients and candidates. In this insightful session, we will guide you through best practices, cutting-edge tools, and proven techniques to ensure a clean and efficient CRM database.

Scroll to Top