1.準備工作
1.1 進入系統注冊賬號
https://central.sonatype.com/
點擊右上角 Sign-in登錄
如果是首次登陸,需要點擊Sign-Up注冊賬號
2.命名空間管理
2.1 注冊Namespaces
點擊右上角自己的賬號->選中View Namespaces
進入命名空間列表后,點擊Add Namespace,然后輸入自己的命名空間名稱
注:此處的命名空間名稱對應的是自己項目里的GroupId
如果命名空間是之前JIRA系統存在,則參考第4章請求官方協助數據遷移。
2.2 校驗Namespaces
按照提示完成域名身份校驗
To prove the ownership of this Namespace, a DNS TXT Record is required with the same value that matches its Verification Key(ticket-123).For the Namespace org.spring.io you will need to create TXT Record:
ticket-123
Domain Registrars services have different procedures for adding a TXT Record, please check your registers documentation to find out how to add a TXT Record.
注意:此處添加TXT記錄時,主機記錄為:@,記錄值為:ticket-123
添加成功后,打開如下地址驗證域名baidu.com*(改成你自己的域名)*
https://www.whatsmydns.net/dns-lookup/txt-records?query=baidu.com&server=google
如果DNS記錄可以查到,說明配置成功,就可以完成校驗
TXT records for baidu.com:
Record | Type | Value | TTL |
---|---|---|---|
baidu.com | TXT | “ticket-123” | 499 |
3.Maven發布
3.1 啟用Token用戶
選擇 View Account,然后點擊Generate User Token,即可生成maven發布專用用戶。
3.2 GPG證書申請
參考文章
3.3 Maven pom 添加配置 (以Github Action方式正常運行)
<profiles><profile><id>release</id><build><plugins><plugin><groupId>org.sonatype.central</groupId><artifactId>central-publishing-maven-plugin</artifactId><version>0.5.0</version><extensions>true</extensions><configuration><publishingServerId>central</publishingServerId><autoPublish>true</autoPublish></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><version>3.3.0</version><executions><execution><id>attach-sources</id><phase>verify</phase><goals><goal>jar-no-fork</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-javadoc-plugin</artifactId><version>3.6.3</version><executions><execution><id>attach-javadoc</id><goals><goal>jar</goal></goals></execution></executions><configuration><stylesheet>java</stylesheet><doclint>none</doclint></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-gpg-plugin</artifactId><version>3.1.0</version><executions><execution><id>sign-artifacts</id><phase>verify</phase><goals><goal>sign</goal></goals></execution></executions><configuration><gpgArguments><arg>--pinentry-mode</arg><arg>loopback</arg></gpgArguments></configuration></plugin></plugins></build></profile></profiles><build><plugins><plugin><groupId>org.sonatype.central</groupId><artifactId>central-publishing-maven-plugin</artifactId><version>0.5.0</version><extensions>true</extensions><configuration><publishingServerId>central</publishingServerId><autoPublish>true</autoPublish></configuration></plugin></plugins></build>
3.4 Github Action腳本
name: Publish package to the Maven Central Repository
on:release:types: [created]
jobs:publish:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v4- name: Set up Maven Central Repositoryuses: actions/setup-java@v4with:java-version: '8'distribution: 'temurin'server-id: centralserver-username: MAVEN_USERNAMEserver-password: MAVEN_PASSWORDgpg-private-key: ${{ secrets.GPG_SECRET }}gpg-passphrase: MAVEN_GPG_PASSPHRASE- name: Publish packagerun: mvn -P release --batch-mode deploy -DskipTestsenv:MAVEN_USERNAME: ${{ secrets.OSSRH_USER }}MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }}
Github Action secrets 如何使用請自行度娘。
4.JIAR 數據遷移
4.1 使用郵箱注冊賬號
如果你還記得JIRA注冊時使用的郵箱,可以使用該郵箱聯系central-support@sonatype.com
如果不記得JIRA注冊時使用的郵箱,則需要使用已經注冊的新賬號綁定的郵箱聯系官方通過DNS方式驗證身份后,官方會協助遷移通過DNS驗證的域名。
4.2 協助溝通郵件記錄(新郵箱)
確認自己身份,請求協助
I’M authorized publisher. , but my old email : xxx can’t login.
I have login in new system by username & password ,
can provide other ways to check authorized publisher. ,eg: doamin add txt record
you can provide String code , I Add txt record to config.
獲得官方回復
Hello,
Can you do the following:
- Create a user for xxx on https://central.sonatype.com/
- add the Domain TXT record ticket-12345 to com.baidu
此處com.baidu就是之前JIRA系統申請GroupId時使用的域名,新系統只需要注冊一次即可,不用每個GroupId單獨申請
Regards,
The Central Team
接下來我們只需要按照2.2章節配置DNS,然后給官方發送郵件
hello ,Try again
I have correctly configured the domain name Txt record for :baidu.com
https://www.whatsmydns.net/dns-lookup/txt-records?query=baidu.com&server=google
接下來我們就等候官方回復郵件
Hello ,
Apologies for the confusion, we are up to date on the thread.
We migrated your namespace as requested:
- your user account on s01.oss.sonatype.org can no longer be used to create deployments for the com.baidu namespace
- your account on central.sonatype.com associated with 你的新郵箱 has been updated to include the com.baidu namespace
Please login to Central Portal and confirm you see com.baidu as verified under your list of namespaces. After this you could follow the publishing instructions in our documentation to publish your components.
If you have any other question please feel free open a new request.
Thank you,
The Central Team
看到這個郵件后,我們就可以使用新賬號登錄新系統,然后看到對應的namespace官方已經幫我們
遷移到新賬號下面了。
4.3 如果需要使用JIAR繼續發布的參考如下步驟(供參考未驗證)
若是在2024年6月前還正常上傳, 在6月突然不行了. 很大原因是原來使用用戶名,密碼,現要在使用token了.
將maven的settings.xml,
ossrh username password改為:
ossrh token-username token-password問題是如何創建token的name及password.
使用原JIRA賬號登錄舊的url,并在以下地址,創建token即可.
https://oss.sonatype.org/#profile;User%20Token