Skip to content

Commit cf08694

Browse files
committed
📝 Writing docs.
1 parent 7997fe0 commit cf08694

10 files changed

Lines changed: 227 additions & 12 deletions

docs/javatool/maven/README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Maven
22

3-
## 目录
3+
## 知识结构图
44

5-
* [Maven 快速指南(一)](maven-quickstart-01.html)
6-
* [Maven 快速指南(二)](maven-quickstart-02.html)
7-
* [Maven 之 settings.xml 详解](maven-settings-config.html)
8-
* [Maven 排错](maven-faq.html)
5+
![maven.png](http://upload-images.jianshu.io/upload_images/3101171-b5325d3c12338b65.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# 发布项目到中央仓库
2+
3+
## 创建工单
4+
5+
在发布Java包到Maven中央仓库首先需要在[https://issues.sonatype.org/secure/Dashboard.jspa](https://www.iteblog.com/redirect.php?url=aHR0cHM6Ly9pc3N1ZXMuc29uYXR5cGUub3JnL3NlY3VyZS9EYXNoYm9hcmQuanNwYQ==&article=true)网站创建一个工单(Issues),第一次使用这个网站的时候需要注册自己的帐号(这个帐号和密码需要记住,后面会用到),之后创建自己的Issue。
6+
7+
然后根据你Java包的功能分别写上`Summary``Description``Group Id``SCM url`以及`Project URL`等必要信息,可以参见我之前创建的Issue:[https://issues.sonatype.org/browse/OSSRH-33765](https://issues.sonatype.org/browse/OSSRH-33765)。创建完之后需要等待Sonatype的工作人员审核处理,审核时间还是很快的,我的审核差不多等待了两小时。当Issue的Status变为`RESOLVED`后,就可以进行下一步操作了。
8+
9+
> 注:如果你的Group Id填写的是自己的网站(我的就是这种情况),Sonatype的工作人员会询问你那个Group Id是不是你的域名,你只需要在上面回答是就行,然后就会通过审核。
10+
11+
## gpg
12+
13+
### 安装、下载 gpg
14+
15+
上面创建的issuce经过审核之后,我们可以使用gpg生成密钥对,这里分两种情况:
16+
17+
1. 如果使用的是Windows,可以到[https://www.gpg4win.org/download.html](https://www.iteblog.com/redirect.php?url=aHR0cHM6Ly93d3cuZ3BnNHdpbi5vcmcvZG93bmxvYWQuaHRtbA==&article=true)下载gpg4win,推荐使用 Gpg4win-Vanilla 2.3.3版本,因为它仅包括 GnuPG,这个工具才是我们所需要的;
18+
2. 如果使用的是Linux,可以通过`yum install gpg`命令安装gpg。
19+
20+
之后可以通过`gpg --version`命令查看是否安装成功,如果出现版本等信息说明安装成功了。
21+
22+
### 生成密钥
23+
24+
安装 gpg 成功后,执行命令:
25+
26+
```bash
27+
$ gpg --gen-key
28+
```
29+
30+
按照提示信息依次设置好名字、邮箱等信息。不过输入Passphrase的值需要记住,这个相当于密钥的密码,发布过程中进行签名操作的时候会用到。
31+
32+
到这里我们就设置好密钥对了。上面代码中导数第四行的`B15C5AA3`需要记住,其相当于我们生成的key,后面会用到。
33+
34+
### 上传keys
35+
36+
```bash
37+
$ gpg --list-keys
38+
xxxx/gnupg/pubring.gpg
39+
--------------------------------------------------------
40+
pub 2048R/D416FE08 2017-12-06
41+
uid [ultimate] Zhang Peng (author) <forbreak@163.com>
42+
sub 2048R/CBD8FA39 2017-12-06
43+
44+
45+
$ gpg --keyserver hkp://keyserver.ubuntu.com:11371 --send-keys D416FE08
46+
gpg: sending key D416FE08 to hkp server keyserver.ubuntu.com
47+
```
48+
49+
## settings 配置
50+
51+
修改 maven 的 settings.xml 文件
52+
53+
```xml
54+
<servers>
55+
<server>
56+
<id>sonatype-nexus-snapshots</id>
57+
<username>Sonatype网站的账号</username>
58+
<password>Sonatype网站的密码</password>
59+
</server>
60+
<server>
61+
<id>sonatype-nexus-staging</id>
62+
<username>Sonatype网站的账号</username>
63+
<password>Sonatype网站的密码</password>
64+
</server>
65+
</servers>
66+
```
67+
68+
## pom 配置
69+
70+
licenses、scm、developers 配置:
71+
72+
```xml
73+
<licenses>
74+
<license>
75+
<name>The Apache Software License, Version 2.0</name>
76+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
77+
<distribution>repo</distribution>
78+
</license>
79+
</licenses>
80+
81+
<developers>
82+
<developer>
83+
<name>VictorZhang</name>
84+
<email>forbreak@163.com</email>
85+
<url>https://github.com/dunwu</url>
86+
</developer>
87+
</developers>
88+
89+
<scm>
90+
<url>https://github.com/dunwu/tent</url>
91+
<connection>git@github.com:dunwu/tent.git</connection>
92+
<developerConnection>https://github.com/dunwu</developerConnection>
93+
</scm>
94+
```
95+
96+
distributionManagement 配置
97+
98+
```xml
99+
<distributionManagement>
100+
<snapshotRepository>
101+
<id>nexus</id>
102+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
103+
</snapshotRepository>
104+
<repository>
105+
<id>nexus</id>
106+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
107+
</repository>
108+
</distributionManagement>
109+
```
110+
111+
profiles 配置
112+
113+
```xml
114+
<profiles>
115+
<profile>
116+
<id>release</id>
117+
<build>
118+
<plugins>
119+
<plugin>
120+
<groupId>org.sonatype.plugins</groupId>
121+
<artifactId>nexus-staging-maven-plugin</artifactId>
122+
<version>1.6.7</version>
123+
<extensions>true</extensions>
124+
<configuration>
125+
<serverId>nexus</serverId>
126+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
127+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
128+
</configuration>
129+
</plugin>
130+
<plugin>
131+
<groupId>org.apache.maven.plugins</groupId>
132+
<artifactId>maven-javadoc-plugin</artifactId>
133+
<version>2.10.3</version>
134+
<configuration>
135+
<failOnError>false</failOnError>
136+
<quiet>true</quiet>
137+
</configuration>
138+
<executions>
139+
<execution>
140+
<id>attach-javadocs</id>
141+
<goals>
142+
<goal>jar</goal>
143+
</goals>
144+
</execution>
145+
</executions>
146+
</plugin>
147+
<plugin>
148+
<groupId>org.apache.maven.plugins</groupId>
149+
<artifactId>maven-gpg-plugin</artifactId>
150+
<version>1.6</version>
151+
<executions>
152+
<execution>
153+
<id>sign-artifacts</id>
154+
<phase>verify</phase>
155+
<goals>
156+
<goal>sign</goal>
157+
</goals>
158+
</execution>
159+
</executions>
160+
</plugin>
161+
</plugins>
162+
</build>
163+
</profile>
164+
</profiles>
165+
```
166+
167+
## 部署和发布
168+
169+
```bash
170+
$ mvn clean deploy -P sonatype-oss-release -Darguments="gpg.passphrase=设置gpg设置密钥时候输入的Passphrase" -Dmaven.test.skip=true
171+
```

docs/javatool/maven/maven-faq.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ tags:
77
- java
88
- tool
99
- build
10+
- maven
1011
---
1112

13+
# Maven 排错
14+
1215
> 本文收录我在开发过程中遇到的各种 maven 问题,持续更新。。。
1316
1417
## 问题

docs/javatool/maven/maven-pom-01.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
# [maven]pom.xml详解一
1+
---
2+
title: Maven 之 pom.xml 详解(一)
3+
date: 2016/11/10
4+
categories:
5+
- javatool
6+
tags:
7+
- java
8+
- tool
9+
- build
10+
- maven
11+
---
12+
13+
# Maven 之 pom.xml 详解(一)
214

315
## 简介
416

docs/javatool/maven/maven-pom-02.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
# [maven]pom.xml详解二
1+
---
2+
title: Maven 之 pom.xml 详解(二)
3+
date: 2016/11/10
4+
categories:
5+
- javatool
6+
tags:
7+
- java
8+
- tool
9+
- build
10+
- maven
11+
---
12+
13+
# Maven 之 pom.xml 详解(二)
214

315
## 构建配置
416

@@ -252,4 +264,4 @@ build 可以分为 "project build" 和 "profile build"。
252264
</reporting>
253265
...
254266
</project>
255-
```
267+
```

docs/javatool/maven/maven-pom-03.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
# [maven]pom.xml详解三
1+
---
2+
title: Maven 之 pom.xml 详解(三)
3+
date: 2016/11/10
4+
categories:
5+
- javatool
6+
tags:
7+
- java
8+
- tool
9+
- build
10+
- maven
11+
---
12+
13+
# Maven 之 pom.xml 详解(三)
214

315
## 项目信息
416

@@ -319,4 +331,4 @@ POM 执行的预设条件。
319331
</profile>
320332
</profiles>
321333
</project>
322-
```
334+
```

docs/javatool/maven/maven-quickstart-01.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
---
22
title: Maven 快速指南(一)
3-
date: 2016/06/16
3+
date: 2016/11/10
44
categories:
55
- javatool
66
tags:
77
- java
88
- tool
99
- build
10+
- maven
1011
---
1112

13+
# Maven 快速指南(一)
14+
1215
## 概念
1316

1417
### Maven是什么

docs/javatool/maven/maven-quickstart-02.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
---
22
title: Maven 快速指南(二)
3-
date: 2016/06/16
3+
date: 2016/11/10
44
categories:
55
- javatool
66
tags:
77
- java
88
- tool
99
- build
10+
- maven
1011
---
1112

13+
# Maven 快速指南(二)
14+
1215
## 使用指导
1316

1417
### 如何添加外部依赖jar包

docs/javatool/maven/maven-settings-config.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ tags:
99
- build
1010
---
1111

12+
# Maven 之 settings.xml 详解
13+
1214
## 概要
1315

1416
### settings.xml有什么用?

docs/javatool/maven/maven.xmind

106 KB
Binary file not shown.

0 commit comments

Comments
 (0)