У меня была похожая головная боль некоторое время назад.Я решил это, скопировав openjfx-monocle
и все расширения из папки расширений в папку под /target
, а затем установил системное свойство расширений в этот путь.Таким образом, я мог избежать NoClassDefFoundException
, а также успешно выполнить все тесты на Jenkins.Вот часть профиля:
<!--
This profile is used to make headless tests work with the Monocle Platform.
It first copies the extensions from the JDK to the target/java-extensions folder.
Then copies the openjfx-monocle implementation to the same folder.
Afterwards it sets the extensions path to the folder with the copied extensions and the monocle platform.
-->
<profile>
<id>headless-tests</id>
<activation>
<property>
<name>headless.tests</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy-external-jars</id>
<phase>generate-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target/java-extensions</outputDirectory>
<resources>
<resource>
<directory>${java.home}/lib/ext/</directory>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-monocle-to-extensions</id>
<phase>generate-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target/java-extensions</outputDirectory>
<resources>
<resource>
<directory>src/test/resources/test-lib</directory>
<includes>
<include>openjfx-monocle-8u76-b04.jar</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<argLine>-Djava.ext.dirs=${project.basedir}/target/java-extensions</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
В моем случае я скопировал банку с моноклем из maven в папку src/test/resources
.Это может быть улучшено с помощью Maven Dependency Plugin , чтобы скопировать банку монокля напрямую с maven, вместо этого, указав ее в src/test/resources
.