gpt4 book ai didi

maven - 为什么 Bitbucket 无法构建我的 JFX 项目?

转载 作者:行者123 更新时间:2023-12-04 07:16:22 25 4
gpt4 key购买 nike

我正在开发一个依赖于 JFX 实例运行的单元测试,但是当 Bitbucket 执行测试时,它在初始化 JFXPanel 时失败。

这是我的位桶管道:

pipelines:
default:
- step:
caches:
- maven
script: # Modify the commands below to build your repository.
- apt-get update && apt-get install -y openjfx

- mvn install:install-file -Dfile=lib/builder.jar -DgroupId=builder -DartifactId=builder
-Dversion=1.0 -Dpackaging=jar

- mvn clean test
@BeforeClass运行 JFXPanel:
@BeforeClass
public static void setup() {
new JFXPanel();
}

我可以在我的计算机上毫无问题地构建我的项目,但 Bitbucket 不能。

Bitbucket 测试日志:
 T E S T S
-------------------------------------------------------
Running com.abc.suapp.model.QuickCommandsTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.045 sec
Running com.abc.suapp.model.DeviceTest
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec
Running com.abc.suapp.factory.SystraceFactoryTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.224 sec <<< FAILURE!
com.abc.suapp.factory.SystraceFactoryTest Time elapsed: 0.223 sec <<< ERROR!
java.lang.UnsupportedOperationException: Unable to open DISPLAY
at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:68)
at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
at com.sun.glass.ui.Application.run(Application.java:146)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
at javafx.embed.swing.JFXPanel.initFx(JFXPanel.java:215)
at javafx.embed.swing.JFXPanel.<init>(JFXPanel.java:230)
at com.abc.suapp.factory.SystraceFactoryTest.setup(SystraceFactoryTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

我没有找到有同样问题的人。类似的问题,如在 bitbucket 上构建失败,表示它可能是缺少某些命令的管道。

最佳答案

Bitbucket 仅提供 headless test environment没有图形显示。你得到异常 java.lang.UnsupportedOperationException: Unable to open DISPLAY因为 JavaFX 默认不支持 headless 环境。

您必须安装和配置 JavaFX 的 Glass 窗口组件的 headless 实现,例如 OpenJFX 的 Monocle项目。 Monocle严重依赖 OpenJDK 的版本和 OpenJFX .有时您必须将补丁应用到 Monocle使其工作。见 OpenJFX wiki - MonocleGithub - Monocle .

如需更多信息,请参阅 JEROME'S BLOG - Testing JavaFX in headless mode和/或 Uwe's Blog - Headless UI Testing with TestFX and JavaFX 8 .

关于maven - 为什么 Bitbucket 无法构建我的 JFX 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47753749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com