I am attempting to startup a gRPC client with Java...
# community-support
e
I am attempting to startup a gRPC client with JavaFX, but when I try to run it, I get the following message
Copy code
> Cannot choose between the available variants of org.openjfx:javafx-controls:23.0.1:
          - linux-aarch64Runtime
          - linuxRuntime
          - mac-aarch64Runtime
          - macRuntime
          - runtime
          - winRuntime
I have been at this all day and cannot figure out for the life of me what's going on. I have tried all kinds of things. My latest attempt includes running this bit of code in my build.gradle file in the hopes of pointing explicitly to the location of the JavaFX installation to avoid any ambiguity:
Copy code
def javafxHome = System.getenv('JAVAFX_HOME')
tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'
    options.fork = true
    options.compilerArgs.addAll(['-Xlint:deprecation','-Xlint:unchecked','-Xlint:preview'])
    options.compilerArgs.addAll(['--module-path',javafxHome+File.separator+'lib'])
    sourceCompatibility='23'
    targetCompatibility='23'
}
I have of course already added these plugins:
Copy code
plugins {
    id('java')
    id("application")
    id('idea')
    id("com.github.johnrengelman.shadow") version "8.1.1"
    id("io.micronaut.application") version "4.4.4"
    id("com.google.protobuf") version "0.9.2"

    id("org.openjfx.javafxplugin") version "0.1.0"
}

javafx {
    version = "23.0.1"
    modules = [ 'javafx.controls', 'javafx.graphics', 'javafx.base' ]
}
Is anyone able to shed any light on this? I am confounded.
t
ah the javafx thing is superspecial and doesnt work very well. so the javafx block also has a configurations block where you need to configure on which configurations it actually runs. The configuration name that fails should be somewhere in the error message
e
Hey @TheGoesen This is what I see:
Copy code
[Incubating] Problems report is available at: file:///C:/Users/ealov/Downloads/ChatClient/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':extractIncludeProto'.
> Could not resolve all files for configuration ':compileProtoPath'.
   > Cannot resolve external dependency io.micronaut:micronaut-discovery-core because no repositories are defined.
     Required by:
         root project :
   > Cannot resolve external dependency io.micronaut.grpc:micronaut-grpc-runtime because no repositories are defined.
     Required by:
         root project :
   > Cannot resolve external dependency io.micronaut.grpc:micronaut-grpc-client-runtime because no repositories are defined.
     Required by:
         root project :
   > Cannot resolve external dependency io.micronaut.serde:micronaut-serde-jackson because no repositories are defined.
     Required by:
         root project :
   > Cannot resolve external dependency javax.annotation:javax.annotation-api because no repositories are defined.
     Required by:
         root project :
   > Cannot resolve external dependency com.google.cloud.trace:java-timestamp:0.2.2 because no repositories are defined.
     Required by:
         root project :
   > Cannot resolve external dependency io.micronaut:micronaut-inject because no repositories are defined.
     Required by:
         root project :
   > Cannot resolve external dependency org.openjfx:javafx-base:23.0.1 because no repositories are defined.
     Required by:
         root project :
   > Cannot resolve external dependency org.openjfx:javafx-graphics:23.0.1 because no repositories are defined.
     Required by:
         root project :
   > Cannot resolve external dependency org.openjfx:javafx-controls:23.0.1 because no repositories are defined.
     Required by:
         root project :
   > Cannot resolve external dependency io.micronaut.platform:micronaut-platform:4.7.2 because no repositories are defined.
     Required by:
         root project :

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to <https://docs.gradle.org/8.11.1/userguide/command_line_interface.html#sec:command_line_warnings> in the Gradle documentation.

