Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 45 additions & 37 deletions fern/products/sdks/overview/java/publishing-to-maven-central.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: How to publish the Fern Java SDK to Maven Central.
---

Publish your public-facing Fern Java SDK to the [Maven Central
registry](https://pypi.org/). After following the steps on this page,
you'll have a versioned package published on Maven Central.
registry](https://central.sonatype.com/). After following the steps on this
page, you'll have a versioned package published on Maven Central.

<Markdown src="/products/sdks/snippets/setup-fern-folder-callout.mdx"/>

Expand Down Expand Up @@ -54,63 +54,71 @@ you'll have a versioned package published on Maven Central.

```
</Step>

<Step title="Configure Maven Coordinate">

Add the `coordinate: groupId:artifactId` field to specify how your Java
SDK will be published and referenced in the Central Maven respository.

```yaml {8}
groups:
java-sdk:
generators:
- name: fernapi/fern-java-sdk
version: <Markdown src="/snippets/version-number-java.mdx"/>
output:
location: maven
coordinate: com.company:sdk-name #<company name in reverse domain name format>:<SDK name>
```

</Step>



<Step title="Add repository location">

Add the path to your GitHub repository to `generators.yml`:

```yaml {9-10}
```yaml {8-9}
groups:
java-sdk:
generators:
- name: fernapi/fern-java-sdk
version: <Markdown src="/snippets/version-number-java.mdx"/>
output:
location: maven
coordinate: com.company:sdk-name
github:
repository: your-org/company-java
```

</Step>
</Steps>

## Set up Maven Central publishing authentication via the Central Portal
## Set up Maven Central publishing authentication

<Steps>

<Step title="Log into Maven Central">

Log into [Maven Central](https://pypi.org/) or create a new account.
Log into [Maven Central](https://central.sonatype.com/) or create a new account.

</Step>

<Step title="Verify your namespace">

1. Click on your username, then select **View Namespaces**. Click **Register New Namespace**.
1. Enter your company website or GitHub account in reverse domain name format and go through the
verification process.

</Step>
<Step title="Configure Maven Coordinate">

Add the namespace you just verified in Maven Central to the `coordinate:
groupId:artifactId` field. This specifies how your Java SDK will be
published and referenced in the Maven Central respository.

```yaml {8}
groups:
java-sdk:
generators:
- name: fernapi/fern-java-sdk
version: <Markdown src="/snippets/version-number-java.mdx"/>
output:
location: maven
coordinate: com.company:sdk-name # <company name in reverse domain name format>:<SDK name>
github:
repository: your-org/company-java
```

</Step>

<Step title="Generate user tokens">

1. Click on your username, then select **View Account**
1. Click on **Generate User Token**, then click **Ok** to confirm
generation. This will invalidate any existing token.
1. Back in Maven Central, click on your username, then select **View Account**
1. Click on **Generate User Token**, then click **Ok** to confirm
generation. This will invalidate any existing token.

<Warning>Save your username and password tokens – they won’t be displayed after you leave the page.</Warning>
<Warning>Save your username and password tokens – they won’t be displayed after you leave the page.</Warning>

</Step>

Expand Down Expand Up @@ -182,9 +190,9 @@ groups:
username: ${MAVEN_USERNAME}
password: ${MAVEN_PASSWORD}
signature:
keyId: ${MAVEN_CENTRAL_SECRET_KEY_KEY_ID}
password: ${MAVEN_CENTRAL_SECRET_KEY_PASSWORD}
secretKey: ${MAVEN_CENTRAL_SECRET_KEY}
keyId: ${MAVEN_SIGNATURE_SECRET_KEY_ID}
password: ${MAVEN_SIGNATURE_PASSWORD}
secretKey: ${MAVEN_SIGNATURE_SECRET_KEY}
github:
repository: your-org/company-java
```
Expand All @@ -203,10 +211,10 @@ groups:

```bash
export MAVEN_USERNAME=your-maven-username
export MAVEN_PASSWORD=your-maven-password
export MAVEN_CENTRAL_SECRET_KEY_KEY_ID=your-gpg-key-id
export MAVEN_CENTRAL_SECRET_KEY_PASSWORD=your-gpg-passphrase
export MAVEN_CENTRAL_SECRET_KEY=your-gpg-secret-key
export MAVEN_PASSWORD=your-maven-password
export MAVEN_SIGNATURE_SECRET_KEY_ID=your-gpg-key-id
export MAVEN_SIGNATURE_PASSWORD=your-gpg-passphrase
export MAVEN_SIGNATURE_SECRET_KEY=your-gpg-secret-key
```

</Step>
Expand Down