前提条件
- 拥有 groupId 对用域名的配置权限,需要进行 DNS 配置
申请 groupId
- issues.sonatype.org 创建账户,后续发布中央仓库使用的是该账户
- 在 项目下创建 Issue,可参考项目下其他人的申请,如:New group id for ClickHouse Java library
- 之后会收到回复,进行 域名的 DNS 配置
- 这里使用的是 阿里云解析: 云解析DNS > 域名解析 > 解析设置 > 添加记录 > 记录类型:TXT,记录值: Issue 的 Key
- 校验方式:
dig -t TXT framework.kail.xyz
- 最后在 Issue 中回复 DNS 解析完成
gpg
1
2
3
4
5
6
7
8
9
10
|
# 删除
# $ gpg --delete-key [用户ID]
# 生成(生成的时候需要 用户ID、邮箱、密码,这里与 issues.sonatype.org 账户 保持一致)
$ gpg --gen-key
# 查看
$ gpg --list-keys
|
Maven 配置
pom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<licenses>
<license>
<name>MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>
<scm>
<url>https://github.com/kailbin/root-parents</url>
<connection>https://github.com/kailbin/root-parents.git</connection>
<developerConnection>https://github.com/kailbin/root-parents</developerConnection>
</scm>
<developers>
<developer>
<name>kailbin</name>
<email>ykb553@163.com</email>
<url>https://github.com/kailbin</url>
</developer>
</developers>
<profiles>
<!-- Open Source Project Repository Hosting(OSSRH) -->
<profile>
<id>ossrh</id>
<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>
<build>
<plugins>
<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>
</plugins>
</build>
</profile>
</profiles>
|
settings.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<servers>
<!-- 与 distributionManagement 中的 id 对应 -->
<server>
<id>ossrh</id>
<username>[ issues.sonatype.org 账户 ]</username>
<password>[ issues.sonatype.org 密码 ]</password>
</server>
</servers>
<profiles>
<profile>
<id>ossrh</id>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.passphrase>[ gpg 密码 ]</gpg.passphrase>
</properties>
</profile>
</profiles>
|
Deploy
1
2
|
# 激活 ossrh Profile
$ mvn clean deploy -Possrh
|
发布完之后,登陆 https://s01.oss.sonatype.org/ 可以搜到上传的库,但是中央仓库还是都不到的,需要手动进行发布
Release
Read More