Thingsboard Build踩坑(一)

在尝试编译ThingsboardBuild项目时遇到错误,详细错误信息指出等待另一个ngcc进程超时。解决此问题的方法是定位到指定路径下的ngcc_lock_file文件并将其删除,之后重新进行编译操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Thingsboard Build踩坑(一)

编译时错误代码:

	[Error] Timed out waiting 250s for another ngcc process, with id 3300, to complete. (If you are sure no ngcc process is running then you should delete the lock-file at F:/thingsboard-master/ui-ngx/node_modules/@angular/compiler-cli/ngcc/ngcc_lock_file.) at AsyncLocker. (F:/thingsboard-master\ui-ngx\node_modules\@angular\compiler-cli\ngcc\src\locking\async_locker.js:91:31) at step (F:/thingsboard-master\ui-ngx\node_modules\tslib\tslib.js:139:27) at Object.next (F:/thingsboard-master\ui-ngx\node_modules\tslib\tslib.js:120:57) at fulfilled (F:/thingsboard-master\ui-ngx\node_modules\tslib\tslib.js:110:62) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! thingsboard@3.0.1 postinstall: ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the thingsboard@3.0.1 postinstall script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\mao19\AppData\Roaming\npm-cache\_logs\2020-07-13T09_13_00_170Z-debug.log

在这里插入图片描述
解决方法:查找到F:/thingsboard-master/ui-ngx/node_modules/@angular/compiler-cli/ngcc/ngcc_lock_file.文件并删除,重新build即可。

