But that does not work (Could not find method plugins() for arguments).
The docs mention
To customize the metadata published in the generated POM, set properties, e.g. MavenPom.getDescription(), on the POM returned via the MavenPublication.getPom() method or directly by an action (or closure) passed into MavenPublication.pom(org.gradle.api.Action)). As a last resort, it is possible to modify the generated POM using the MavenPom.withXml(org.gradle.api.Action) method.
Which looks promising but i am unable to figure out how to do that. Is there an example which could clarify how to do that type of costomization somewhere?
Why should you want to do that?
In Maven the “build recipe” and the “consumption recipe” is mixed up inside the same POM file.
The Maven plugins in a published POM has no significance at all for consumers.
Adding that to a library published with Gradle is just adding arbitrary text that does not serve any purpose.
the reason is to be able simplify distribution without having to worry about installs, os specifics etc making it possible to easily run the app by doing essentially
mvn dependency:get -Dartifact=‘my.publised.artifact’ && mvn -f “/path/to/localrepo/artifact/pom.xml” javafx:run
Ugh, that is a quite ugly abuse imho.
Maven like Gradle is a build tool not an application launcher.
You should really not do that.
If you for example use the application Gradle plugin, you can build a distributable archive that is also cross-platform and you do not have to care about OS specifics.
The only requirement is the same as with your intended method, that the user has to have a Java installation with the expected version.
If you nevertheless want to follow that strange way, then yes, you need to use withXml. The DSL only supports explicitly supported things and with the withXml hook you can freely modify the resulting POM, even though you should almost never do that.
Thanks, I was able to figure it out. It was very easy to do actually. After figuring it out, the documentation makes perfect sense Just in case it benefits someone else looking for how to do it: Just add a pom.withXml {…} after the usual pom configuration of name, , url, licenses etc. e.g: