1.github上上傳專案(略)
2.在sonatype上注冊賬號
https://issues.sonatype.org/secure/Dashboard.jspa
注意記住用戶名和密碼
3.在sonatype創建問題
4.新建完后客服會給提示
主要是要求:groupId要合理,需要按照要求在github上創建空倉庫,做完這些后,然后修改狀態為打開即可,
5.審核成功后會發郵件通知,狀態顯示為已解決
6.專案修改groupId為上方指定的groupId
7.修改maven的setting.xml配置
<servers> <server> <id>ossrh</id> <username>sonatype用戶名</username> <password>sonatype登錄密碼</password> </server> </servers>
8.修改pom.xml配置
<!-- 部署配置 --> <distributionManagement> <snapshotRepository> <id>ossrh</id> <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url> </snapshotRepository> <repository> <id>ossrh</id> <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> </distributionManagement>
9. 打包上傳
mvn clean install
mvn deploy
10.在倉庫上查看快照版的jar包是否上傳成功
打開:https://s01.oss.sonatype.org/
11.發布正式版
批量修改版本號:
mvn versions:set -DnewVersion=1.0.0
部署:
mvn clean deploy
12.在sonatype上查看暫存版
13.解決問題后放開進一步發布到正式版
主要要解決檔案簽名問題,給檔案生成簽名檔案
下載gpg4win: https://www.gpg4win.org/download.html
安裝后,生成證書,發布到服務器等
參考:https://blog.csdn.net/ooyyaa6561/article/details/124900977
14.gpg相關配置
setting.xml配置
<profile> <id>ossrh</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <gpg.executable>gpg</gpg.executable> <gpg.passphrase>密碼</gpg.passphrase> </properties> </profile>
pom.xml配置
<profiles> <profile> <id>release</id> <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>3.0.1</version> <executions> <execution> <id>sign-artifacts</id> <phase>verify</phase> <goals> <goal>sign</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles>
15. 運行打包部署命令
指定release這個profile運行
打包
mvn clean install -P release
部署
mvn clean deploy -P release
16. 及時發布
close后,會給問題反饋,沒問題后,點擊Release
17.jar包拉取驗證
sonatype倉庫驗證:在pom.xml中添加倉庫
<repository> <id>nexues</id> <name>snapshots</name> <url>https://s01.oss.sonatype.org/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository>
然后添加maven依賴配置
快照版和正式版均可以下載,正式版優先級高!
maven中央倉庫驗證:
setting.xml檔案無需配置,默認就可以直連maven中央倉庫,直接引入依賴即可
<!-- openapi服務端sdk --> <dependency> <groupId>io.github.hdwang123</groupId> <artifactId>openapi-server-sdk</artifactId> <version>1.0.0</version> </dependency> <!-- openapi客戶端sdk --> <dependency> <groupId>io.github.hdwang123</groupId> <artifactId>openapi-client-sdk</artifactId> <version>1.0.0</version> </dependency>
經過大約4個小時終于收到成功的郵件,驗證果然成功了,下面是郵件截圖
遇到的問題:
gpg插件無法運行
解決:1.安裝完gpg4win后需要重啟電腦,切記 2. setting.xml中的命令可能是gpg而非gpg2
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/482123.html
標籤:Java
上一篇:eclipse取消自動生成package-info.java
下一篇:返回列表