Slackbot
08/15/2023, 10:13 PMsamypr100
08/15/2023, 10:19 PMthirdPartyCompatibility
if it makes sense.samypr100
08/15/2023, 10:37 PMError: Two versions of module javafx.base found in /path/to/build/jlinkbase/jlinkjars (javafx-base-20.0.2-linux.jar and javafx-base-20.0.2-mac-aarch64.jar)
> Task :jlink FAILED
java.lang.module.FindException: Two versions of module javafx.base found in /path/to/build/build/jlinkbase/jlinkjars (javafx-base-20.0.2-linux.jar and javafx-base-20.0.2-mac-aarch64.jar)
I've confirmed this is resolved as soon as I remove the thirdPartyCompatibility
section on the local .m2 version and using mavenLocal()
on the consuming project.Vampire
08/16/2023, 7:46 AMwithXml
hack for POMs, but instead the modeling of the project should be fixed to produce the intended result, which should then also produce the correct POM without manipulation ..... in almost all cases.
With JavaFX the problem is, that the JavaFX Gradle plugin you probably use - which also is not configuration-cache compatible -, configures those classified dependencies as dependencies, and so they end up in the GMM.
Besides making JavaFX rething their publication strategy, which I would greatly welcome, I guess in that case you have to hook into the task that generates the GMM and add a doLast
action to it, that does the manipulation you need.samypr100
08/16/2023, 1:39 PMthe JavaFX Gradle plugin you probably use - which also is not configuration-cache compatibleAre the alternatives here if I don't use the plugin? Let's say purely
implementation "org.openjfx:javafx-base:${javafxVersion}"
implementation "org.openjfx:javafx-graphics:${javafxVersion}"
implementation "org.openjfx:javafx-controls:${javafxVersion}"
implementation "org.openjfx:javafx-swing:${javafxVersion}"
That's basically what I have on my build.gradle
For your suggestion
hook into the task that generates the GMM and add aIs something like this what you had in mind (e.g. modify the json output)? Or are there other more official approaches I should follow here?action to it, that does the manipulation you need.doLast
tasks.withType(GenerateModuleMetadata).configureEach {
doLast { _ ->
def gmmFile = it.outputFile.get().asFile
def inJson = new JsonSlurper().parseText(gmmFile.text)
def filteredVariant = inJson.variants.findAll { it.name == configurations.runtimeElements.name }
// remove "thirdPartyCompatibility" from GMM
filteredVariant.dependencies.first().each {
if (it.group == 'org.openjfx') {
it.remove('thirdPartyCompatibility')
}
}
def outJson = JsonOutput.toJson(inJson)
gmmFile.write(JsonOutput.prettyPrint(outJson))
}
}
Vampire
08/16/2023, 2:08 PMAre the alternatives here if I don't use the plugin?Well, the JARs in those non-classified coordinates is empty, so you cannot compile or run against them if you are actually using JavaFX. You could maybe have those as
implementation
dependencies and manually add the classified dependency as compileOnly
dependency so that your compilation works and manually add them to classpaths of any tasks that need them at runtime.
Is something like this what you had in mind (e.g. modify the json output)?Without looking in-depth, yes.
Or are there other more official approaches I should follow here?No, as far as I know there is not official "manipulate the GMM" facility as official stanza is to fix the modelling of the build so that the correct result is produced. You could open a feature request ticket to add such a facility with your use-case. Maybe they then add it or come up with some different way how to properly model it.
samypr100
08/16/2023, 4:41 PM