Push Java project to Maven central warehouse practice

The latest open source project Swagger Kubernetes has been written. Considering the successful release to Maven's central warehouse, it is universal in the world. In the process of Maven's pull, there is no problem that Jar package is not available for download. Due to the first time the project was submitted to Maven central warehouse, the online knowledge was uneven until at last a lot of holes were encountered. Here is a record of the practice process.

1, Push project to Github

Create a new project warehouse on Github and push the code to be sent to Maven central warehouse to Github. There is a lot of information in this regard, but there is no more description here.

2, Sign up for a Sonatype account

Enter https://issues.sonatype.org/secure/Dashboard.jspa Sign up for JIRA account and complete personal information as prompted.

3, Log in to Sonatype to create a work order

Login https://issues.sonatype.org/secure/Dashboard.jspa , click the Create button to create a new issues job

The content is as follows. Fill in the required part and wait for approval.

4, Confirm domain name

Wait for a while and you will receive an email with the following content:

[ https://issues.sonatype.org/browse/OSSRH-48958?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Central OSSRH Updated OSSRH-48958:
//Status: Waiting for Response (original value: open)

Do you own the domain mydlq.club? If so, please verify ownership via one of the following methods:
* Add a TXT record to your DNS referencing this JIRA ticket: OSSRH-48958 (Fastest)
* Setup a redirect to your Github page (if it does not already exist)

If you do not own this domain, please read:
You may also choose a groupId that reflects your project hosting, in this case, something like io.github.my-dlq or com.github.my-dlq

Swagger Kubernetes is a program for document aggregation of Swagger standardized service apis in a Kubernetes cluster.

//Key words: OSSRH-48958
URL: https://issues.sonatype.org/browse/OSSRH-48958
//Project: community support - open source project repository housing
//Question type: New Project
//Reported by: mydlq
//Handled by: Joel Orlina
//Priority: important

Swagger Kubernetes is a program for document aggregation of Swagger standardized service apis in a Kubernetes cluster. Service discovery under a Namespace of Kubernetes can be automatically performed. The interface of the Swagger API specification will be integrated and filtered. The service will be delegated to the service by zuul reverse proxy, and the Swagger API information will be aggregated and displayed by the Swagger UI.

It means to ask whether the domain name you set for GroupId is owned by yourself. If so, you need to prove two methods

  • 1. Set github page as domain name.
  • 2. Add a record of type Txt to DNS resolution of domain name.

Because I have my own domain name, I set up the second method to add NDS resolution record. Here, I add the record as OSSRH-48958, the type as TxT, and the value as https://issues.sonatype.org/browse/OSSRH-48958 A parsing record information of.

Then open the address mentioned in the email https://issues.sonatype.org/browse/OSSRH-48958 Enter the issues, reply that you own the domain name, and set DNS resolution.

5, Configure GPG

1. Download GPG

Open https://www.gpg4win.org/ Download the GPG and install it step by step.

After the installation, you will see that there are multiple Kleopatra icons on the desktop. This program is the front-end program of GnuPG. Here we will open it.

2. Configure key pair

After opening Kleopatra, click new key pair

Enter name and email

Finally, confirm to create a new one

In the process, you need to enter a password of more than 8 digits by yourself. Please remember the password, which needs to be used later. The following information will be prompted when the input is complete.

3. Upload public key to GPS key servers

Open the command prompt window and enter the following command to send the certificate to the remote server

gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys  243EFB60D8F930B391CA194EA40663B00BDC6CA1

6, Configuration items

To send the project to Maven central warehouse, you need to set up some settings for the project to meet the release criteria.

1. Configure Strings.xml

Configure the settings.xml file in the conf folder of the maven directory, set a server, and add the account and password of JIRA.

      <username>JIRA Account number</username>
      <password>JIRA Password</password>

2. Configure Pom.xml

Pom.xml configures some necessary information, such as Maven document plug-in, packaging plug-in, GPG validation plug-in, etc., as follows:

You can view my project's GitHub address: Maven sample project , the pom parameter can be modified as required. By the way, click Start star, Thanks.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


    <description>swagger api doc for kubernetes discovery.</description>

    <!--licenses information-->
            <name>The Apache Software License, Version 2.0</name>

    <!--scm information-->

    <!--Publisher information-->



            <!-- doc plugin,Maven API Document generation plug in -->
            <!-- resources plugin,Maven Resource plug-in -->
            <!-- compiler plugin,Maven Compiler plug-in -->
            <!-- gpg plugin,For signature authentication -->
            <!--staging puglin,Used to automate the publish phase(Manual Free)-->
            <!-- release plugin,For publishing to release Warehouse deployment plug-in -->

    <!-- Introduce here Settings.xml User name and password set in -->


3. Set encoding

If Maven compiles doc due to coding errors, you can set the variable Java tool options in the environment variable with a value of UTF-8 to change the coding mode.

  • -Dfile.encoding=UTF-8

7, Send project to Maven central warehouse

1. Log in to Nexus Repositories Manager

It is required to log in to Nexus Repositories before publishing, so log in to Nexus Repositories in advance before publishing

Login https://oss.sonatype.org The user name and password are the user name and password of JIRA.

2. Publish project

Execute the command of maven, deploy the project to Maven warehouse, and enter the GPG password set before in the process. Just enter it.

$ mvn clean deploy

3. View publishing process

Go back to Nexus Repositories Manager, select Staging Repositories, and find the Jar information you submitted according to the release time. Then check the execution information in Actives. Note that the execution and deployment process is now popular and handed over to Maven's auto deployment plug-in for execution. Some old methods on the Internet are to enter here for manual execution, which is not recommended because it is very easy to have problems in deployment.

Note: as can be seen during Maven's release, if the release has been completed, it may not be found in the staging library.

The normal deployment process should be: open phase > close phase > release phase. After the three phases are completed, they will be released to the central warehouse, and will be notified by email

[ https://issues.sonatype.org/browse/OSSRH-48958?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Central OSSRH Updated OSSRH-48958:

Central sync is activated for club.mydlq. After you successfully release, your component will be published to Central, typically within 10 minutes, though updates to search.maven.org can take up to two hours.

It means that the Release is successful, and the Jar information can be found in the central warehouse in about ten minutes or a few, but the update of search.maven.org may take two hours.

4. Reply in Issues completed Release

Submit the Issues address before opening, and the subsequent reply has been released

5. View your published projects

After successful publishing, you can enter https://search.maven.org If you don't find the Jar published by yourself, wait a few hours for this query.

Tags: Maven Kubernetes github Apache

Posted on Mon, 16 Mar 2020 22:00:44 -0700 by Coreyjames25