I have been looking around for the proper way to include FXML and images in the build.gradle
so that they are build into the jar. I have look here and tried it but it still does not work.
Throws this error: java.lang.NullPointerException: inputStream is null.
Here is the build.gradle
(Github):
group 'com.voidustries'
version '1.0-SNAPSHOT'
sourceSets {
main {
resources {
srcDirs = ["src/main/java/com/voidustries/poly"]
includes = ["gui/layoutForm.fxml"]
}
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.1.0'
}
}
apply plugin: 'java'
apply plugin: 'org.junit.platform.gradle.plugin'
repositories {
mavenCentral()
}
dependencies {
testCompile('org.junit.jupiter:junit-jupiter-api:5.1.0')
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.1.0')
}
task wrapper(type: Wrapper) {
description = 'Generates gradlew[.bat] scripts'
gradleVersion = '4.3.1'
}
test {
testLogging {
events "passed", "skipped", "failed"
}
}
Here is GUI.java (Github):
FXMLLoader loader = new FXMLLoader();
FileInputStream fis = new FileInputStream(settings);
ResourceBundle resourceBundle = new PropertyResourceBundle(fis);
loader.setResources(resourceBundle);
Parent root = loader.load(getClass().getResourceAsStream("layoutForm.fxml"));
Platform.setImplicitExit(false);
The stacktrace says that loader.load(getClass().getResourceAsStream("layoutForm.fxml"));
is causing the error
Here is the source Tree:
com
└───voidustries
└───poly
│ CustomFormatter.java
│ Main.java
│ PolyThreads.java
│ SysTray.java
│
├───gui
│ Controller.java
│ GUI.java
│ Icon.png
│ layoutForm.fxml
│
└───img
Icon.png
you can see that layoutForm.fxml
and Icon.png
are both there in the tree
Here is the Out tree:
com
└───voidustries
└───poly
│ CustomFormatter.class
│ Main.class
│ PolyThreads.class
│ SysTray.class
│
└───gui
Controller.class
GUI.class
In the out tree they are both absent and I have been fiddling for hours trying to fix this issue. Any help would be greatly appreciated.
Also if you need more here is the Github repository