1)创建您的 Jira 帐户:注册 Sonatype https://issues.sonatype.org/secure/Signup!default.jspa
2)创建一个新的项目票证(以声明您的工作空间):
3)生成 PGP 签名
gpg2 --gen-key
....
gpg: key YOUR_KEY_ID marked as ultimately trusted
...
4)分发您的公钥
gpg2 --keyserver hkp://pool.sks-keyservers.net --send-keys YOUR_KEY_ID
将您的密钥分发到多个服务器以加快同步过程(pgp.mit.edu、keyserver.ubuntu.com...)
5)更新您的 ~.m2/settings.xml
<settings>
<servers>
<server>
<id>ossrh</id>
<username>jira_username</username>
<password>jira_password</password>
</server>
</servers>
<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg2</gpg.executable>
<gpg.passphrase>your_key_passphrase</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
6)更新您的项目 pom.xml
<?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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>9</version>
</parent>
<groupId>xxx.xxx</groupId>
<artifactId>xxx</artifactId>
<version>0.1</version>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</project>
7)运行Maven
Maven 会询问你的密码
mvn clean deploy
8)评论您的 Jira 票证
这将触发与您的组 ID 的中心同步。
我已经推广了我的第一个版本。谢谢。
资源 :
OSSRH 指南 http://central.sonatype.org/pages/ossrh-guide.html#deployment
使用 Maven 进行部署 http://central.sonatype.org/pages/apache-maven.html
PGP 签名 http://central.sonatype.org/pages/working-with-pgp-signatures.html