发布
发布到Maven 中央仓库
将
<!-- https://mvnrepository.com/artifact/com.fundebug/fundebug-java -->
<dependency>
<groupId>com.fundebug</groupId>
<artifactId>fundebug-java</artifactId>
<version>0.2.0</version>
</dependency>
但是,
其中,最”简单”的方式是通过Sonatype OSSRH仓库来发布
本教程所使用的系统配置如下:
- OS:macOS 10.14.2
- JDK:1.8.0_192
- Maven:3.5.4
1. 注册JIRA 账号
注册地址:https://issues.sonatype.org/secure/Signup!default.jspa
需要填写
2. 创建issue
通过在
创建链接:https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134

创建
- Summary
- Description
- Group Id
- Project URL
- SCM url
大家可以参考我申请发布fundebug-java与fundebug-spring时所填写的内容:OSSRH-45238
由于时差,前一天创建
3. 安装并配置GPG
发布到
安装
生成
gpg --gen-key
生成密钥时将需要输入
上传
将公钥上传到公共的密钥服务器,这样其他人才可以通过公钥来验证
gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys CAB4165C69B699D989D2A62BD74A11D3F9F41243
其中
gpg --list-keys
/Users/kiwenlau/.gnupg/pubring.kbx
----------------------------------
pub dsa2048 2010-08-19 [SC] [expires: 2020-06-15]
85E38F69046B44C1EC9FB07B76D78F0500D026C4
uid [ unknown] GPGTools Team <team@gpgtools.org>
sub elg2048 2010-08-19 [E] [expires: 2020-06-15]
sub rsa4096 2014-04-08 [S] [expires: 2024-01-02]
pub rsa2048 2019-01-03 [SC] [expires: 2021-01-02]
CAB4165C69B699D989D2A62BD74A11D3F9F41243
uid [ultimate] kiwenlau <kiwenlau@gmail.com>
sub rsa2048 2019-01-03 [E] [expires: 2021-01-02]
4. 配置Maven 的setting.xml
setting.xml为
<servers>
<server>
<id>ossrh</id>
<username>Fundebug</username>
<password>passsword</password>
</server>
</servers>
5. 配置项目的pom.xml
- Supply Javadoc and Sources
- Sign Files with GPG/PGP
- Sufficient Metadata
- Correct Coordinates
- Project Name, Description and URL
- License Information
- Developer Information
- SCM Information
配置时参考我的
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.fundebug</groupId>
<artifactId>fundebug-java-notifier</artifactId>
<version>0.2.0</version>
<packaging>pom</packaging>
<name>fundebug-java-notifier</name>
<url>https://github.com/Fundebug/fundebug-java-notifier</url>
<description>Capture Java and Spring exceptions automatically</description>
<licenses>
<license>
<name>Server Side Public License</name>
<url>https://www.mongodb.com/licensing/server-side-public-license</url>
<distribution>repo</distribution>
<comments>A not business-friendly OSS license</comments>
</license>
</licenses>
<scm>
<url>https://github.com/Fundebug/fundebug-java-notifier</url>
<connection>https://github.com/Fundebug/fundebug-java-notifier.git</connection>
</scm>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<developers>
<developer>
<name>kiwenlau</name>
<id>kiwenlau</id>
<email>kiwenlau@gmail.com</email>
<roles>
<role>Developer</role>
</roles>
<timezone>+8</timezone>
</developer>
</developers>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>package</phase>
<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>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</profile>
</profiles>
<modules>
<module>fundebug-java</module>
<module>fundebug-spring</module>
<module>examples/hello-world</module>
<module>examples/spring-rest-api</module>
</modules>
</project>
6. 发布jar 包
执行
mvn clean deploy -projects fundebug-java,fundebug-spring
我们的项目fundebug-java-notifier含有多个模块,仅需部署
第一次执行
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] fundebug-java 0.2.0 ................................ SUCCESS [ 22.183 s]
[INFO] fundebug-spring 0.2.0 .............................. SUCCESS [ 16.383 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 38.728 s
[INFO] Finished at: 2019-01-12T20:10:16+08:00
[INFO] ------------------------------------------------------------------------
7. close 并release

选中对于的
