Bitbucket's pipelines with Java Maven project and JFX

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.

2 answers

0 vote

I have the same problem. Any solutions?

0 vote
John Camp I'm New Here Apr 09, 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

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Asked 12m ago in Confluence

What are the resources that you use to learn more about Atlassian Products?

I am gathering information about resources available for Atlassian product knowledge transferring for a presentation in our local Atlassian User Group. I want to group them in four categories From ...

3 views 0 1
View question

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you