gerrit-3.4.3 的编译

下载gerrit源码

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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
https://gerrit.googlesource.com/gerrit (fetch)

git clone https://gerrit.googlesource.com/gerrit

git checkout v3.4.3


git clone --recurse-submodules https://gerrit.googlesource.com/gerrit -b v3.4.3 gerrit-3.4.3


要注意 这个 modules/jgit 路径下面 jgit 的版本。我这里 3.4.3的gerrit 配上 60b81c5a9 这个点的gerrit。
https://github.com/mamh-java/jgit.git
* 60b81c5a9 * Fix RevWalk.getMergedInto() ignores annotated tags <kylezhao >[2021-10-08 12:05] (HEAD, github/blackshark-v3.4.3)


参考 gitmodule 文件 查看其他 模块或插件 需要的下载路径
[submodule "modules/jgit"]
path = modules/jgit
url = ../jgit

[submodule "plugins/codemirror-editor"]
path = plugins/codemirror-editor
url = ../plugins/codemirror-editor
branch = .

[submodule "plugins/commit-message-length-validator"]
path = plugins/commit-message-length-validator
url = ../plugins/commit-message-length-validator
branch = .

[submodule "plugins/delete-project"]
path = plugins/delete-project
url = ../plugins/delete-project
branch = .

[submodule "plugins/download-commands"]
path = plugins/download-commands
url = ../plugins/download-commands
branch = .

[submodule "plugins/gitiles"]
path = plugins/gitiles
url = ../plugins/gitiles
branch = .

[submodule "plugins/hooks"]
path = plugins/hooks
url = ../plugins/hooks
branch = .

[submodule "plugins/plugin-manager"]
path = plugins/plugin-manager
url = ../plugins/plugin-manager
branch = .

[submodule "plugins/replication"]
path = plugins/replication
url = ../plugins/replication
branch = .

[submodule "plugins/reviewnotes"]
path = plugins/reviewnotes
url = ../plugins/reviewnotes
branch = .

[submodule "plugins/singleusergroup"]
path = plugins/singleusergroup
url = ../plugins/singleusergroup
branch = .

[submodule "plugins/webhooks"]
path = plugins/webhooks
url = ../plugins/webhooks
branch = .

[submodule "polymer-bridges"]
path = polymer-bridges
url = ../polymer-bridges
branch = .

下载编译工具(bazel,jdk,nodejs)

1
2
3
4
5
6
7

bazel-4.2.2-linux-x86_64
bazel_nojdk-4.2.2-linux-x86_64
node-v14.15.4-linux-x64
jdk11 # 这个用 openjdk11

gcc g++ 还会用到这个2个工具

编译gerrit,部署gerrit

1
2
3
4
5
6
7
8
9
10
11
12
13
14

#!/bin/bash -x
export JAVA_HOME=~/work/install/jdk11
export PATH=$JAVA_HOME/bin:~/work/install/node/bin:~/work/install/maven/bin:$PATH

export HTTPS_PROXY="http://127.0.0.1:44444" # 翻墙的代理,编译时候会下载 东西的,需要翻个墙
export HTTP_PROXY="http://127.0.0.1:44444"

bazel-4.2.2-linux-x86_64 build release # 构建整个 gerrit.war


bazel-4.2.2-linux-x86_64 build plugins/ref-protection # 构建 plugins ref-protection


搞一个脚本 用来编译,加 安装重新部署gerrit服务的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash -x
export JAVA_HOME=~/work/install/jdk11
export PATH=$JAVA_HOME/bin:~/work/install/node/bin:~/work/install/maven/bin:$PATH

export HTTPS_PROXY="http://127.0.0.1:44444"
export HTTP_PROXY="http://127.0.0.1:44444"
export SITE=~/work/gerrit/review_site

(
~/work/install/bazel-4.2.2-linux-x86_64 build release

#~/work/install/bazel-4.2.2-linux-x86_64 build $1

)
(
cp -rf bazel-bin/release.war $SITE
cd $SITE || exit 1
bin/gerrit.sh stop
java -Xmx30g -Xms30g -jar release.war init --install-all-plugins --no-auto-start --show-stack-trace --batch --dev -d $SITE
bin/gerrit.sh start
)