我的团队和我有一个maven项目使用jdk1.8(不是打开jdk)和javaFX用于我们的UI。它运行良好,还有很多工作要做,我们希望使用Bitbucket的管道来实现持续集成。
我尝试使用一个简单的.yml文件:
image: maven:3.3.9-jdk-8
pipelines:
default:
- step:
caches:
- maven
script: # Modify the commands below to build your repository.
- mvn -B verify # -B batch mode makes Maven less verbose
但是有我的问题,我们正在开发IntelliJ和jdk1.8,其中javaFX是标准的并自动包含在项目中。但是管道尝试使用openjdk1.8,并且找不到javaFX类(尤其是jfxrt.jar文件)。
如果我什么都不做并按原样尝试,那么Maven错误就是:
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[3,26] package javafx.application does not exist
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[4,19] package javafx.fxml does not exist
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[5,20] package javafx.scene does not exist
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[6,20] package javafx.scene does not exist
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[7,20] package javafx.stage does not exist
我尝试将jfxrt.jar文件包含到我的pom.xml中作为系统依赖项,如下所示:
<dependency>
<groupId>javafx</groupId>
<artifactId>jfxrt</artifactId>
<version>${java.version}</version>
<scope>system</scope>
<systemPath>${java.home}/lib/ext/jfxrt.jar</systemPath>
</dependency>
但Maven警告我他没有找到jfxrt.jar文件:
[WARNING] 'dependencies.dependency.systemPath' for javafx:jfxrt:jar refers to a non-existing file /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar @ line 34, column 25
主要是因为他使用的是openjdk而不是jdk。
我还尝试将jfxrt.jar文件放在存储库中并对其进行依赖,但是它起作用但是Maven警告我这样做是不合适的:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>2.0</version>
<scope>system</scope>
<systemPath>${basedir}/dependency/jfxrt.jar</systemPath>
</dependency>
和警告:
[WARNING] 'dependencies.dependency.systemPath' for com.oracle:javafx:jar should not point at files within the project directory, ${basedir}/dependency/jfxrt.jar will be unresolvable by dependent projects @ line 34, column 25[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
我的问题是如何强制Maven使用JDK而不是OpenJDK,或者如何对javaFX进行良好的依赖,以便Maven可以在每次推送时验证我们的项目,而不是警告我们。
感谢大家未来的回复。
答案 0 :(得分:1)
由于Oracle的Java许可,Docker Hub不再托管包含Oracle JDK的官方映像。所有官方图片,包括the Maven one you're using,现在都基于OpenJDK。
要使用Oracle Java,您需要build your own Docker image as the Pipelines build environment(相对简单),或者在其中找到包含JDK的Docker镜像的可靠来源。 (通过谷歌搜索很容易找到这些,因为这是一个常见的问题。)
答案 1 :(得分:0)
Frist:JavaFX是OpenJDK的一部分。自从piplines公开测试版以来,这个设置对我有用:
yaml文件
image: maven:3.3.3
pipelines:
default:
- step:
script: # Modify the commands below to build your repository.
- mvn clean install
这里是pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.group.id</groupId>
<artifactId>my.artifact.id</artifactId>
<name>my.app.name</name>
<version>1.0.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- goal is 'mvn jfx:jar' -->
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.7.0</version>
<configuration>
<mainClass>package.to.my.main.class</mainClass>
</configuration>
<executions>
<execution>
<id>create-jfxjar</id>
<phase>package</phase>
<goals>
<goal>build-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>