Home > Mobile >  How to add Gradle to existing JavaFX Project (IntelliJ)
How to add Gradle to existing JavaFX Project (IntelliJ)

Time:11-26

From this post (Creating build.gradle

Write a build script. Here is a template for JavaFX applications:

plugins {
  id "application"                              // Use Application plugin
  id "org.openjfx.javafxplugin" version "0.0.9" // Use JavaFX plugin
}

mainClassName = "my.package.Application" // Set this to your main class

repositories {
    mavenCentral()
}

javafx {
    version = "16"                  // JavaFX Version
    modules = [ "javafx.controls" ] // JavaFX modules. Add them to this array.
}

Once you have finished, import the project:

Importing the project

This may take a while depending on your internet speed.

You may have to adjust runtime configurations to use Gradle, but that shouldn't be necessary.

You may encounter the following error:

BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61

If that is the case, Reloading Gradle project

You may also need to rearrange the source folders:

enter image description here

I apologise for the cat photo, but it was just a placeholder image. I definitely didn't specifically choose it.

  • Related