Gradle PreferencesFX does something weird

I want to use PreferencesFX in a project with gradle. So I created a little demo application to test it. This is my whole controller to test PreferencesFX:
package com.example.uitests;

import com.dlsc.preferencesfx.PreferencesFx;
import com.dlsc.preferencesfx.model.Category;
import com.dlsc.preferencesfx.model.Group;
import com.dlsc.preferencesfx.model.Setting;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.fxml.FXML;
import javafx.scene.control.Label;

public class HelloController {
@FXML
private Label welcomeText;
private StringProperty test = new SimpleStringProperty();
private IntegerProperty test2 = new SimpleIntegerProperty();

@FXML
protected void onHelloButtonClick() {
welcomeText.setText("Welcome to JavaFX Application!");
PreferencesFx prefs = PreferencesFx.of(Preferences.class,
Category.of("Test",
Group.of("Test",
Setting.of("Test", test)),
Group.of("Test2",
Setting.of("Test2", test2))));
prefs.show(true);
}
}
package com.example.uitests;

import com.dlsc.preferencesfx.PreferencesFx;
import com.dlsc.preferencesfx.model.Category;
import com.dlsc.preferencesfx.model.Group;
import com.dlsc.preferencesfx.model.Setting;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.fxml.FXML;
import javafx.scene.control.Label;

public class HelloController {
@FXML
private Label welcomeText;
private StringProperty test = new SimpleStringProperty();
private IntegerProperty test2 = new SimpleIntegerProperty();

@FXML
protected void onHelloButtonClick() {
welcomeText.setText("Welcome to JavaFX Application!");
PreferencesFx prefs = PreferencesFx.of(Preferences.class,
Category.of("Test",
Group.of("Test",
Setting.of("Test", test)),
Group.of("Test2",
Setting.of("Test2", test2))));
prefs.show(true);
}
}
If I try to run it, I get the following error:
> Task :HelloApplication.main() FAILED
Error occurred during initialization of boot layer
java.lang.module.FindException: Module gson not found, required by com.dlsc.preferencesfx

Execution failed for task ':HelloApplication.main()'.
> Process 'command '/usr/lib/jvm/java-17-openjdk-amd64/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Task :HelloApplication.main() FAILED
Error occurred during initialization of boot layer
java.lang.module.FindException: Module gson not found, required by com.dlsc.preferencesfx

Execution failed for task ':HelloApplication.main()'.
> Process 'command '/usr/lib/jvm/java-17-openjdk-amd64/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
3 Replies
JavaBot
JavaBot2y ago
This post has been reserved for your question.
Hey @NeoCortex97! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
NeoCortex97
NeoCortex97OP2y ago
This is my whole build.gradle:
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'org.beryx.jlink' version '2.25.0'
}

group 'com.example'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
}

ext {
junitVersion = '5.9.2'
}

sourceCompatibility = '11='
targetCompatibility = '11'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

application {
mainModule = 'com.example.jfxmoderntest'
mainClass = 'com.example.jfxmoderntest.HelloApplication'
}

javafx {
version = '17.0.2'
modules = ['javafx.controls', 'javafx.fxml']
}

dependencies {
implementation('com.dlsc.preferencesfx:preferencesfx-core:11.8.0')

testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}

test {
useJUnitPlatform()
}

jlink {
imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip")
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'app'
}
}

jlinkZip {
group = 'distribution'
}
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'org.beryx.jlink' version '2.25.0'
}

group 'com.example'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
}

ext {
junitVersion = '5.9.2'
}

sourceCompatibility = '11='
targetCompatibility = '11'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

application {
mainModule = 'com.example.jfxmoderntest'
mainClass = 'com.example.jfxmoderntest.HelloApplication'
}

javafx {
version = '17.0.2'
modules = ['javafx.controls', 'javafx.fxml']
}

dependencies {
implementation('com.dlsc.preferencesfx:preferencesfx-core:11.8.0')

testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}

test {
useJUnitPlatform()
}

jlink {
imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip")
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'app'
}
}

jlinkZip {
group = 'distribution'
}
I know that PreferencesFX tells you to use the following to add it as a dependency:
dependencies {
compile group: 'com.dlsc.preferencesfx', name: 'preferencesfx-core', version: '11.8.0'
}
dependencies {
compile group: 'com.dlsc.preferencesfx', name: 'preferencesfx-core', version: '11.8.0'
}
But compile is deprecated and no longer available. What construct should I use to replace it, or what would be the correct way to do this? My module-info.java:
module com.example.uitest {
requires javafx.controls;
requires javafx.fxml;

requires com.dlsc.preferencesfx;

opens com.example.uitest to javafx.fxml;
exports com.example.uitest;
}
module com.example.uitest {
requires javafx.controls;
requires javafx.fxml;

requires com.dlsc.preferencesfx;

opens com.example.uitest to javafx.fxml;
exports com.example.uitest;
}
JavaBot
JavaBot2y ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.
Want results from more Discord servers?
Add your server