preamble
This article is based on the official documentation/publish/publish-guide/ Writing.
Publishing Steps:
- Create an account
- Create User Token
- Creating a Namespace
- Configuring the GPG
- Configuration items
- post
Caveats:
- Successfully published items cannot be modified or deleted
preparatory phase
Create an account
If you already have a Google or Github account, you can skip this step and log in directly using their associations.
The steps to create an account are as follows:
-
Open the official website./ Click on the upper right corner of the
Sign In
Then, on the login page that opens, clickSign up
。
Note: The email address should be a real one with verification. -
After successful registration, you will be prompted to verify your email address.
-
Open your mailbox, collect the email, and click
Confirm My Account
Verify Email. -
The page that opens prompts that the e-mail address has been verified, indicating that the registration has been successful.
Create User Token
-
Open the official website./ Click on the upper right corner of the
Sign In
Then enter your username and password directly into the login page that opens, or you can choose to log in directly with your Google or Github affiliation. -
Click on Account in the upper right corner and in the drop down menu select
View Account
。 -
strike (on the keyboard)
Generate User Token
。 -
Then in the dialog box that pops up click
Ok
If you have a Token, it will generate a Token of the following form.<server> <id>${server}</id> <username>0j6XV+5V</username> <password>lSbp/2aMFiSiyzwNstB9zmzo6+5YyLqNHr9JDD8yKC5T</password> </server>
Notice here the
id
The information, which needs to be changed to your customized one, will be used later. Then copy the above content to the file you want to publish the project to use.file, where the
id
The value should readcentral
。<servers> <server> <id>central</id> <username>0j6XV+5V</username> <password>lSbp/2aMFiSiyzwNstB9zmzo6+5YyLqNHr9JDD8yKC5T</password> </server> </servers>
Creating a Namespace
The official website explains the namespace:
Before you can publish your components, you must choose a namespace. In the Maven ecosystem, this is also known as a groupId, which is one of the three required coordinates to describe any component published to Maven Central, . groupId, artifactId, version.
Before publishing a component, you must choose a namespace. In the Maven ecosystem, this is also known as the groupId, and it is one of the three coordinates required to describe any component published to Maven Central - groupId, artifactId, version.
There are two ways to choose your namespace:
-
You own the domain name and can use a reverse domain name for the namespace as follows:
- ->
- ->
- -> -domain
This method requires you to add a specified domain name resolution for the corresponding domain name to verify your ownership of the domain name, which can be deleted after successful verification.
-
You have a code hosting service account from the following list, which can be used as a namespace in the form of a reverse domain name of a personal domain name
Service Example namespace GitHub GitLab Gitee Bitbucket In this way, you need to create a public repository with the specified name under the corresponding account to verify the account ownership, and you can delete it after successful verification.
The steps to create a namespace are as follows:
-
Open the official website./ Click on the upper right corner of the
Sign In
Then enter your username and password directly into the login page that opens, or you can choose to log in directly with your Google or Github affiliation. -
Click on Account in the upper right corner and in the drop down menu select
View Namespaces
。 -
In the page that opens click on
Add Namespace
。 -
Enter the custom Namespace in the pop-up dialog box.
-
After successful creation, the Namespace is shown as pending validation, click the
Verify Namespace
Perform validation. -
The dialog box that pops up will give you different prompts depending on the type of Namespace you fill in. If you fill in a personal domain name for a code hosting service, you will be prompted to go to the corresponding platform to create a public repository with a specified name; if it's a personal domain name, you will be prompted to create a public repository with a specified content of the
TXT
type of domain name resolution. Anyway, you'll get aVerification Key
You need to use this value to do the corresponding operation. Click on the dialog box'sConfirm
button, Namespace becomes Pending Validation:
Choose one of the following two verification methods:- Create a public repository:
- Add domain name resolution:
- Create a public repository:
-
Wait for Namespace to validate successfully, then you can remove the public repository you just created or the domain resolution records you added.
Configuring the GPG
-
Open the official website./download/#sec-1-2Download the corresponding version for your system and install it. Use
gpg --version
Verify that the installation was successful.C:\Users\Administrator>gpg --version gpg (GnuPG) 2.3.8 libgcrypt 1.10.1 Copyright (C) 2021 g10 Code GmbH License GNU GPL-3.0-or-later </licenses/> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Home: C:\Users\Administrator\AppData\Roaming\gnupg Supported algorithms: Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256 AEAD: EAX, OCB Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2
-
utilization
gpg --gen-key
command to generate a key pair, you will be prompted to enter theReal name
cap (a poem)Email address
(It is recommended to enter a real e-mail address to be used later for secret key recovery), after entering it, a pop-up window will ask you to enter a password (Note: This password is used every time you publish a project), then the key pair is generated.
The following content in the5BBA74D9F7E76AAA234ACB337B583099E6B290D8
It's the generated public key, which you need to send to the secret key server next, because other people will need this public key to validate the files you publish.C:\Users\Administrator>gpg --gen-key gpg (GnuPG) 2.3.8; Copyright (C) 2021 g10 Code GmbH This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Note: Use "gpg --full-generate-key" for a full featured key generation dialog. GnuPG needs to construct a user ID to identify your key. Real name: t1 Email address: t1@ You selected this USER-ID: "t1 <t1@>" Change (N)ame, (E)mail, or (O)kay/(Q)uit? O We need to generate a lot of random bytes. It is a good idea to perform some other action (type on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the random number generator a better chance to gain enough entropy. We need to generate a lot of random bytes. It is a good idea to perform some other action (type on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the random number generator a better chance to gain enough entropy. gpg: revocation certificate stored as 'C:\\Users\\Administrator\\AppData\\Roaming\\gnupg\\\\' public and secret key created and signed. pub ed25519 2024-08-26 [SC] [expires: 2026-08-26] 5BBA74D9F7E76AAA234ACB337B583099E6B290D8 uid t1 <t1@> sub cv25519 2024-08-26 [E] [expires: 2026-08-26]
-
utilization
gpg --keyserver --send-keys <public-key>
command to send the public key to the server, if it fails to send, you can choose another server to retry several times, it will always succeed.The GPG key servers supported by the central server are:
# Send public key C:\Users\Administrator>gpg --keyserver --send-keys 5BBA74D9F7E76AAA234ACB337B583099E6B290D8 gpg: sending key 7B583099E6B290D8 to hkp:// # Failed to validate public key C:\Users\Administrator>gpg --keyserver --recv-keys 5BBA74D9F7E76AAA234ACB337B583099E6B290D8 gpg: keyserver receive failed: No data # Verify Public Key Successfully C:\Users\Administrator>gpg --keyserver --recv-keys 5BBA74D9F7E76AAA234ACB337B583099E6B290D8 gpg: key 7B583099E6B290D8: "t1 <t1@>" not changed gpg: Total number processed: 1 gpg: unchanged: 1
Configuration items
Below is a project complete withConfiguration example, you need to make changes based on the actual information of the project:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="/POM/4.0.0"
xmlns:xsi="http:///2001/XMLSchema-instance"
xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.">
<modelVersion>4.0.0</modelVersion>
<groupId></groupId>
<artifactId>no-bug-spring-boot-starter</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>No Bug</name>
<description>Bugdisperse,Bufffill up</description>
<url>/iminghe/no-bug</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>/licenses/LICENSE-2.</url>
</license>
</licenses>
<scm>
<url>/iminghe/no-bug</url>
<connection>scm:git:/iminghe/</connection>
<developerConnection>scm:git:/iminghe/</developerConnection>
</scm>
<developers>
<developer>
<name>minghe</name>
<email>iminghe@</email>
</developer>
</developers>
<properties>
<>8</>
<>8</>
<>UTF-8</>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId></groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.7.18</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId></groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Compiler -->
<plugin>
<groupId></groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${}</source>
<target>${}</target>
<encoding>${}</encoding>
</configuration>
</plugin>
<!-- Source -->
<plugin>
<groupId></groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId></groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.10.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<!-- GPG -->
<plugin>
<groupId></groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId></groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.5.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Description:
-
groupId
: The Namespace certified in the previous steps. -
licenses
: License information for the project. -
scm
:source control system
Source code management system. This part of the element is required if the URL itself does not need to be public. You can specify a URL that is not accessible to the public, or even a placeholder indicating that your SCM URL is private and not suitable for public access. -
developers
: Developer information. -
build
: Packaged public plug-ins. -
profiles
: Define configurations for different environments usingid
As an identifier, it can be used to performmvn
command when selecting the specified environment. This defines therelease
environment is used for project publishing, wherecentral-publishing-maven-plugin
is used to publish the project, wherepublishingServerId
corresponding to the user's Token settingid
。
release phase
existProfiles
decide upon a candidaterelease
and then execute theclean
、deploy
Command.
Alternatively, you can execute it directly from the project directory in your terminal.mvn clean deploy -P release
Wait for the command to finish executing, then log in to the official website, click on Account in the upper right corner, and selectView Deployments
, you will see the items that have been verified to be published.
After confirming that there are no errors, clickPublish
The status will change toPUBLISHING
and then wait a while for the status to change toPUBLISHED
, that means the release was successful, congratulations!