Usually develop their own tool classes or other framework JAR packages are generally placed in the local. Or upload the code to Github for someone else to download and package it yourself. Today, I’ll show you how to publish your JAR packages to Maven’s central repository. Let others who use your JAR package go directly to the central repository to download it. If you are using AliYun’s Maven central repository. Also, ali Cloud’s central repository will synchronize your JAR packages.
1 Register a JIRA account
Registered address: issues.sonatype.org/secure/Dash…
2 create issue
These are all filled out! The Project URL and SCM URL can be filled in the address of your Github Project and the Group ID can be filled in according to your own needs. For example, I filled in com.github. MXSM. Generally within one working day, when the Issue Status changes to RESOLVED, the next step can be taken, otherwise, wait… (It’s best if you do this at night when you work abroad.)
This means that you are ready to upload your own JAR package
3 Configure the Maven setting. XML file
Adding a Server Node
<server> < ID > Replace by yourself </id> <username> Replace by your JIRA account </username> <password> Replace by your JIRA account password </password> </server>Copy the code
4 Create a Maven project
Set up the POM.xml file
The < 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" > < modelVersion > 4.0.0 < / modelVersion > < groupId > com. Making. MXSM < / groupId > < artifactId > dubbotest < / artifactId > < version > 1.0 < / version > < packaging > jar < / packaging > < name > dubbotest < / name > < url > https://github.com/mxsm < / url > <description>dubbotest com.github.mxsm jar</description> <licenses> <license> <name>Apache 2</name> The < url > http://www.apache.org/licenses/LICENSE-2.0.txt < / url > < distribution > '< / distribution > < comments > A business-friendly OSS license</comments> </license> </licenses> <scm> <url>https://github.com/mxsm</url> <connection>https://github.com/mxsm/taokeeper.git</connection> </scm> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId> <artifactId>junit</ groupId> <artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> < version > 4.3.10. RELEASE < / version > < / dependency > < the dependency > < groupId > com. Alibaba < / groupId > <artifactId>dubbo</artifactId> <version>2.5.3</version> </dependency> </dependencies> <developers> <developer> <name>ljbmxsm</name> <id>ljbmxsm</id> <email>[email protected]</email> <roles> <role>Developer</role> </roles> <timezone>+8</timezone> </developer> </developers> <profiles> <profile> <id>release</id> <! <build> <plugins> <! -- Source --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>2.2.1</version> <executions> <phase>package</phase> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin> <! -- Javadoc --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.9.1</version> <executions> <phase>package</phase> < Goals > <goal>jar</goal> </execution> </executions> </plugin> <! -- GPG --> <plugin> <! Plugins </groupId> <artifactId> Maven -gpg-plugin</artifactId> <version>1.6</version> <executions> <execution> <phase>verify</phase> <goals> <goal>sign</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <distributionManagement> <snapshotRepository> <id>oss</id> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> </snapshotRepository> <repository> <id>oss</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> </distributionManagement> </profile> </profiles> </project>Copy the code
Required: Name URL description Licenses SCM
<distributionManagement> <snapshotRepository> <id>oss</id><! -- Settings. The XML node id of the server - > < url > https://oss.sonatype.org/content/repositories/snapshots/ < / url > < / snapshotRepository > <repository> <id>oss</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> </distributionManagement>Copy the code
5 Install GPG4Win in Windows
Download address:www.gpg4win.org/download.ht…View version:
$GPG --gen-key GPG (GnuPG) 1.4.19; Copyright (C) 2015 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Please select what kind of key you want: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (sign only) (4) RSA (sign only) Your selection? RSA keys may be between 1024 and 4096 bits long. What keysize do you want? (2048) Requested keysize is 2048 bits Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) Key does not expire at all Is this correct? (y/N) Y You need a user ID to identify your key; the software constructs the user ID from the Real Name, Comment and Email Address in this form: "Heinrich Heine (Der Dichter) <[email protected]>" Real name: ljbmxsm Email address: [email protected] Comment: flink-elasticsearch-connector You selected this USER-ID: "iteblog (flink-elasticsearch-connector) <[email protected]>" Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O You need a Passphrase to protect your secret key. 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: /c/Users/iteblog/.gnupg/trustdb.gpg: trustdb created gpg: key B15C5AA3 marked as ultimately trusted public and secret key created and signed.Copy the code
Set the name + mailbox, otherwise use the default values, remember the passphrase input, will be used later in the deployment
6 Uploading a Key
Upload the secret key you just generated
Upload command
GPG -- keyserver hkp://keyserver.ubuntu.com: 11371 - send - keys CF21873A - GPG -- keyserver uploaded to the server hkp://keyserver.ubuntu.com: 11371 - recv - keys CF21873A -- see if upload the wholeCopy the code
- pool.sks-keyservers.net
- keys.openpgp.org
- keyserver.ubuntu.com
Main: keyserver.ubuntu.com: 11371 this is available now, before the Internet pool.sks-keyservers.net anyway I uploaded successfully but behind validation when not to use this address. Perform the deployment
mvn clean deploy -P release
Copy the code
Release < ID >release
this. If reported on Centos8
The signature failed. Procedure GPG. Conf and gpg-agent.conf files are created in the. Gnupg directory of GPG
Then add to gpg.conf:
use-agent
pinentry-mode loopback
Copy the code
Add the following to gpg-agent.conf:
allow-loopback-pinentry
Copy the code
7 Log in to the website to view information
Address: oss.sonatype.org That’s where the username and password are registered.
A) After the component is ready, upload the build from the command line;
B) “close” and “release” components at oss.sonatype.org/;
C) Wait for good synchronization (about 2 hours), it can be used
8 Notifying the Administrator
Go to the websiteissues.sonatype.orgLog in to notify your admin and waitAnd then it’s all done here. All that was left was to wait for sync to the central repository to see a result I posted myself:
Check out the central warehouseSearch.maven.org (central warehouse after 2 hours)
If you have any questions, please contact me at [email protected] or QQ :375808041