[O]Flink版本适配改造(二)1.0.0+
# 背景说明
在 Flink 的 flink-runtime-web
模块中,Web UI 的构建依赖于 Node.js 和 NPM,并通过 frontend-maven-plugin
进行统一构建与检查。在国内环境中,该插件默认的 Node 镜像站点访问较慢,甚至可能失败,因此我们需要对如下部分进行定制适配:
- 替换 Node 与 NPM 下载地址为国内源(阿里云/淘宝源/CDN 源);
- 降低 Node 版本避免 npm v8 构建 bug;
- 添加
<skipTests>true</skipTests>
; - 增加构建参数便于调试与加速。
本文改造内容以 pom.xml
为核心,尤其适用于 Bigtop 场景下的 RPM 包构建。构建适配
# 修改点汇总
修改目的回顾
主要解决两类问题:
- 编译时 frontend-maven-plugin 执行失败;
- 编译日志冗长、下载失败、CI 缓存失效等问题。
改造项 | 原配置 | 修改后 |
---|---|---|
Node 版本 | v16.13.2 | v12.22.6 |
NPM 版本 | 8.1.2 | 6.14.5 |
Node 下载地址 | 默认 nodejs.org | https://cdn.npmmirror.com/binaries/node/ |
NPM 下载地址 | 默认 registry.npmjs.org | https://registry.npmmirror.com/npm/-/ |
执行参数 | ci --cache-max=0 | install --unsafe-perm --verbose --save --progress |
插件版本 | 不定 | 1.11.0 明确指定 |
添加 <skipTests> | 否 | ✅ |
# 关键修改片段
# frontend-maven-plugin
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.11.0</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v12.22.6</nodeVersion>
<npmVersion>6.14.5</npmVersion>
<nodeDownloadRoot>https://cdn.npmmirror.com/binaries/node/</nodeDownloadRoot>
<npmDownloadRoot>https://registry.npmmirror.com/npm/-/</npmDownloadRoot>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install --unsafe-perm --verbose --save --progress</arguments>
<npmRegistryURL>https://registry.npmmirror.com/</npmRegistryURL>
<environmentVariables>
<HUSKY_SKIP_INSTALL>true</HUSKY_SKIP_INSTALL>
</environmentVariables>
</configuration>
</execution>
<execution>
<id>npm run ci-check</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run ci-check</arguments>
</configuration>
</execution>
</executions>
<configuration>
<workingDirectory>web-dashboard</workingDirectory>
</configuration>
</plugin>
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
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
# maven-surefire-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<skipTests>true</skipTests>
<systemPropertyVariables>
<targetDir>${project.build.directory}</targetDir>
<parameterJarName>${test.parameterProgram.name}</parameterJarName>
<parameterJarWithoutManifestName>${test.ParameterProgramNoManifest.name}</parameterJarWithoutManifestName>
<parameterJarWithEagerSinkName>${test.ParameterProgramWithEagerSink.name}</parameterJarWithEagerSinkName>
</systemPropertyVariables>
</configuration>
</plugin>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 效果截图参考
修改完成后再执行 mvn clean install -DskipTests
构建时,下载链路成功切换为镜像 CDN,加速效果明显:
注意
如构建仍然卡在 npm install,请检查是否存在代理冲突或 npm proxy 配置未清除。