Maven 使用Bitbucket管道构建JavaFx应用程序
我正在尝试使用bitbucket管道构建JavaFx项目。为此,我使用maven:3-jdk-8 docker映像。此Docker映像使用OpenJDK 8,而不是Oracle的OpenJDK 8(由于lincensing问题),后者不包括JavaFx部分。注意,我必须使用Java8来构建我的项目! 我遇到的问题是,我无法单独使用docker映像构建应用程序 正如在对同一问题的答复()中提出的: 我尝试使用此bitbucket-pipelines.yml来克服这种情况:Maven 使用Bitbucket管道构建JavaFx应用程序,maven,docker,javafx,bitbucket-pipelines,openjdk-8,Maven,Docker,Javafx,Bitbucket Pipelines,Openjdk 8,我正在尝试使用bitbucket管道构建JavaFx项目。为此,我使用maven:3-jdk-8 docker映像。此Docker映像使用OpenJDK 8,而不是Oracle的OpenJDK 8(由于lincensing问题),后者不包括JavaFx部分。注意,我必须使用Java8来构建我的项目! 我遇到的问题是,我无法单独使用docker映像构建应用程序 正如在对同一问题的答复()中提出的: 我尝试使用此bitbucket-pipelines.yml来克服这种情况: image: maven
image: maven:3-jdk-8
pipelines:
default:
- step:
script: # Modify the commands below to build your repository.
- apt-get update
- apt-get install -y openjfx
- mvn clean install # -B batch mode makes Maven less verbose
在步骤2中,openjfx似乎安装正确。
但在步骤3中,我得到以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project ***********: Compilation failure: Compilation failure:
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/********/******/****/MainFx.java:[7,26] package javafx.application does not exist
它仍然在抱怨JavaFx库丢失,但我不知道为什么。
在我的开发人员机器(Windows 7,jdk1.8.0_221)上,我可以毫无问题地执行maven build。以前的方法缺少的是javafx库不在类路径上。基本上,为了使maven构建工作正常,我必须将jfxrt.jar添加到类路径中。 我发现在安装javafx后的
maven:3-jdk-8
图像中,可以在以下位置找到该库:
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar
在构建运行期间将此文件添加到类路径将完成此任务
一个想法(对我来说很有用)是将这个库作为系统
范围包含在应用程序pom/dependecy部分中
在我的案例中,我为此制作了一份maven简介:
<profiles>
<profile>
<id>docker_build</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javaFX</artifactId>
<version>2.2</version>
<scope>system</scope>
<systemPath>${javafx-location}</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
为了简化此过程,我使用以下Dockerfile制作了一个Docker图像:
FROM maven:3-jdk-8
RUN apt-get update && \
apt-get install -y --no-install-recommends openjfx
COPY settings.xml /root/.m2/
它使用以下maven settings.xml文件:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/usr/share/maven/ref/repository</localRepository>
<activeProfiles>
<activeProfile>docker_build</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>docker_build</id>
<properties>
<javafx-location>/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar</javafx-location>
</properties>
</profile>
</profiles>
</settings>
/usr/share/maven/ref/repository
在前面的方法中缺少的是javafx库不在类路径上。基本上,为了使maven构建工作正常,我必须将jfxrt.jar添加到类路径中。
我发现在安装javafx后的maven:3-jdk-8
图像中,可以在以下位置找到该库:
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar
在构建运行期间将此文件添加到类路径将完成此任务
一个想法(对我来说很有用)是将这个库作为系统
范围包含在应用程序pom/dependecy部分中
在我的案例中,我为此制作了一份maven简介:
<profiles>
<profile>
<id>docker_build</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javaFX</artifactId>
<version>2.2</version>
<scope>system</scope>
<systemPath>${javafx-location}</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
为了简化此过程,我使用以下Dockerfile制作了一个Docker图像:
FROM maven:3-jdk-8
RUN apt-get update && \
apt-get install -y --no-install-recommends openjfx
COPY settings.xml /root/.m2/
它使用以下maven settings.xml文件:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/usr/share/maven/ref/repository</localRepository>
<activeProfiles>
<activeProfile>docker_build</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>docker_build</id>
<properties>
<javafx-location>/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar</javafx-location>
</properties>
</profile>
</profiles>
</settings>
/usr/share/maven/ref/repository