官网注册账号地址
username不能是中文,不让后面会出问题
一定要选如图的选项
图4.1 |
概要:填你的项目名
groupid:如果gitee上的项目就填io.gitee+下图所示antopen
,如果是公司(有域名和公司邮箱),就填com.公司名称
其他的如
图4.1
所示
意思是说让你创建一个空仓库来验证是不是你本人在操作
创建即可,要设置为开源,gitee现在默认是私有的
创建完成之后点击Respond按钮告诉工作人员已经创建好了
我这里已经成功了,所以没有Respond
按钮
下载并安装GPG:
https://www.gnupg.org/download/index.html
进入bin目录
gpg --gen-key
依次输入姓名和地址,填你注册sonatype的信息就行了
然后让你输入密码(私钥密码
passphrase
)
记住,后面要用
pub ed25519 2023-01-09 [SC] [expires: 2025-01-08]
A4BE13B592B3B38A442170A922D74586719B2B26
uid tset <setset@sdf。com>
sub cv25519 2023-01-09 [E] [expires: 2025-01-08]
A4BE13B592B3B38A442170A922D74586719B2B26
就是你的密钥,记住
gpg --list-keys
存储路径,记住
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys A4BE13B592B3B38A442170A922D74586719B2B26
意思就是上传到
hkp://keyserver.ubuntu.com:11371
中去,然后sonatype也会去这里验证查询发布公钥是否成功
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --recv-keys A4BE13B592B3B38A442170A922D74586719B2B26
出现这样就成功了
<servers>
<server>
<id>ossrhid>
<username>(SonaType账号username)username>
<password>填你注册SonaType时填写的密码password>
server>
servers>
<profiles>
<profile>
<id>ossrhid>
<activation>
<activeByDefault>trueactiveByDefault>
activation>
<properties>
<gpg.executable>D:/gpg/GnuPG/bin/gpg.exegpg.executable>
<gpg.passphrase>填写你生成秘钥时输入的密码gpg.passphrase>
<gpg.homedir>C:/Users/Administrator/AppData/Roaming/gnupggpg.homedir>
properties>
profile>
profiles>
<groupId>io.gitee.antopengroupId>
<artifactId>simple-cacheartifactId>
<version>1.0.0-SNAPSHOTversion>
<name>simple-cachename>
<description>simple cachedescription>
<url>https://gitee.com/antopen/simple-cacheurl>
<licenses>
<license>
<name>The Apache Software License, Version 2.0name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txturl>
license>
licenses>
<developers>
<developer>
<id>masiyiid>
<name>masiyiname>
<email>[email protected]email>
<roles>
<role>Project Managerrole>
<role>Architectrole>
roles>
<timezone>+8timezone>
developer>
developers>
<scm>
<connection>https://gitee.com/antopen/simple-cache.gitconnection>
<developerConnection>scm:git:ssh://[email protected]:antopen/simple-cache.gitdeveloperConnection>
<url>https://gitee.com/antopen/simple-cacheurl>
scm>
<profiles>
<profile>
<id>ossrhid>
<activation>
<activeByDefault>trueactiveByDefault>
activation>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.pluginsgroupId>
<artifactId>nexus-staging-maven-pluginartifactId>
<version>1.6.7version>
<extensions>trueextensions>
<configuration>
<serverId>ossrhserverId>
<nexusUrl>https://s01.oss.sonatype.org/nexusUrl>
<autoReleaseAfterClose>trueautoReleaseAfterClose>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-source-pluginartifactId>
<version>2.2.1version>
<executions>
<execution>
<id>attach-sourcesid>
<goals>
<goal>jar-no-forkgoal>
goals>
execution>
executions>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-javadoc-pluginartifactId>
<version>2.9.1version>
<executions>
<execution>
<id>attach-javadocsid>
<goals>
<goal>jargoal>
goals>
execution>
executions>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-gpg-pluginartifactId>
<version>1.5version>
<executions>
<execution>
<id>sign-artifactsid>
<phase>verifyphase>
<goals>
<goal>signgoal>
goals>
execution>
executions>
plugin>
plugins>
build>
<distributionManagement>
<snapshotRepository>
<id>ossrhid>
<url>https://s01.oss.sonatype.org/content/repositories/snapshotsurl>
snapshotRepository>
<repository>
<id>ossrhid>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/url>
repository>
distributionManagement>
profile>
profiles>
先把上面的注释全部删掉,再上传
然后会弹出对话框让你输入生成gpg时填写的密码
https://s01.oss.sonatype.org/
能找到就是成功了
<!--将原来server标签和profile标签中的的ossrh替换为release-->
<id>release</id>
<groupId>io.gitee.antopen</groupId>
<artifactId>simple-cache</artifactId>
去除-SNAPSHOT后缀
<version>1.0.1</version>
<!--将原来profile标签中的的ossrh替换为release-->
<id>release</id>
<!--移除此发布到中央SNAPSHOT仓库插件,并替换为分割线下面发布到中央release仓库的插件-->
<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://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<!-- 分割线 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
</plugin>
移除
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
替换为
<repository>
<id>release</id>
<url>https://s01.oss.sonatype.org/content/repositories/releases/</url>
</repository>
https://s01.oss.sonatype.org/
都上传成功之后就会收到官方的信息
io.gitee.antopen的中央同步已激活。成功发布后,您的组件将在中央对公众开放https://repo1.maven.org/maven2/,通常在30分钟内,但更新到https://search.maven.org可能需要四个小时。
30分钟后就可以下载,4个小时后就可以在mvn搜索网页可以搜索到
发布出去就改不了了,如果需要bug修复或者版本更新就只需要上传release版本即可
修改版本号,重复上面操作即可
鸣谢:https://blog.csdn.net/lovexiaotaozi/article/details/121989407
希望更多的小伙伴能够参与到开源当中去,这样大家才能进步,社会才会发展