You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/products/sdks/overview/java/publishing-to-maven-central.mdx
+226-2Lines changed: 226 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,230 @@ title: Publishing to Maven Central
3
3
description: How to publish the Fern Java SDK to Maven Central.
4
4
---
5
5
6
-
Learn how to publish your Fern Java SDK to the Maven Central registry.
6
+
Publish your public-facing Fern Java SDK to the [Maven Central
7
+
registry](https://pypi.org/). After following the steps on this page,
8
+
you'll have a versioned package published on Maven Central.
7
9
8
-
<Warning>This page is a WIP, please refer to our previous [documentation](https://buildwithfern.com/learn/sdks/guides/publish-a-public-facing-sdk).</Warning>
10
+
<Info>This guide assumes that you already have an initialized `fern` folder on your local machine. If you don’t, run `fern init`. See [Java Quickstart](quickstart.mdx) for more details.</Info>
11
+
12
+
## Set up your GitHub integration
13
+
14
+
1. Create a new GitHub repository called `company-java` (or something similar) for your SDK, if you haven't done so already.
15
+
1. Install the [Fern GitHub App](https://github.com/apps/fern-api): Select **Configure**, then scroll down to **Repository Access**. Select **Only select repositories** and in the dropdown select the repository for your SDK. Click **Save**.
16
+
17
+
18
+
## Configure `generators.yml`
19
+
20
+
<Steps>
21
+
22
+
<Steptitle="Run `fern add <generator>`">
23
+
24
+
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.
25
+
26
+
Add a new generator to `generators.yml`:
27
+
28
+
29
+
```bash
30
+
fern add fern-java-sdk --group java-sdk
31
+
```
32
+
33
+
Once the command completes, you'll see a new group created in your `generators.yml`:
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
104
+
105
+
<Steps>
106
+
107
+
<Step title="Log into Maven Central">
108
+
109
+
Log into [Maven Central](https://pypi.org/) or create a new account.
110
+
111
+
</Step>
112
+
113
+
<Step title="Generate user tokens">
114
+
115
+
1. Click on your username, then select **View Account**
116
+
1. Click on **Generate User Token**, then click **Ok** to confirm
117
+
generation. This will invalidate any existing token.
118
+
119
+
<Warning>Save your username and password tokens – they won’t be displayed after you leave the page.</Warning>
120
+
121
+
</Step>
122
+
123
+
124
+
<Step title="Configure Maven Central authentication token">
125
+
126
+
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.
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.
147
+
148
+
<Info>If you don't have gpg installed, you can download the binary from [https://gnupg.org/download/index.html](https://gnupg.org/download/index.html), or install it via package manager.</Info>
149
+
150
+
1. Find your key
151
+
* If you already have a GPG key, you can list your keys:
152
+
153
+
```sh
154
+
gpg --list-secret-keys --keyid-format LONG
155
+
```
156
+
157
+
* If you don't have a GPG key, you can generate a new one:
158
+
159
+
```sh
160
+
gpg --gen-key
161
+
```
162
+
163
+
You'll be prompted to create a new username and passphrase.
164
+
165
+
1. To export your secret key, run:
166
+
167
+
```sh
168
+
gpg --export-secret-keys --armor KEY_ID
169
+
```
170
+
171
+
Be sure to replace `KEY_ID` with the key ID of the key you want to export.
172
+
173
+
<Info>More information is available on [Maven Central's GPG validation page](https://central.sonatype.org/publish/requirements/gpg/).</Info>
174
+
</Step>
175
+
<Step title="Configure GPG Signature">
176
+
177
+
Add the `keyId`, `password`, and `secretKey` from the previous step to `generators.yml`:
0 commit comments