Gradle for Java 11 with Modules

我们两清 提交于 2019-12-05 09:03:46

The reason why it would fail for you is mostly that the automatic module name derived out of the jar that you've used would not be javafx.graphics. Trying to get the details using the command line, I could observe the following:

jar --file=.../org/openjfx/javafx-graphics/11/javafx-graphics-11.jar --describe-module
No module descriptor found. Derived automatic module.

javafx.graphicsEmpty@11 automatic
requires java.base mandated

and since the module name resolved is not same as what you've specified in the command line --add-modules javafx.graphics, hence you're facing the stated error.


Additionally, one of the notes from Run HelloWorld using JavaFX 11 reads:

there is no need to add javafx.graphics module, since it is transitively required by the javafx.controls module


Edit from comments:- Steps defined at Run HelloWorld using Gradle with JavaFX would be a better place to look for appropriate steps to build with gradle.

As it states(edits mine), one needs to specify the platform in dependencies for e.g.

compile "org.openjfx:javafx-graphics:11:$platform"

... classifiers are not taken into account when resolving transitive dependencies in Gradle. Therefore, we need to specify ... modules with platform as classifier

and for which you might need the build script used in the sample as well to specify the platform/OS as a classifier.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.gradle:osdetector-gradle-plugin:1.6.0'
    }
}

apply plugin: 'application'
apply plugin: 'com.google.osdetector'

ext.platform = osdetector.os == 'osx' ? 'mac' : osdetector.os == 'windows' ? 'win' : osdetector.os
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!