-
Notifications
You must be signed in to change notification settings - Fork 1
Maven 公网发布
Kervin edited this page Jul 5, 2021
·
1 revision
- 注册一个 Sonatype用户
https://blog.csdn.net/qiujuer/article/details/44195199 https://blog.csdn.net/ssrc0604hx/article/details/51513414/ http://www.cnblogs.com/gaoxing/p/4359795.html
- 创建一个发布构件的 Issue
- pom.xml配置
<profiles>
<profile>
<id>sonatype-oss-release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<distributionManagement>
<!-- <repository>
<id>central</id>
<url>http://central.maven.org/maven2/</url>
</repository> -->
<repository>
<id>Sonatype</id>
<!-- <url>https://oss.sonatype.org/content/repositories/releases/</url> -->
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
<id>Sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
注意profile/distributionManagement中ID部分,发布时使用 4. setting.xml
<server>
<id>Sonatype</id>
<username>Sonatype账号</username>
<password>Sonatype密码</password>
</server>
id对应pom中distributionManagement的ID
- 下载 Gpg4win软件来生成密钥对
- 安装Gpg4win生产秘钥
- 1)gpg --version
- 2)gpg --gen-key 输入Sonatype用户名、邮箱、选择**(O)key**?O
- 3)输入秘钥Passphase,记住秘钥发布使用
- 4)gpg --list-keys 查看加密key(秘钥后8位)
C:/Users/yi.zhang>gpg --list-keys
C:/Users/yi.zhang/AppData/Roaming/gnupg/pubring.kbx
---------------------------------------------------
pub rsa2048 2017-11-09 [SC] [expires: 2019-11-09]
647D43AD8D1F22F10D98FC021D85B2632C87E20A
uid [ultimate] ukelink <yi.zhang@ucloudlin
sub rsa2048 2017-11-09 [E] [expires: 2019-11-09]
pub rsa2048 2017-11-10 [SC] [expires: 2019-11-10]
A68D7924C3577D648C4115E065CFDF3B897F0364
uid [ultimate] ukelink <yi.zhang@ucloudlin
sub rsa2048 2017-11-10 [E] [expires: 2019-11-10]
- 5)上传秘钥
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys 2C87E20A
gpg --keyserver hkp://pool.sks-keyservers.net --send-keys 897F0364
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys 897F0364
gpg --keyserver hkp://pool.sks-keyservers.net --send-keys 2C87E20A
可以网络查看秘钥
- 发布jar包
mvn clean deploy -P sonatype-oss-release
-P后对应pom中profile的ID,然后弹出签名输入对应过期时间Passphase
以后的发布流程:
- a)构件准备好之后,在命令行上传构建;
- b)在https://oss.sonatype.org/ “close”并“release”构件;
- c)等待同步好(大约2小时多)之后,就可以使用了