BUILD FAILED in 1s
I don't see any mention of configuration in there - do you?
t
Could not resolve all files for configuration ':compileProtoPath'.
so thats your configuration: its named compileProtoPath
and in your build file you somehow set it up so your protobuf depends on javafx
And thats why its going wrong: the javafxplugin "fixes" the dependencies for some configurations, but not for all automatically. In your case: you probably really should not have javafx on your compileprotoclasspath
also the error message you pasted now doest mention available variants, instead you somehow deleted your repositories šŸ˜‰
j
JavaFX is on the protobuf classpath for some reason. This is a "special" configuration the JavaFX plugin does not know about. Maybe this can be avoided. But the Protobuf plugin is also doing some very special things. It always seems to be a fight with that one.... You can set additional attributes for the
compileProtoPath
configuration to resolve the variant conflict. Similar to what is done here for the normal classpaths: https://github.com/openjfx/javafx-gradle-plugin/blob/master/src/main/java/org/openjfx/gradle/JavaFXOptions.java#L109-L114 Something like:
Copy code
configurations.compileProtoPath {
  attributes {
    attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE,
                objects.named(OperatingSystemFamily, javafx.platform.osFamily));
    attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE,
                objects.named(MachineArchitecture, javafx.platform.arch));
  }
}
I think there is no shortcut for this in the
javafx { }
block at the moment.
t
you can really just set the configurations it runs in in the javafx block: https://github.com/openjfx/javafx-gradle-plugin/blob/master/src/main/java/org/openjfx/gradle/JavaFXOptions.java But usually javafx should not end up in the protobuff classpath at all. Also sad news even if you can figure that one out, the javafx plugin will break the configuration cache if you you use run
ah ok the configuration of the javafx only adds the dependencies it does not change the attributes got it
j
Looking at the errors again: • The first one does not show which configuration is failing - maybe it is somewhere else and not protobuf • The second error complains about missing repositories. There, something else must be broken in the setup.
e
Thanks, guys. I would have accidentally deleted the repositories. I restored it, but I'm still getting this ambiguity error. Now, instead of ":compileProtoPath" I am getting ":developmentRuntimeClasspath":
Copy code
> Task :run FAILED
[Incubating] Problems report is available at: file:///C:/Users/ealov/Downloads/ChatClient/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Could not resolve all files for configuration ':developmentRuntimeClasspath'.
   > Could not resolve org.openjfx:javafx-base:23.0.1.
     Required by:
         root project :
      > Cannot choose between the available variants of org.openjfx:javafx-base:23.0.1:
          - linux-aarch64Runtime
          - linuxRuntime
          - mac-aarch64Runtime
          - macRuntime
          - runtime
          - winRuntime
        All of them match the consumer attributes:
          - Variant 'linux-aarch64Runtime' capability 'org.openjfx:javafx-base:23.0.1':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'aarch64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'linux' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'linuxRuntime' capability 'org.openjfx:javafx-base:23.0.1':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'linux' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'mac-aarch64Runtime' capability 'org.openjfx:javafx-base:23.0.1':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'aarch64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'macos' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'macRuntime' capability 'org.openjfx:javafx-base:23.0.1':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'macos' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'runtime' capability 'org.openjfx:javafx-base:23.0.1':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'winRuntime' capability 'org.openjfx:javafx-base:23.0.1':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'windows' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
   > Could not resolve org.openjfx:javafx-graphics:23.0.1.
     Required by:
         root project :
      > Cannot choose between the available variants of org.openjfx:javafx-graphics:23.0.1:
          - linux-aarch64Runtime
          - linuxRuntime
          - mac-aarch64Runtime
          - macRuntime
          - runtime
          - winRuntime
        All of them match the consumer attributes:
          - Variant 'linux-aarch64Runtime' capability 'org.openjfx:javafx-graphics:23.0.1':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'aarch64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'linux' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'linuxRuntime' capability 'org.openjfx:javafx-graphics:23.0.1':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'linux' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'mac-aarch64Runtime' capability 'org.openjfx:javafx-graphics:23.0.1':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'aarch64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'macos' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'macRuntime' capability 'org.openjfx:javafx-graphics:23.0.1':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'macos' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'runtime' capability 'org.openjfx:javafx-graphics:23.0.1':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'winRuntime' capability 'org.openjfx:javafx-graphics:23.0.1':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'windows' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
j
I think
developmentRuntimeClasspath
is probably something out of the micronaut plugin. It makes more sense that that has JavaFX. Still that one is "special". You should be able to apply what I posted to that one.
šŸ‘ 1
Copy code
configurations.developmentRuntimeClasspath {
  attributes {
    attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE,
                objects.named(OperatingSystemFamily, javafx.platform.osFamily));
    attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE,
                objects.named(MachineArchitecture, javafx.platform.arch));
  }
}
(not sure if the syntax is 100% correct)
e
Thank you all. I got this over this hurdle thanks to you!
šŸ‘ 1