Publishing to Maven Central
Publish your public-facing Fern Java SDK to the Maven Central registry. After following the steps on this page, you’ll have a versioned package published on Maven Central.
fern
folder on
your local machine. See Set up the fern
folder for more
details.Set up your GitHub integration
- Create a new GitHub repository called
company-java
(or something similar) for your SDK, if you haven’t done so already. - Install the Fern GitHub App: Select Configure, then scroll down to Repository Access. Select Only select repositories and in the dropdown select the repository for your SDK. Click Save.
Configure generators.yml
Run fern add <generator>
Navigate to your generators.yml
on your local machine. Your generators.yml
lives inside of your fern
folder and contains all the configuration for your Fern generators.
Add a new generator to generators.yml
:
Once the command completes, you’ll see a new group created in your generators.yml
:
Configure output
location
Next, change the output location in generators.yml
from local-file-system
(the default) to maven
to indicate that Fern should publish your package directly to the Maven Central registry:
Set up Maven Central publishing authentication via the Central Portal
Generate user tokens
-
Click on your username, then select View Account
-
Click on Generate User Token, then click Ok to confirm generation. This will invalidate any existing token.
Save your username and password tokens – they won’t be displayed after you leave the page.
Configure Maven Central authentication token
Add username: ${MAVEN_USERNAME}
and password: ${MAVEN_PASSWORD}
to generators.yml
to tell Fern to use the MAVEN_USERNAME
and MAVEN_PASSWORD
environment variable for authentication when publishing to the Maven Central registry.
Generate GPG Signature
Next, set up code signing credentials by generating or identifying a GPG key ID, password, and secret key. Maven Central requires all artifacts to be digitally signed with PGP/GPG keys.
-
Find your key
-
If you already have a GPG key, you can list your keys:
-
If you don’t have a GPG key, you can generate a new one:
You’ll be prompted to create a new username and passphrase.
-
-
To export your secret key, run:
Be sure to replace
KEY_ID
with the key ID of the key you want to export.More information is available on Maven Central’s GPG validation page.
Release your SDK to Maven Central
At this point, you’re ready to generate a release for your SDK.