I'm trying to port existing JavaFX app to Java 9.
Here's build.gradle
plugins {
id 'application'
id 'java'
id 'org.openjfx.javafxplugin' version '0.0.9'
}
repositories {
mavenLocal()
maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
flatDir {
dirs 'libs'
}
}
group = 'ru.mydomain.myapp.fx'
version = '0.7'
description = 'myAppFX'
java.sourceCompatibility = JavaVersion.VERSION_1_9
java {
modularity.inferModulePath = true
}
sourceSets {
main {
java {
srcDirs("src/common/java", "src/fx/java")
}
resources {
srcDirs = ['src/fx/resources']
}
}
}
dependencies {
implementation 'org.slf4j:slf4j-api:1.7.25'
implementation 'com.j256.ormlite:ormlite-jdbc:5.0'
//blah-blah
}
javafx {
version = "15.0.1"
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.swing']
}
application {
mainModule = 'mymodule.javafx'
mainClass = 'ru.mydomain.myapp.fx.Main'
}
My module declaration:
module mymodule.javafx {
requires javafx.controls;
requires javafx.fxml;
requires javafx.swing;
requires slf4j.api;
requires ormlite.jdbc;
// Export the package (needed by JavaFX to start the Application)
// Replace "exports" with "opens" if "@FXML" is used in this module
opens ru.mydomain.myapp.fx;
}
Problem is in unnamed modules generated by libraries declared in gradle's dependencies. In this particular case with slf4j
. Yeahh, it's resolvable whenever I'd use newer library with declared module-info.java
, but in case when I use old libraries w/o module-info.java
I'm getting error messages like:
error: module not found: slf4j.api/ormlite.jdbc/etc...
As far as I understood problem is in so-called automatic/unnamed modules.
Any ideas, how to resolve this issue with noname modules generated by dependency libs?
Update
Exploring com.j256.ormlite:ormlite-jdbc:5.0
dependency
- It doesn't contain any
Automatic-Module-Name
in manifest - Exact jar name is:
ormlite-jdbc-5.0.jar
- Double checked - it's in compile classpath
- Exact error message is:
module-info.java:7: error: module not found: ormlite.jdbc
requires ormlite.jdbc;
^