Maven 中央仓库并不支持直接上传 jar 包,所以须要将 jar 包发布到一些指定的第三方 Maven 仓库,好比:Sonatype OSSRH 仓库,而后该仓库再将 jar 包同步到 Maven ,本文详细记录整个发布、同步过程。html
进入地址:https://issues.sonatype.org/secure/Signup!default.jspa 注册 Sonatype 用户,Sonatype 经过 JIRA(JIRA 是 Atlassian 公司出品的项目与事务跟踪工具)来管理 OSSRH 仓库。<br />java
提交「构件发布申请」的第一步是在 JIRA Dashborad 上建立一个 issue。以下所示,点击 Create
按钮:git
会弹出一个对话框让你填写 issue 的详细信息,这里最重要的就是 Group Id,通常会带上域名,千万别弄错了,这关系到之后发布其它的构件。咱们这里是com.vesoft
。github
Sonatype 有域名验证,验证方式:数据库
若是你没有域名,可参考这个连接:http://central.sonatype.org/pages/choosing-your-coordinates.html 的方法进行操做apache
审核由于时差缘由须要必定时间,审核经过后会收到邮件通知,同时在对应 issue 下会看到 Sonatype 工做人员的回复,通常是添加一个 comment,内容大体以下:安全
Configuration has been prepared, now you can: Deploy snapshot artifacts into repository https://oss.sonatype.org/content/repositories/snapshots Deploy release artifacts into the staging repository https://oss.sonatype.org/service/local/staging/ deploy/maven2 Promote staged artifacts into repository 'Releases' Download snapshot and release artifacts from group https://oss.sonatype.org/content/groups/public Download snapshot, release and staged artifacts from staging group https://oss.sonatype.org/content/groups/staging please comment on this ticket when you promoted your first release, thanks服务器
> gpg --gen-key
会让选择加密方式:微信
默认选第一个,选择以后,需输入用户名和邮箱,和 Passphase——至关于密钥库密码。jsp
> gpg --list-keys xxx/.gnupg/pubring.gpg --------------------------------- pub 2048R/xxxx 2019-12-02 uid $YOUR_UID <$YOUR_EMAIL> sub 2048R/**** 2019-12-02
这里的公钥 ID 是 xxxx,立刻就会用到了。
gpg --keyserver hkp://keys.gnupg.net:11371 --send-keys xxxx
查看公钥是否上传成功
> gpg --keyserver hkp://keys.gnupg.net:11371 --recv-keys xxxx gpg: 下载密钥‘xxxx’,从 hkp 服务器 keys.gnupg.net gpg: 密钥 xxxx:“$YOUR_UID <$YOUR_EMAIL>”未改变 gpg: 合计被处理的数量:1 gpg: 未改变:1
NOTE:
本地的私钥用来对上传的构件进行数字签名,而下载该构件的用户可经过上传的公钥来验证签名--需验证这个构件是否由本人上传的,由于存在构件被篡改的可能。
修改 Maven 配置文件主要是须要修改 setting.xml
和项目的 pom.xml
文件
修改 ~/.m2/setting.xml
文件
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <servers> ... <server> <id>snapshots</id> <username>$USER_NAME</username> <password>$YOUR_PASSWORD</password> </server> <server> <id>release</id> <username>$USER_NAME</username> <password>$YOUR_PASSWORD</password> </server> </servers> </settings>
替换 USER_NAME
, YOUR_PASSWORD
为 Sonatype 上面注册的用户名和密码, 这里的 ID 会在 pom.xml
里面使用到。
<project> ... <!-- More Project Information --> <name>nebula-java</name> <description>Nebula Java Client</description> <url>https://github.com/vesoft-inc/nebula-java</url> <scm> <connection>scm:git:https://github.com/vesoft-inc/nebula</connection> <url>https://github.com/vesoft-inc/nebula</url> <developerConnection>scm:git:https://github.com/vesoft-inc/nebula</developerConnection> </scm> <licenses> <license> <name>Apache License, Version 2.0</name> <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url> <distribution>repo</distribution> <comments>license</comments> </license> </licenses> ... <profiles> <profile> <id>release</id> <build> <plugins> <!-- Source --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <!-- Javadoc --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.1.1</version> <configuration> <excludePackageNames>com.facebook.thrift:com.facebook.thrift.*</excludePackageNames> </configuration> <executions> <execution> <id>attach-javadocs</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <doclint>none</doclint> </configuration> </execution> </executions> </plugin> <!-- GPG --> <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> <repository> <id>release</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> <snapshotRepository> <id>snapshots</id> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> </profile> </profiles> ... </project>
name
、 description
、 url
、 licenses
、 developers
、 scm
等基本信息 (maven-javadoc-plugin
和 maven-source-plugin
。 参考示例:com-vesoft-client |-- pom.xml |-- src\ `-- target `-- attach-source-javadoc-1.0-SNAPSHOT.jar `-- attach-source-javadoc-1.0-SNAPSHOT-javadoc.jar `-- attach-source-javadoc-1.0-SNAPSHOT-sources.jar
maven-gpg-plugin
(nebula-java 是多模块项目
<modules> <module>client</module> <module>examples</module> </modules>
为了上传 Client,须要上传 parent 的 pom.xml,不然 Client 会找不到依赖(血泪史之踩过的坑),但咱们又不但愿上传 examples 模块,故作了以下改动:
name
、 description
、 url
、 licenses
、 developers
、 scm
等信息和 maven-gpg-plugin
放在 parent 的 pom.xml 文件中<project> ... <name>nebula-java</name> <description>Nebula Java Client</description> <url>https://github.com/vesoft-inc/nebula-java</url> <scm> <connection>scm:git:https://github.com/vesoft-inc/nebula</connection> <url>https://github.com/vesoft-inc/nebula</url> <developerConnection>scm:git:https://github.com/vesoft-inc/nebula</developerConnection> </scm> <licenses> <license> <name>Apache License, Version 2.0</name> <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url> <distribution>repo</distribution> <comments>license</comments> </license> </licenses> <developers> <developer> <id>$ID</id> <name>$NAME</name> <email>$EMAIL</email> <organization>vesoft</organization> <roles> <role>architect</role> <role>developer</role> </roles> </developer> </developers> <distributionManagement> <repository> <id>release</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> <snapshotRepository> <id>snapshots</id> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> <build> <plugins> <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> </project>
maven-javadoc-plugin
、 maven-source-plugin
和 maven-deploy-plugin
<plugins> ...... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.1.1</version> <configuration> <excludePackageNames>com.facebook.thrift:com.facebook.thrift.*</excludePackageNames> </configuration> <executions> <execution> <id>attach-javadocs</id> <phase>package</phase> <goals> <goal>jar</goal> </goals> <configuration> <doclint>none</doclint> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <executions> <execution> <id>default-deploy</id> <phase>deploy</phase> </execution> </executions> </plugin> </plugins>
在 example 模块的 pom.xml 中声明 skip deploy
<plugins> ...... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin> </plugins>
Q: 为何 maven-gpg-plugin
放在 parent 的 pom.xm l中,而 maven-javadoc-plugin
,maven-source-plugin
插件放在 Client 的 pom.xml 中
A: 由于上传的全部构件都须要加密,包括 parent 的 pom.xml,所以放在 parent 中; 而只有 Client 须要上传 javadoc,source,所以 maven-javadoc-plugin
,maven-source-plugin
插件放在 Client 中。
在 nebula-java/ 目录下运行:
> mvn clean deploy -DpomFile=pom.xml
NOTE:不加 -DpomFile ,上传的文件中会没有 parent 的 pom.xml (
又是一部血泪史)
使用 Sonatype 帐号登陆 https://oss.sonatype.org/#stagingRepositories,可在 Staging Repositories
中查看已上传的构件,这些构件目前是放在 Staging 仓库中,可进行模糊查询,定位到刚上传的构件。
此时,该构件的状态为 Open
,勾选它,而后点击 Close
按钮。系统会自动验证该构件是否知足指定要求 (幸福的人只有一种,不幸的人各有各的不幸,可能会遇到各类各样的不符合要求,Good luck!ヾ(◍°∇°◍)ノ゙)
当验证完毕后,状态会变为 Closed
。
最后,点击 Release
按钮来发布该构件
页面可能要刷新一下才能看到最新的状态。
在前面 JIRA 的 issue 下面回复一条“构件已成功发布”的评论,通知 Sonatype 的工做人员为要发布的构件作审批,发布后会关闭该 issue。
而后,等待。。。
大概十多分钟后,能够在这里 https://repo1.maven.org/maven2 找到刚刚发布的构件,能够直接在 pom.xml 中使用啦~~ 👏👏
等同步完成大约 2 个小时,中央仓库(链接:http://search.maven.org/)就能够搜到啦。
国内不少使用的是阿里云的镜像,镜像同步不是实时同步。为了及时使用,能够添加中央仓库镜像源,在 ~/.m2/setting.xml
文件添加,以下:
<mirrors> ...... <mirror> <id>nexus-mvn</id> <mirrorOf>central</mirrorOf> <name>Nexus Central</name> <url>http://repo1.maven.org/maven2</url> </mirror> </mirrors>
第一次成功发布以后,之后就不用这么麻烦了,能够直接使用 Group Id 发布构件。
以后同一个 Group Id 的发布流程
最后舒适提示:发布的版本不支持修改,或者删除
为何给图数据库取名 Nebula ? Nebula 是星云的意思,很大嘛,也是漫威宇宙里面漂亮的星云小姐姐。对了,Nebula的发音是:[ˈnɛbjələ]
本文星云图讲解--《阿尔普 188 和蝌蚪的尾巴》
为何这个星系有这么长的尾巴?
在这张使人惊叹的远景图中,根据哈勃遗留档案的图像数据,遥远的星系造成了一个引人注目的背景,这是被破坏的螺旋星系 Arp188,蝌蚪星系。
宇宙蝌蚪距离北方的龙星座(天龙座)只有 4.2 亿光年。它引人注目的尾巴大约有 28 万光年长,以巨大、明亮的蓝色星团为特征。有一个故事是这样说的:一个更致密的闯入星系从 Arp 188 前穿过——从右到左——被它们的引力甩在蝌蚪后面。在此次近距离接触中,潮汐力将螺旋星系的恒星、气体和尘埃拉出,造成了壮观的尾巴。闯入者星系自己,估计位于蝌蚪后面 30 万光年处,能够经过右上角的前景螺旋臂看到。与地球同名的蝌蚪星系极可能会随着年龄的增加而失去尾巴,尾巴上的星团造成了大螺旋星系的小卫星。
资料来源 | Hubble Legacy Archive, ESA, NASA;
图片来源 | Astronomy Picture of the Day | 2018 December 11
最后,附上 Nebula Graph GitHub 地址:https://github.com/vesoft-inc/nebula,若是你在使用 Nebula Graph 过程当中遇到任何问题,欢迎 GitHub 联系咱们或者加入微信交流群,请联系微信号:NebulaGraphbot