Mac M1 build Thingsboard

文章目录

mac m1编译thingsboard过程记录,虽说是mac m1为示例机器,但是windows也是一样的道理,只是架构部分不同。
本机环境:JAVA:11、MAVEN3、NODE:18、YARN:1.22.19
image

拉取代码

github地址:https://github.com/thingsboard/thingsboard

修改文件

根目录下pom.xml

1、 文件内搜索:${os.detected.classifier},出现三处位置,将其更改为:osx-aarch_64
2、 文件内搜索:com.mycila,出现两处位置,将其完整注释,具体注释内容如下:

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
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>3.0</version>
<configuration>
<header>${main.dir}/license-header-template.txt</header>
<properties>
<owner>The Thingsboard Authors</owner>
</properties>
<excludes>
<exclude>**/.env</exclude>
<exclude>**/*.env</exclude>
<exclude>**/.eslintrc</exclude>
<exclude>**/.babelrc</exclude>
<exclude>**/.jshintrc</exclude>
<exclude>**/.gradle/**</exclude>
<exclude>**/nightwatch</exclude>
<exclude>**/README</exclude>
<exclude>**/LICENSE</exclude>
<exclude>**/banner.txt</exclude>
<exclude>node_modules/**</exclude>
<exclude>**/*.properties</exclude>
<exclude>src/test/resources/**</exclude>
<exclude>src/vendor/**</exclude>
<exclude>src/font/**</exclude>
<exclude>src/sh/**</exclude>
<exclude>packaging/*/scripts/control/**</exclude>
<exclude>packaging/*/scripts/windows/**</exclude>
<exclude>packaging/*/scripts/init/**</exclude>
<exclude>**/*.log</exclude>
<exclude>**/*.current</exclude>
<exclude>.instance_id</exclude>
<exclude>src/main/scripts/control/**</exclude>
<exclude>src/main/scripts/windows/**</exclude>
<exclude>src/main/resources/public/static/rulenode/**</exclude>
<exclude>**/*.proto.js</exclude>
<exclude>docker/haproxy/**</exclude>
<exclude>docker/tb-node/**</exclude>
<exclude>ui/**</exclude>
<exclude>**/.browserslistrc</exclude>
<exclude>**/yarn.lock</exclude>
<exclude>**/.yarnrc</exclude>
<exclude>**/.angular/**</exclude>
<exclude>**/*.raw</exclude>
<exclude>**/*.patch</exclude>
<exclude>**/apache/cassandra/io/**</exclude>
<exclude>.run/**</exclude>
<exclude>**/NetworkReceive.java</exclude>
<exclude>**/lwm2m-registry/**</exclude>
</excludes>
<mapping>
<proto>JAVADOC_STYLE</proto>
<cql>DOUBLEDASHES_STYLE</cql>
<scss>JAVADOC_STYLE</scss>
<jsx>SLASHSTAR_STYLE</jsx>
<tsx>SLASHSTAR_STYLE</tsx>
<conf>SCRIPT_STYLE</conf>
<gradle>JAVADOC_STYLE</gradle>
</mapping>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
1
2
3
4
5
6
<plugins>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
</plugin>
</plugins>

node和yarn版本

全局搜索nodeVersion,将nodeVersionyarnVersion更改为自己电脑的版本。
node -vyarn -v

设置node、yarn镜像源

npm config set registry registry.npm.taobao.org
yarn config set registry registry.npm.taobao.org

install ui-ngx

cd ui-ngx
yarn install

开始编译

mvn install -Dmaven.test.skip=true

  • ps:这是跳过测试的,所以截止这一步不需要搭建postgres、kafka等。

遇到的问题

  • 直接上报错代码,更加直观。

错误一:

The following artifacts could not be resolved: org.thingsboard:dao:jar:tests:3.5.1-SNAPSHOT (absent):

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
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Thingsboard 3.5.1-SNAPSHOT:
[INFO]
[INFO] Thingsboard ........................................ SUCCESS [ 0.113 s]
[INFO] Netty MQTT Client .................................. SUCCESS [ 0.450 s]
[INFO] Thingsboard Server Commons ......................... SUCCESS [ 0.003 s]
[INFO] Thingsboard Server Common Data ..................... SUCCESS [ 0.489 s]
[INFO] Thingsboard Server Common Utils .................... SUCCESS [ 0.032 s]
[INFO] Thingsboard Server Common Messages ................. SUCCESS [ 2.516 s]
[INFO] Thingsboard Actor system ........................... SUCCESS [ 0.327 s]
[INFO] Thingsboard Server Stats ........................... SUCCESS [ 0.209 s]
[INFO] Thingsboard Server Common Cluster API .............. SUCCESS [ 6.500 s]
[INFO] Thingsboard Server Queue components ................ SUCCESS [ 1.521 s]
[INFO] Thingsboard Server Common Cache .................... SUCCESS [ 0.419 s]
[INFO] Thingsboard Server Commons ......................... SUCCESS [ 0.003 s]
[INFO] Thingsboard Server Common Transport components ..... SUCCESS [ 2.013 s]
[INFO] Thingsboard MQTT Transport Common .................. SUCCESS [ 2.019 s]
[INFO] Thingsboard HTTP Transport Common .................. SUCCESS [ 0.313 s]
[INFO] Thingsboard CoAP server ............................ SUCCESS [ 0.384 s]
[INFO] Thingsboard CoAP Transport Common .................. SUCCESS [ 2.295 s]
[INFO] Thingsboard LwM2M Transport Common ................. SUCCESS [ 1.273 s]
[INFO] Thingsboard SNMP Transport Common .................. SUCCESS [ 0.383 s]
[INFO] Thingsboard Server Common DAO API .................. SUCCESS [ 0.573 s]
[INFO] Thingsboard Server Remote Edge wrapper ............. SUCCESS [ 2.972 s]
[INFO] Thingsboard Server Version Control API ............. SUCCESS [ 0.529 s]
[INFO] Thingsboard Script Invoke Commons .................. SUCCESS [ 0.003 s]
[INFO] Thingsboard Server Script invoke API ............... SUCCESS [ 0.327 s]
[INFO] Thingsboard Extensions ............................. SUCCESS [ 0.003 s]
[INFO] Thingsboard Rule Engine API ........................ SUCCESS [ 0.378 s]
[INFO] Thingsboard Server JS Client for remote JS execution SUCCESS [ 0.341 s]
[INFO] Thingsboard Server DAO Layer ....................... SUCCESS [ 3.426 s]
[INFO] Thingsboard Rule Engine Components ................. SUCCESS [ 1.949 s]
[INFO] Thingsboard Server Transport Modules ............... SUCCESS [ 0.002 s]
[INFO] Thingsboard HTTP Transport Service ................. SUCCESS [ 44.298 s]
[INFO] Thingsboard MQTT Transport Service ................. SUCCESS [ 16.300 s]
[INFO] Thingsboard CoAP Transport Service ................. SUCCESS [ 15.375 s]
[INFO] Thingsboard LwM2m Transport Service ................ SUCCESS [ 15.761 s]
[INFO] Thingsboard SNMP Transport Service ................. SUCCESS [ 15.268 s]
[INFO] ThingsBoard Server UI .............................. SUCCESS [02:02 min]
[INFO] Thingsboard Server Tools ........................... SUCCESS [ 0.451 s]
[INFO] Thingsboard Rest Client ............................ SUCCESS [ 0.579 s]
[INFO] ThingsBoard Server Application ..................... FAILURE [ 6.288 s]
[INFO] ThingsBoard Microservices .......................... SKIPPED
[INFO] ThingsBoard Docker Images .......................... SKIPPED
[INFO] ThingsBoard Web UI Microservice .................... SKIPPED
[INFO] ThingsBoard Version Control Executor ............... SKIPPED
[INFO] ThingsBoard Version Control Executor Microservice .. SKIPPED
[INFO] ThingsBoard Node Microservice ...................... SKIPPED
[INFO] ThingsBoard Transport Microservices ................ SKIPPED
[INFO] ThingsBoard MQTT Transport Microservice ............ SKIPPED
[INFO] ThingsBoard HTTP Transport Microservice ............ SKIPPED
[INFO] ThingsBoard COAP Transport Microservice ............ SKIPPED
[INFO] ThingsBoard LWM2M Transport Microservice ........... SKIPPED
[INFO] ThingsBoard SNMP Transport Microservice ............ SKIPPED
[INFO] ThingsBoard JavaScript Executor Microservice ....... SKIPPED
[INFO] ThingsBoard Monitoring Service ..................... SKIPPED
[INFO] ThingsBoard Monitoring Microservice ................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:28 min
[INFO] Finished at: 2023-07-29T13:54:44+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project application: Could not resolve dependencies for project org.thingsboard:application:jar:3.5.1-SNAPSHOT: The following artifacts could not be resolved: org.thingsboard:dao:jar:tests:3.5.1-SNAPSHOT (absent): Could not find artifact org.thingsboard:dao:jar:tests:3.5.1-SNAPSHOT in taobao (https://maven.aliyun.com/repository/public) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :application

Process finished with exit code 1

解决方案:
前往https://repo.thingsboard.io/artifactory/libs-release-public/org/thingsboard/dao/3.5.1/ 下载所需的包(注意版本),放到自己本地仓库下:
/org/thingsboard/dao/xxx/

错误二

Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.0:yarn (yarn pkg) on project web-ui: Failed to run task: 'yarn run pkg' failed.

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
[INFO] > Error! Not able to build for 'linux' here, only for 'macos'
[INFO] error Command failed with exit code 2.
[INFO] error Command failed with exit code 2.info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Thingsboard 3.5.1-SNAPSHOT:
[INFO]
[INFO] Thingsboard ........................................ SUCCESS [ 0.156 s]
[INFO] Netty MQTT Client .................................. SUCCESS [ 0.682 s]
[INFO] Thingsboard Server Commons ......................... SUCCESS [ 0.005 s]
[INFO] Thingsboard Server Common Data ..................... SUCCESS [ 0.586 s]
[INFO] Thingsboard Server Common Utils .................... SUCCESS [ 0.034 s]
[INFO] Thingsboard Server Common Messages ................. SUCCESS [ 1.992 s]
[INFO] Thingsboard Actor system ........................... SUCCESS [ 0.035 s]
[INFO] Thingsboard Server Stats ........................... SUCCESS [ 0.045 s]
[INFO] Thingsboard Server Common Cluster API .............. SUCCESS [ 6.209 s]
[INFO] Thingsboard Server Queue components ................ SUCCESS [ 0.334 s]
[INFO] Thingsboard Server Common Cache .................... SUCCESS [ 0.038 s]
[INFO] Thingsboard Server Commons ......................... SUCCESS [ 0.002 s]
[INFO] Thingsboard Server Common Transport components ..... SUCCESS [ 1.797 s]
[INFO] Thingsboard MQTT Transport Common .................. SUCCESS [ 1.965 s]
[INFO] Thingsboard HTTP Transport Common .................. SUCCESS [ 0.071 s]
[INFO] Thingsboard CoAP server ............................ SUCCESS [ 0.050 s]
[INFO] Thingsboard CoAP Transport Common .................. SUCCESS [ 0.883 s]
[INFO] Thingsboard LwM2M Transport Common ................. SUCCESS [ 0.095 s]
[INFO] Thingsboard SNMP Transport Common .................. SUCCESS [ 0.053 s]
[INFO] Thingsboard Server Common DAO API .................. SUCCESS [ 0.069 s]
[INFO] Thingsboard Server Remote Edge wrapper ............. SUCCESS [ 2.583 s]
[INFO] Thingsboard Server Version Control API ............. SUCCESS [ 0.057 s]
[INFO] Thingsboard Script Invoke Commons .................. SUCCESS [ 0.003 s]
[INFO] Thingsboard Server Script invoke API ............... SUCCESS [ 0.031 s]
[INFO] Thingsboard Extensions ............................. SUCCESS [ 0.003 s]
[INFO] Thingsboard Rule Engine API ........................ SUCCESS [ 0.047 s]
[INFO] Thingsboard Server JS Client for remote JS execution SUCCESS [ 0.057 s]
[INFO] Thingsboard Server DAO Layer ....................... SUCCESS [ 0.279 s]
[INFO] Thingsboard Rule Engine Components ................. SUCCESS [ 0.482 s]
[INFO] Thingsboard Server Transport Modules ............... SUCCESS [ 0.003 s]
[INFO] Thingsboard HTTP Transport Service ................. SUCCESS [ 16.460 s]
[INFO] Thingsboard MQTT Transport Service ................. SUCCESS [ 16.444 s]
[INFO] Thingsboard CoAP Transport Service ................. SUCCESS [ 15.747 s]
[INFO] Thingsboard LwM2m Transport Service ................ SUCCESS [ 15.983 s]
[INFO] Thingsboard SNMP Transport Service ................. SUCCESS [ 15.843 s]
[INFO] ThingsBoard Server UI .............................. SUCCESS [ 40.597 s]
[INFO] Thingsboard Server Tools ........................... SUCCESS [ 0.103 s]
[INFO] Thingsboard Rest Client ............................ SUCCESS [ 0.033 s]
[INFO] ThingsBoard Server Application ..................... SUCCESS [ 36.036 s]
[INFO] ThingsBoard Microservices .......................... SUCCESS [ 0.078 s]
[INFO] ThingsBoard Docker Images .......................... SUCCESS [ 0.825 s]
[INFO] ThingsBoard Web UI Microservice .................... FAILURE [02:23 min]
[INFO] ThingsBoard Version Control Executor ............... SKIPPED
[INFO] ThingsBoard Version Control Executor Microservice .. SKIPPED
[INFO] ThingsBoard Node Microservice ...................... SKIPPED
[INFO] ThingsBoard Transport Microservices ................ SKIPPED
[INFO] ThingsBoard MQTT Transport Microservice ............ SKIPPED
[INFO] ThingsBoard HTTP Transport Microservice ............ SKIPPED
[INFO] ThingsBoard COAP Transport Microservice ............ SKIPPED
[INFO] ThingsBoard LWM2M Transport Microservice ........... SKIPPED
[INFO] ThingsBoard SNMP Transport Microservice ............ SKIPPED
[INFO] ThingsBoard JavaScript Executor Microservice ....... SKIPPED
[INFO] ThingsBoard Monitoring Service ..................... SKIPPED
[INFO] ThingsBoard Monitoring Microservice ................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:20 min
[INFO] Finished at: 2023-07-29T14:16:19+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.12.0:yarn (yarn pkg) on project web-ui: Failed to run task: 'yarn run pkg' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 2 (Exit value: 2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :web-ui

Process finished with exit code 1

解决方案:
前往:https://github.com/vercel/pkg-fetch/releases 下载所需要的文件,放置在用户文件夹下:
/.pkg-cache/vxx/,例如mac的位置为:/Users/meng/.pkg-cache/v3.4

微信公众号
分享到: