Maven Authentication Guide: Difference between revisions

From RetroMC
Jump to navigation Jump to search
No edit summary
Formatting fixes
 
Line 1: Line 1:
[[Category:Server internals]] [[Category:Guides]] [[Category:Developing]]
[[Category:Server internals]] [[Category:Guides]] [[Category:Developing]]
__NOTOC__
__NOTOC__
= Adding GitHub Credentials to Maven =
This guide is intended for [[RetroMC]] [[Ranks#Developer|developers]] who need to configure their local development environments to access private artifacts published via our SonaType RetroMC mirror.
 
== Adding GitHub credentials to Maven ==
== Purpose ==
 
This guide is intended for '''RetroMC developers''' who need to configure their '''local development environments''' to access '''private RetroMC artifacts''' published via '''our SonaType RetroMC mirror'''.
 
These credentials allow Maven to authenticate against GitHub in order to:
These credentials allow Maven to authenticate against GitHub in order to:
* Download private RetroMC dependencies
* Download private RetroMC dependencies
* Publish internal artifacts where required
* Publish internal artifacts where required
* Build and test RetroMC projects locally without authentication errors
* Build and test RetroMC projects locally without authentication errors
This setup is '''required for local development''' on projects that depend on private RetroMC packages.
This setup is '''required for local development''' on projects that depend on private RetroMC packages.
== Prerequisites ==
== Prerequisites ==
* A RetroMC Sonatype developer account (Requested from JohnyMuffin)
* A RetroMC Sonatype developer account (Requested from [[User:JohnyMuffin|JohnyMuffin]])
* Access to the relevant GitHub organisation/repositories
* Access to the relevant GitHub organisation/repositories
* Maven installed locally
* Maven installed locally
 
== Steps ==
== Step 1: Add the SonaType credentials to Maven ==
=== Add the SonaType credentials to Maven ===
 
Open (or create) the following file:
Open (or create) the following file:
 
~/.m2/settings.xml
<code>~/.m2/settings.xml</code>
 
On Windows, this is typically:
On Windows, this is typically:
 
C:\Users\&lt;your-username&gt;\.m2\settings.xml
<code>C:\Users\&lt;your-username&gt;\.m2\settings.xml</code>
 
Add the following configuration:
Add the following configuration:
<pre>
<pre>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
Line 47: Line 35:
</settings>
</settings>
</pre>
</pre>
Replace:
Replace:
* <code>YOUR_SONATYPE_USERNAME</code> with your Legacy Minecraft Sonatype Nexus Repository username
* <code>YOUR_SONATYPE_USERNAME</code> with your Legacy Minecraft Sonatype Nexus Repository username
Line 57: Line 41:
[[File:Maven4.png|800px|center|Maven settings.xml configuration]]
[[File:Maven4.png|800px|center|Maven settings.xml configuration]]


== Step 2: Verify ==
=== Verify ===
 
You should now be able to:
You should now be able to:
* Deploy artifacts to Sonatype
* Deploy artifacts to Sonatype
Line 65: Line 48:


If authentication fails:
If authentication fails:
* Confirm the <code>&lt;id&gt;</code> matches your repository id
* Confirm the <code>&lt;id&gt;</code> matches your repository ID
* Ensure the token includes <code>read:packages</code> and <code>write:packages</code>
* Ensure the token includes <code>read:packages</code> and <code>write:packages</code>
* Ensure you have access to the desired repository on GitHub
* Ensure you have access to the desired repository on GitHub
Line 71: Line 54:


== Security Notes ==
== Security Notes ==
* '''Never commit''' <code>settings.xml</code> to Git
* '''Never EVER commit''' <code>settings.xml</code> to Git
* Do not share tokens in screenshots, logs, or chat
* Do not share tokens in screenshots, logs, or chat
* Revoke tokens immediately if exposed
* Revoke tokens immediately if exposed

Latest revision as of 08:48, 17 July 2026


This guide is intended for RetroMC developers who need to configure their local development environments to access private artifacts published via our SonaType RetroMC mirror.

Adding GitHub credentials to Maven

These credentials allow Maven to authenticate against GitHub in order to:

  • Download private RetroMC dependencies
  • Publish internal artifacts where required
  • Build and test RetroMC projects locally without authentication errors

This setup is required for local development on projects that depend on private RetroMC packages.

Prerequisites

  • A RetroMC Sonatype developer account (Requested from JohnyMuffin)
  • Access to the relevant GitHub organisation/repositories
  • Maven installed locally

Steps

Add the SonaType credentials to Maven

Open (or create) the following file:

~/.m2/settings.xml

On Windows, this is typically:

C:\Users\<your-username>\.m2\settings.xml

Add the following configuration:

<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">

    <servers>
        <server>
            <id>johnymuffin-nexus-retromc</id>
            <username>YOUR_SONATYPE_USERNAME</username>
            <password>YOUR_SONATYPE_PASSWORDE</password>
        </server>
    </servers>

</settings>

Replace:

  • YOUR_SONATYPE_USERNAME with your Legacy Minecraft Sonatype Nexus Repository username
  • YOUR_SONATYPE_PASSWORDE with the Legacy Minecraft Sonatype Nexus Repository token
Maven settings.xml configuration
Maven settings.xml configuration

Verify

You should now be able to:

  • Deploy artifacts to Sonatype
  • Download packages from private repositories
  • Run Maven builds without authentication errors

If authentication fails:

  • Confirm the <id> matches your repository ID
  • Ensure the token includes read:packages and write:packages
  • Ensure you have access to the desired repository on GitHub
  • Check the token has not expired

Security Notes

  • Never EVER commit settings.xml to Git
  • Do not share tokens in screenshots, logs, or chat
  • Revoke tokens immediately if exposed