You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决Maven构建Gluon多模块项目的target路径错误问题?

解决GluonFX在多模块Maven项目中找不到类文件的问题

问题背景

我有一个名为meeting的父Maven项目,包含meeting-common和meeting-gui两个子模块。执行GluonFX构建命令时出现错误,错误信息显示找不到父项目下的target/classes目录,但实际类文件位于meeting-gui/target路径下。

错误堆栈信息

[Mon May 13 09:45:19 UTC 2024][SEVERE] Failed copying /home/runner/work/Meeting/Meeting/target/classes to /tmp/classes11104874000357322298: java.nio.file.NoSuchFileException: /home/runner/work/Meeting/Meeting/target/classes
Check the log files under /home/runner/work/Meeting/Meeting/target/gluonfx/aarch64-android/gvm/log
java.nio.file.NoSuchFileException: /home/runner/work/Meeting/Meeting/target/classes

使用的构建命令

mvn -Pandroid gluonfx:build gluonfx:package -pl meeting-gui -am

解决方案

1. 切换到子模块目录执行命令

直接进入meeting-gui子模块的目录下执行构建命令,GluonFX插件会默认读取当前目录的target/classes路径,匹配实际类文件位置:

cd meeting-gui
mvn -Pandroid gluonfx:build gluonfx:package

2. 在子模块POM中显式配置类路径

如果需要在父项目根目录执行命令,可在meeting-gui的POM文件中,为GluonFX插件指定正确的类文件目录:

<build>
    <plugins>
        <plugin>
            <groupId>com.gluonhq</groupId>
            <artifactId>gluonfx-maven-plugin</artifactId>
            <version>你的插件版本</version>
            <configuration>
                <mainClass>你的主类全限定名</mainClass>
                <!-- 用Maven内置变量指定子模块的classes目录 -->
                <classesDirectory>${project.build.directory}/classes</classesDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>

${project.build.directory}是Maven内置变量,会自动指向当前子模块的target目录,确保插件找到正确的类文件路径。

3. 避免父项目全局配置GluonFX插件

确保父项目的POM中没有全局配置GluonFX插件,仅在meeting-gui子模块中添加该插件配置,避免路径优先级冲突。

内容的提问来源于stack exchange,提问作者Peng

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 07:53:17