openjfx / javafx-gradle-plugin

Gradle plugin that makes it easy to work with JavaFX 11+
https://openjfx.io/
BSD 3-Clause "New" or "Revised" License
347 stars 59 forks source link

Cannot compile/run with the new 'configurations' property #149

Open palexdev opened 1 year ago

palexdev commented 1 year ago

Hey @abhinayagarwal, I finally had some time to test the plugin with the recent changes. Seems like there are still issues.

If I use the configuration shown here in the README: configurations = [ 'implementation', 'testImplementation' ] I have this situation: image

If I use: configurations = [ 'compileOnly', 'testImplementation' ] I can compile, no more errors in the IDE, but when I run the application: image

The only configuration that allows me to compile and run is: configurations = [ 'compileOnly', 'runtimeOnly', 'testImplementation' ]

However, shouldn't implementation cover both of them? Am I doing something wrong?

abhinayagarwal commented 1 year ago

Yes, implementation cover both compile and runtime dependencies.

I am unable to reproduce the issue you are facing with configurations = [ 'implementation', 'testImplementation' ].

Have you tried compiling via the terminal?

This looks like an IDE cache issue.

palexdev commented 1 year ago

Yes, implementation cover both compile and runtime dependencies.

I am unable to reproduce the issue you are facing with configurations = [ 'implementation', 'testImplementation' ].

Have you tried compiling via the terminal?

This looks like an IDE cache issue.

Unfortunately I have the same issue if I use the Gradle Wrapper: image

Running ./gradlew dependecies though, seems to reveal that the JavaFX modules have not been added to implementation

To make things even more weird, the fact that JavaFX modules are correctly added for the test environment, lol what's going on haha

abhinayagarwal commented 1 year ago

I don't see an issue with the following configurations:

plugins {
  id 'application'
  id 'org.openjfx.javafxplugin' version '0.0.14'
}

repositories {
    mavenCentral()
}

javafx {
    version = '17'
    modules = [ 'javafx.controls' ]
    configurations = [ 'implementation', 'testImplementation' ]
}

mainClassName = 'HelloFX'

Running ./gradlew -q dependencies gives the following o/p:

➜  hellofx git:(master) ✗ ./gradlew -q dependencies                   

------------------------------------------------------------
Root project 'hellofx'
------------------------------------------------------------

annotationProcessor - Annotation processors and their dependencies for source set 'main'.
No dependencies

apiElements - API elements for main. (n)
No dependencies

archives - Configuration for archive artifacts. (n)
No dependencies

compileClasspath - Compile classpath for source set 'main'.
+--- org.openjfx:javafx-base:17
+--- org.openjfx:javafx-graphics:17
|    \--- org.openjfx:javafx-base:17
\--- org.openjfx:javafx-controls:17
     \--- org.openjfx:javafx-graphics:17 (*)

compileOnly - Compile only dependencies for source set 'main'. (n)
No dependencies

default - Configuration for default artifacts. (n)
No dependencies

implementation - Implementation only dependencies for source set 'main'. (n)
+--- org.openjfx:javafx-base:17 (n)
+--- org.openjfx:javafx-graphics:17 (n)
\--- org.openjfx:javafx-controls:17 (n)

...
TheBoegl commented 1 year ago

We ran into the same issue as @palexdev with gradle 7.6.1 and 8.1.1. Adding compileOnly to the configurations fixes this.

abhinayagarwal commented 1 year ago

It would be nice to have a test project where the behavior can be reproduced.

TheBoegl commented 1 year ago

It's as simple as modifying your example and use the java-library instead of the application plugin:

plugins {
  id 'java-library'
  id 'org.openjfx.javafxplugin' version '0.0.14'
}

repositories {
    mavenCentral()
}

javafx {
    version = '17'
    modules = [ 'javafx.controls' ]
    configurations = [ 'implementation', 'testImplementation' ]
}

Running ./gradlew -q dependencies shows that only the the testImplementation and therefore testCompileClasspath and testRuntimeClasspath are set as expected.