The java project deploys jar s to the maven central repository

Release process overview:
1. Apply for sonatype account creation task
2. Install the gpg key pair and upload the private / key to the central warehouse server
3. Configuration item, maven/ pom configuration
4. Project inspection / release

1, Apply for sonatype account and create application release task

1.1 registered account

Official website: Add link description
Registered address: Add link description

1.2. Create task

Enter the home page and click new

Create task

  • group id, make sure that the domain name corresponding to the group id is yours. It's best to use com.github.wslxm directly according to its prompt. If you have your own official website, you can also use your website directly (you will be asked to verify later)
  • Project address
  • Code management address
  • Code management address

1.3 audit

After filling in, click confirm to submit to ensure that the task is open and waiting for review. The review will send an email notification,
If it does not meet their requirements, it will be set to Unresolved. You can repeatedly modify the relevant configuration information and submit it again for them to handle.

1.4 calibration

For example, my project address is on github. It will let you create a project required by github and submit it here

1.5. Approved / verified

After the approval / verification is passed, the email prompt is as follows. Different replies may be given due to different items

2, GPG installation and key generation

# command
pg --gen-key      # Generate key
gpg --list-keys   # Judge whether the key is generated successfully

1. GPG installation

Download address:
After downloading, you can install it as a fool

Open cmd as an administrator and execute the command gpg --version to determine whether the installation is successful

2. Generate key

Open cmd as Administrator

Execute command: GPG -- Gen key
Enter user name / password

Enter o and the password setting will pop up

Get key

Send the key to the central warehouse server, and then upload it for authentication

gpg --keyserver --send-keys B34ACF782ABE8FD3
gpg --keyserver --recv-keys B34ACF782ABE8FD3

3, Configure the project and upload it

From February 2021, the repository does not support:

Use new address Repository:

Upload the central warehouse address configuration. Pay attention to using the new storage address

3.1. Add account and password configuration of central warehouse in settings.xml

   <!--  Account and password of central warehouse -->

3.2. Add license, source code information, personal information and central warehouse configuration in pom.xml

  <!-- mvn clean deploy  -->
    <!-- licence -->
            <name>The Apache Software License, Version 2.0</name>

    <!-- Source code information -->

    <!-- personal information,corresponding gpg to configure -->
    <!-- Central warehouse configuration id Need to correspond settings.xml of server of id -->

3.3 add packaging configuration to pom.xml

<!-- Packaging configuration -->
            <!-- java-doc to configure -->
                        <configuration> <!-- add this to disable checking -->
            <!-- use source conduct jar pack-->
            <!-- gpg to configure -->

4. Execute command upload to warehouse

Open cmd as an administrator to enter the project command and execute the command. Note that the terminal in the idea editor cannot execute the gpg command and cannot upload

mvn clean deploy

Seeing a lot of successful uploaded information means success

visit: Login to query

4, Verify and publish

4.1. Select the data to verify

4.2. Viewing verification results

If the verification fails, refer to the article:

4.3 click publish

Just wait after the release. You can search the central warehouse in about 4 hours

Tags: Java Maven Spring Boot jar

Posted on Tue, 12 Oct 2021 16:13:30 -0400 by jcran