Skip to content

Commit a3fe4dc

Browse files
Update MavenCentral documentation (#334)
Updated the MavenCentral documentation by fixing minor typos, fixing the table of contents links, adjusting the capitalization of some words, and adding a few additional details for clarification.
1 parent 70c8709 commit a3fe4dc

1 file changed

Lines changed: 54 additions & 51 deletions

File tree

documentation/MavenCentral.md

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,92 @@
11
# Deploying to Maven Central
2-
## Table of contents
2+
## Table of Contents
33
1. [Introduction](#introduction)
4-
2. [Prerequisites](#Prerequisites)
5-
3. [GitHub Configuration](#GitHubConfiguration)
6-
1. [GitHub Actions Secrets](#GitHubActionSecrets)
7-
1. [List of Secrets](#GitHubActionSecretsList)
8-
2. [Purpose of Each Secret](#GitHubActionSecretsPurpose)
9-
2. [GitHub Actions Workflow](#GitHubActionsWorkflow)
10-
1. [Workflow Description](#GitHubActionsWorkflowDescription)
11-
3. [Maven Pom File Configuration](#MavenConfig)
12-
1. [Required Plugins](#MavenReqPlugins)
13-
1. [Plugin Descriptions](#MavenReqPluginsDescriptions)
14-
1. [Plugin Configurations](#MavenReqPluginsConfigurations)
4+
2. [Prerequisites](#prerequisites)
5+
3. [GitHub Configuration](#github-configuration)
6+
1. [GitHub Actions Secrets](#github-actions-secrets)
7+
1. [List of Secrets](#list-of-secrets)
8+
2. [Purpose of Each Secret](#purpose-of-each-secret)
9+
2. [GitHub Actions Workflow](#github-actions-workflow)
10+
1. [Workflow Description](#workflow-description)
11+
3. [Maven POM File Configuration](#maven-pom-file-configuration)
12+
1. [Required Plugins](#required-plugins)
13+
2. [Plugin Descriptions](#plugin-descriptions)
14+
3. [Plugin Configurations](#plugin-configurations)
1515

1616

1717
## Introduction <a name="introduction"></a>
18-
Deploying to Maven Central is currently an automated process, but the steps are a bit of a black box that deserves some level of explanation in the event there is a need to update it or change it and the original author is no longer around.
18+
Deploying to Maven Central is currently an automated process, but the steps are a bit of a black box that deserve some level of explanation in the event there is a need to update it or change it and the original author is no longer around.
1919

20-
## Prerequisites <a name="Prerequisites"></a>
20+
## Prerequisites <a name="prerequisites"></a>
2121
There are a couple things you will need to do before attempting to deploy to Maven Central.
2222
1. You will need an account on Maven Central: https://central.sonatype.com/
23-
1. You will also need to be added to the `gov.hhs.aspr.ms group`. To be added to the group, a current member of the group (currently Zach Bischoff, Shawn Hatch and David Durham) must send an email to central-support@sonatype.com requesting your account be added to the gov.hhs.aspr.ms group.
23+
1. You will also need to be added to the `gov.hhs.aspr.ms` group. To be added to the group, a current member of the group (currently Zachary Bischoff, Shawn Hatch, and David Durham) must send an email to central-support@sonatype.com requesting your account be added to the `gov.hhs.aspr.ms` group.
2424
2. You will need to generate a user token: https://central.sonatype.org/publish/generate-portal-token/
25-
3. You will need your maven central username. **NOTE** that this is *NOT* the username you sign in with. It is different. It will be displayed when you generate a token in the previous step
26-
2. You need a signed pgp key. Instructions can be found here: https://central.sonatype.org/publish/requirements/gpg
25+
3. You will need your Maven Central username. **NOTE** that this is *NOT* the username you sign in with. It is different. It will be displayed when you generate a token in the previous step
26+
2. You need a signed PGP key. Instructions can be found here: https://central.sonatype.org/publish/requirements/gpg
2727

2828

29-
## GitHub Configuration <a name="GitHubConfiguration"></a>
30-
### GitHub Actions Secrets <a name="GitHubActionSecrets"></a>
31-
#### List of Secrets <a name="GitHubActionSecretsList"></a>
32-
Each repository that we control has the following Secrets Defined under Settings -> Security -> Secrets and Variables -> Actions:
29+
## GitHub Configuration <a name="github-configuration"></a>
30+
### GitHub Actions Secrets <a name="github-actions-secrets"></a>
31+
#### List of Secrets <a name="list-of-secrets"></a>
32+
Each repository that we control has the following secrets defined under Settings -> Security -> Secrets and Variables -> Actions:
3333

3434
1. GHA_BOT
3535
2. GPG_SECRET_KEY
3636
3. GPG_SECRET_KEY_PASSWORD
3737
4. MAVEN_CENTRAL_TOKEN
3838
5. MAVEN_CENTRAL_USERNAME
39-
#### Purpose of Each Secret <a name="GitHubActionSecretsPurpose"></a>
39+
#### Purpose of Each Secret <a name="purpose-of-each-secret"></a>
4040
Each secret serves a purpose for enabling the auto deployment to Maven Central when a new version is pushed to the main branch.
4141
1. GHA_BOT
42-
- This is a Personal access token (Currently generated under Zach Bischoff’s github account) that allows an upstream GitHub Action workflow to commit and push to a downstream GitHub Repo. (ie Allows ASPR-8 GitHub Action to commit and push to aspr-ms-gcm-taskit repo)
42+
- This is a Personal Access Token (currently generated under Zachary Bischoff’s GitHub account) that allows an upstream GitHub Actions workflow to commit and push to a downstream GitHub repo (i.e., allows ASPR-8 GitHub Actions workflows to commit and push to aspr-ms-gcm-taskit repo). Instructions can be found here: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token
4343
2. GPG_SECRET_KEY
44-
- From the prerequisites step 2, this is the secret key that you made. (Currently this is a key that Zachary Bischoff made, and it expires in 2027). This serves as the key to sign the artifacts from the maven build prior to uploading them to Maven Central. The signing of the artifacts is REQUIRED.
44+
- From the prerequisites step 2, this is the secret key that you made. (Currently this is a key that Zachary Bischoff made, and it expires in 2027). This serves as the key to sign the artifacts from the Maven build prior to uploading them to Maven Central. The signing of the artifacts is REQUIRED.
4545
3. GPG_SECRET_KEY_PASSWORD
4646
- Same as above, but the signing key requires a password, and that is the value of this field. The current password is known by Zachary Bischoff. The password is unique to the specific secret key but can be the same over various keys.
4747
4. MAVEN_CENTRAL_TOKEN
48-
- The user token from prerequisites step 1b. Currently this is generated by Zachary Bischoff. This serves as the password for authenticating to Maven Central for purposes of publishing.
48+
- The user token from prerequisites step 1.ii. Currently this is generated by Zachary Bischoff. This serves as the password for authenticating to Maven Central for purposes of publishing.
4949
5. MAVEN_CENTRAL_USERNAME
50-
- The username from prerequisites step 1c. Currently this is generated by Zachary Bischoff. This serves as the username for authenticating to Maven Central for purposes of publishing.
50+
- The username from prerequisites step 1.iii. Currently this is generated by Zachary Bischoff. This serves as the username for authenticating to Maven Central for purposes of publishing.
5151

5252

53-
### GitHub Actions Workflow <a name="GitHubActionsWorkflow"></a>
54-
When pushing a new version to the main branch, a Github action workflow runs. This action is defined in the `.github/workflows/release_build.yml` file in the repo.
55-
#### Workflow Description <a name="GitHubActionsWorkflowDescription"></a>
53+
### GitHub Actions Workflow <a name="github-actions-workflow"></a>
54+
When pushing a new version to the main branch, a GitHub Actions workflow runs. This workflow is defined in the `.github/workflows/release_build.yml` file in the repo.
55+
#### Workflow Description <a name="workflow-description"></a>
5656
The workflow does the following, in the following order:
5757
1. Checkout the repo on the main branch
58-
2. Setup up Java and Maven
58+
2. Set up Java and Maven
5959
- This includes setting the MAVEN_CENTRAL_TOKEN, MAVEN_CENTRAL_USERNAME, GPG_SECRET_KEY and GPG_SECRET_KEY_PASSWORD
60-
3. run the command `mvn deploy -Pjavadoc,sign --file pom.xml`
60+
3. Run the command `mvn clean deploy -Pjavadoc,sign --file pom.xml`
61+
- clean will remove previous build artifacts, ensuring a clean slate for the current build
6162
- deploy will trigger the deployment to Maven Central
62-
- -Pjavadoc will generate javadocs, this is required for Maven Central Deployment
63-
- -Psign will sign all of the generated files, this is required for Maven Central Deployment
64-
- --file just signifies which pom file to run the maven command against, in this case, the pom.xml in the root directory of the repo
65-
4. Get the version of the software and save it to an enviroment variable by running the command `echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout --file pom.xml)" >> "$GITHUB_ENV"`
66-
5. Create a Github Release using the version from step 4 and the files generated by step 3.
63+
- -Pjavadoc will generate javadocs, this is required for Maven Central deployment
64+
- -sign will sign all of the generated files, this is required for Maven Central deployment
65+
- --file just signifies which POM file to run the Maven command against, in this case, the pom.xml in the root directory of the repo
66+
4. Get the version of the software and save it to an environment variable by running the command `echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout --file pom.xml)" >> "$GITHUB_ENV"`
67+
5. Create a GitHub Release using the version from step 4 and the files generated by step 3.
6768

68-
## Maven Pom File Configuration <a name="MavenConfig"></a>
69-
### Required Plugins <a name="MavenReqPlugins"></a>
70-
To Deploy to Maven Central, you need the Plugins defined in the publish requirements on https://central.sonatype.org/publish/requirements. At a minimum you need the `maven-gpg-plugin`, `maven-javadoc-plugin`, `maven-source-plugin` and `central-publishing-maven-plugin`. The `flatten-maven-plugin` is helpful but not required.
71-
### Plugin Descriptions <a name="MavenReqPluginsDescriptions"></a>
72-
- `flatten-maven-plugin` creates a flattened version of the pom file, with all dependencies including transitive dependencies
73-
- `maven-source-plugin` creates the sources jar file
74-
- `maven-javadoc-plugin` creates the javadoc jar file
75-
- `maven-gpg-plugin` signs all created files, jar, source jar, javadoc jar, and pom file
76-
### Plugin Configurations <a name="MavenReqPluginsConfigurations"></a>
77-
- `flatten-maven-plugin` use the `<flattenMode>ossrh</flattenMode>` to create a pom file adequate for deployment to Maven Central
78-
- `maven-source-plugin` use the goal `jar-no-fork`
79-
- `maven-javadoc-plugin` use `<doclint>all,-missing</doclint>`, add any additional dependencies and add the following:
69+
## Maven POM File Configuration <a name="maven-pom-file-configuration"></a>
70+
### Required Plugins <a name="required-plugins"></a>
71+
To deploy to Maven Central, you need to meet the publishing requirements defined at https://central.sonatype.org/publish/requirements. At a minimum, you will need the `maven-source-plugin`, `maven-javadoc-plugin`, `maven-gpg-plugin`, and `central-publishing-maven-plugin`. The `flatten-maven-plugin` is helpful but not required.
72+
### Plugin Descriptions <a name="plugin-descriptions"></a>
73+
- `flatten-maven-plugin` creates a flattened version of the POM file, with all dependencies including transitive dependencies
74+
- `maven-source-plugin` creates the sources JAR file
75+
- `maven-javadoc-plugin` creates the Javadoc JAR file
76+
- `maven-gpg-plugin` signs all created files: main JAR, sources JAR, Javadoc JAR, and POM file
77+
- `central-publishing-maven-plugin` publishes all signed files to Maven Central
78+
### Plugin Configurations <a name="plugin-configurations"></a>
79+
- `flatten-maven-plugin` use the `<flattenMode>ossrh</flattenMode>` to create a POM file adequate for deployment to Maven Central
80+
- `maven-source-plugin` use the goal `jar-no-fork` to create the sources JAR without starting a separate build process
81+
- `maven-javadoc-plugin`
82+
- use `<doclint>all,-missing</doclint>` to validate all existing javadocs and not generate warnings for missing javadocs
83+
- add any additional dependencies, like `junit-jupiter-api` (which prevents Javadoc errors related to JUnit)
84+
- add the following to ensure that as many errors and warnings are found as possible in a single execution:
8085
```
8186
<additionalJOptions>
8287
<additionalJOption>-Xmaxerrs</additionalJOption>
8388
<additionalJOption>65536</additionalJOption>
8489
<additionalJOption>-Xmaxwarns</additionalJOption>
8590
<additionalJOption>65536</additionalJOption>
8691
</additionalJOptions>
87-
```
88-
To esnure that as many errors and warnings are found as possible in a single execution
89-
92+
```

0 commit comments

Comments
 (0)