question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JavaFX plugin forces Gradle to put libraries on the modulepath instead of the classpath

See original GitHub issue

How to reproduce:

  • Gradle version 6.7.1
  • JavaFX plugin version 0.0.9

Given a modular project with a module-info.java in its main root. And the following Gradle config:

java {
  modularity.inferModulePath.set(true)
  toolchain {
    languageVersion.set(JavaLanguageVersion.of(11))
  }
}

And a non-modular test dependency, e.g. testImplementation("com.tngtech.archunit:archunit-junit5:0.14.1")

And a test case, e.g.

@AnalyzeClasses(packages = "*", importOptions =  { ImportOption.DoNotIncludeTests.class })
public class ArchitectureTest {
    @ArchTest
    public static final ArchRule CYCLE_RULE = slices().matching("..(*)..").should().beFreeOfCycles();
}

When I run the test case with Gradle 6.7.1

Expected behaviour: Then the test case runs Current behaviour: Then the test case does not run, due to a java.lang.module.ResolutionException

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
falkoschumanncommented, Jan 5, 2021

As workaround, remove javafx-gradle-plugin and add JavaFX manually:

def openjfxGroup = 'org.openjfx'
def openjfxVersion = '15.0.1'
def osName = System.properties['os.name'].toLowerCase()
def openjfxPlatform = osName.contains('mac') ? 'mac' : osName.contains('win') ? 'win' : osName.contains('linux') ? 'linux' : null

dependencies {
  api(group: openjfxGroup, name: 'javafx-base', version: openjfxVersion, classifier: openjfxPlatform)
  api(group: openjfxGroup, name: 'javafx-graphics', version: openjfxVersion, classifier: openjfxPlatform)
  api(group: openjfxGroup, name: 'javafx-controls', version: openjfxVersion, classifier: openjfxPlatform)
}

java {
  modularity.inferModulePath = true
}

This works with Gradle 6.7. All used JavaFX modules must be added because transitiv dependencies are not solved automatically. For my use case, the javafx-gradle-plugin should only resolve transitive dependencies of JavaFX module and platform.

0reactions
MrcJkbcommented, Mar 11, 2021

Sure. I’ll look into it when I have some time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to force gradle to add dependencies to the module path ...
I'm running my project in eclipse but every time I refresh the project, all dependencies are put to the class path instead of...
Read more >
JavaFX plugin forces Gradle to put libraries on the modulepath ...
JavaFX plugin forces Gradle to put libraries on the modulepath instead of the classpath.
Read more >
Gradle doesn't add modules to module-path during compile
I started a new project, which is modularized. It contains 4 dependencies, two of which is also modularized. ... requires javafx.controls; ...
Read more >
A Guide to Java 9 Modularity - Baeldung
Learn the essentials of building and using modules in Java 9. Start down the path of modularizing your code today.
Read more >
Create a new JavaFX project | IntelliJ IDEA Documentation
Make sure the JavaFX plugin is enabled · In the Settings/Preferences dialog ( Ctrl+Alt+S ), select Plugins. · Switch to the Installed tab...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found