上传公钥
https://blog.csdn.net/k3108001263/article/details/89713682
注册并申请
https://issues.sonatype.org/secure/Dashboard.jspa
配置setting.xml
<server>
<id>sonatype-nexus-snapshots</id>
<username>qq275860560</username>
<password>123456</password>
</server>
<server>
<id>sonatype-nexus-staging</id>
<username>qq275860560</username>
<password>123456</password>
</server>
</servers>
其中用户名密码是刚刚注册的账号和密码
配置pom.xml
仿照这个pom文件https://github.com/qq275860560/common/blob/master/pom.xml
其中重点配置
<groupId>com.github.qq275860560</groupId>
<artifactId>github-qq275860560-common</artifactId>
<version>20190508</version>
<packaging>jar</packaging>
<name>github-qq275860560-common</name>
<description>github-qq275860560-common</description>
<url>https://github.com/qq275860560/common</url>
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<scm>
<connection>
scm:git:https://github.com/qq275860560/common.git
</connection>
<developerConnection>
scm:git:https://github.com/qq275860560/common.git
</developerConnection>
<url>https://github.com/qq275860560/common</url>
<tag>master</tag>
</scm>
<developers>
<developer>
<name>qq275860560</name>
<email>jiangyuanlin@163.com</email>
</developer>
</developers>
<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
<!-- -Dgpg.passphrase='秘钥密码'或者-Darguments='gpg.passphrase=秘钥密码' -->
</executions>
</plugin>
发布
项目根目录,执行上传命令
mvn deploy -DskipTests -Dgpg.passphrase='秘钥密码'
release
- 登录 https://oss.sonatype.org/
- 点击左侧栏"Staging Repositories"
- 右上角搜索groupId,比如com.github.qq275860560
- 选中构件并点击 close
- 点击 tab 栏的 release
审核
让工作人员审核
https://issues.sonatype.org/secure/Dashboard.jspa