<think>我们正在处理用户关于ThingsBoard编译的问题。用户希望了解如何配置ThingsBoard项目以仅编译Linux版本。根据引用内容,用户已经成功编译了ThingsBoard3.6.4版本,并且使用的是Java11(因为3.6.4不需要Java17)。同时,用户提供了关于在Linux内网环境部署ThingsBoard的信息(引用[2])以及关于编译时类路径问题的说明(引用[3])。但是,用户的问题焦点在于“仅编译Linux版本”。这意味着用户可能希望避免编译其他平台(如Windows)的代码或资源,从而加快编译速度或减少构建产物。分析ThingsBoard项目:ThingsBoard个基于Java的项目,使用SpringBoot框架。它通常使用Maven作为构建工具。在ThingsBoard的源代码中,可能会包含些平台相关的代码或资源,例如在处理设备连接(如MQTT、CoAP等)时可能会用到本地库(如通过JNI)。但是,ThingsBoard的主要部分是用Java编写的,因此通常是跨平台的。然而,ThingsBoard的某些组件可能使用了平台相关的依赖或资源。例如,ThingsBoard的微服务架构中可能包含使用Docker镜像构建的部分,或者在某些模块中使用了特定于操作系统的脚本(如.sh脚本用于Linux,.bat用于Windows)。用户想要“仅编译Linux版本”,可能是指:1.在构建过程中只生成适用于Linux的部署包(例如,RPM包或Docker镜像)。2.避免编译Windows相关的脚本或资源。根据引用[2],ThingsBoard提供了RPM包(用于Linux)的下载,用户希望从源代码编译出这样的RPM包。查阅ThingsBoard的官方文档和构建脚本:ThingsBoard的构建过程由Maven管理,并且项目提供了多个Mavenprofile来支持不同的打包方式。在ThingsBoard的根pom.xml文件中,我们可以找到不同的profile,例如:-deb-用于构建Debian包-rpm-用于构建RPM包-docker-用于构建Docker镜像因此,为了仅构建Linux版本(特别是RPM包),用户应该激活rpmprofile。构建步骤:1.确保环境满足要求:Java11(对于ThingsBoard3.6.4),Maven(版本3.6.0以上),以及RPM构建工具(如rpmbuild,在基于RPM的系统上通常已经安装,或者可以通过yuminstallrpm-build安装)。2.在项目的根目录下,运行Maven命令并指定rpmprofile。命令示例:```bashmvncleaninstall-Prpm```这个命令将激活rpmprofile,该profile会配置Maven来构建RPM包。构建完成后,RPM包将出现在对应模块的target目录下(通常是thingsboard/application/target目录)。注意:如果用户不需要其他平台的构建(如Docker镜像、Debian包等),则不需要激活其他profile(如docker,deb等)。默认情况下,Maven不会激活这些profile,因此只指定`-Prpm`将只构建RPM包。但是,用户可能还希望跳过些与平台无关的模块的构建以加快速度?这通常不是必要的,因为Maven会智能地处理依赖关系。不过,如果用户确实希望最小化构建,可以只构建必要的模块。但ThingsBoard项目结构复杂,通常推荐完整构建。另外,引用[3]提到了关于编译时类路径的问题,这可能在IDE中遇到。但用户现在是在进行命令行编译,所以这个问题可能不相关。如果用户在使用IDE,可以按照引用[3]中的建议设置类路径选项(例如选择“classpathfile”选项)以避免命令行过长的问题。总结:用户可以通过在Maven命令中指定rpmprofile来仅构建Linux的RPM包。因此,回答如下:</think>### ThingsBoard 仅编译 Linux 版本的配置方法 要配置 ThingsBoard 项目仅编译 Linux 版本,需通过 Maven 的 Profile 机制实现。以下是具体步骤: #### 1. **修改根目录 `pom.xml` 文件** 在项目根目录的 `pom.xml` 文件中添加 Linux 专用 Profile: ```xml <profiles> <profile> <id>linux-build</id> <activation> <activeByDefault>false</activeByDefault> </activation> <properties> <!-- 禁用 Windows 平台相关模块 --> <skip.windows.modules>true</skip.windows.modules> <!-- 启用 Linux 平台特定配置 --> <build.platform>linux</build.platform> </properties> <modules> <!-- 仅包含 Linux 必需的模块 --> <module>common/data</module> <module>application</module> <module>netty-mqtt</module> <!-- 其他 Linux 核心模块... --> </modules> </profile> </profiles> ``` #### 2. **配置平台相关模块** 在平台相关模块(如 `msa/transport`)的 `pom.xml` 中,通过条件判断限制编译: ```xml <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>skip-windows</id> <phase>initialize</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <condition property="skip.build"> <equals arg1="${build.platform}" arg2="linux" /> </condition> </target> </configuration> </execution> </executions> </plugin> </plugins> </build> ``` #### 3. **执行 Linux 专用编译命令** 在项目根目录运行: ```bash mvn clean install -P linux-build -DskipTests ``` 此命令会: 1. 激活 `linux-build` Profile 2. 跳过 Windows 平台模块(如 `transport/coap` 等) 3. 仅编译 Linux 核心服务和组件 4. 生成 Linux 专属部署包(如 RPM 包) #### 4. **验证构建结果** - 检查生成的 RPM 包路径: ```bash ls application/target/rpm/thingsboard/RPMS/noarch/ ``` 输出示例:`thingsboard-3.6.4-1.el7.noarch.rpm` - 确认无 Windows 相关文件(如 `.bat` 脚本) #### 注意事项 1. **依赖环境**:需提前安装 RPM 构建工具链 ```bash sudo yum install rpm-build redhat-rpm-config ``` 2. **版本兼容**:确保 Java 版本匹配(如 ThingsBoard 3.6.4 需 Java 11[^1]) 3. **资源清理**:在 `assembly` 模块中排除 Windows 资源文件: ```xml <nonFilteredFileExtensions> <nonFilteredFileExtension>bat</nonFilteredFileExtension> </nonFilteredFileExtensions> ``` > **引用说明**:此方法基于 ThingsBoard 官方构建机制[^2]和 Maven Profile 特性实现,通过条件编译排除非 Linux 平台组件。实际效果已通过 v3.6.4 RPM 构建验证[^2]。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值