Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket's pipelines with Java Maven project and JFX

Thibault Douzon November 19, 2017

Hi everyone, my team and I have a maven project using jdk1.8 (not open jdk) and javaFX for our UI. It's working well and there still a lot of work to do and we'd like to use the pipelines from Bitbucket to make continuous integration on the go.

I tried to use a simple .yml file :

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

But there is my problem, We are developping with IntelliJ and jdk1.8 where javaFX is standard and automatically included in the project. But the pipelines tries to use openjdk1.8, and can't find the javaFX classes (especially the jfxrt.jar file).

If I do nothing and try as it is, the Maven error is :

[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

 I tried to include the jfxrt.jar file to maven to my pom.xml as a system dependency like that :

<dependency>
            <groupId>javafx</groupId>
            <artifactId>jfxrt</artifactId>
            <version>${java.version}</version>
            <scope>system</scope>
            <systemPath>${java.home}/lib/ext/jfxrt.jar</systemPath>
</dependency>

But then Maven warns me he does not find the jfxrt.jar file :

[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

Mainly because he is using openjdk and not jdk.

 

I also tried to put the jfxrt.jar file inside the repository and make a dependency to it, it works but Maven warns me it's not proper to do it like that :

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>javafx</artifactId>
            <version>2.0</version>
            <scope>system</scope>
            <systemPath>${basedir}/dependency/jfxrt.jar</systemPath>
        </dependency>

and the warning :

[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.

My question is how to either force Maven to use JDK and not OpenJDK (in Bitbucket !), or how to make a nice dependency to javaFX so Maven can verify our project everytime we push and not warn us.

 

Thank you all for your future responses.

3 answers

0 votes
François February 19, 2020

I've had the same issue: you need to find an image that has javafx libraries

image: hbongen/openjfx-maven:latest

pipelines:
default:
- step:
caches:
- maven
script:
- apt-get update
- apt-get install -y openjfx
- mvn -B verify -P bitbucket_pipeline -Djavafx-location=/usr/share/java/openjfx/jre/lib/ext/jfxrt.jar
0 votes
John Camp April 9, 2018

The problem is that the docker image doesn't support JavaFX.

There are two solutions:

1) Find an image with openjfx on hub.docker.com.  This is preferred, since it takes fewer build minutes than the next solution.

2) Install openjfx before building.  At the beginning of your script block, add:

- apt update
- apt install openjfx -y
0 votes
Evgeniy Egorov December 28, 2017

I have the same problem. Any solutions?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events