Open DaiYuANg opened 12 months ago
I have the same problem. Impossible to use the plugin with Gradle Kotlin DSL. The readme file of the plugin gives the following configuration example:
Kotlin
javafx {
modules("javafx.controls", "javafx.fxml")
platform = 'mac'
}
But it is not possible to configure the platform. It does not take a single quoted string (impossible in kotlin). The type of the property is JavaFXPlatform, but it cannot be set because gradle complains that Val cannot be reassigned It would be great if it could work like this:
platform = JavaFXPlatform.LINUX
Also, following the documentation, the configurations are not possible to set because of a Type Mismatch: it requires a configure closure instead of a string:
Kotlin
javafx {
modules("javafx.controls", "javafx.fxml")
configurations("implementation", "testImplementation")
}
@DaiYuANg
I actually was able to solve my problem, and it might help you with yours, or at least point you in the right direction. Here is how I solved it, thanks to the answer from Vampire in the Gradle Forums. You can check at the questions and answers here:
[https://discuss.gradle.org/t/how-can-i-re-declare-variants-for-a-configuration-using-gradle-kotlin-dsl/46919](Gradle Forum Question 46919)
[https://discuss.gradle.org/t/how-can-i-add-an-attribute-disambiguation-rule-for-all-configurations-in-a-project/46940](Gradle Forum Question 46940)
Here is the relevant code. What was key in my case is that the attributes were added to configurations that are resolvable:
configurations.matching {
it.isCanBeResolved && it.name.toString().contains("quarkus")
}.configureEach {
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named<Usage>(Usage.JAVA_RUNTIME))
attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named<OperatingSystemFamily>("linux"))
attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named<MachineArchitecture>("x86-64"))
}
}
When I upgraded the plugin to version 0.1.0, I encountered an Cannot choose between the following variants of JavaFX component modules error. I've already found a solution in the project's README, but my understanding of Gradle is still quite basic. Could someone help me take a look? There is my
build.gradle.kts
And there is root project
build.gradle.kts