The reason the task generatePomFileForMavenPublication is not accessible yet is because the plugin delays the creation of the task. You can probably make it work as such:
I’m already doing your first point at a different level in my build and everywhere I call “publish” I don’t want to add a condition that says if “my task exists” then “publish” so I’m just trying to disable the tasks.
Your afterEvaluate suggestion did not work, and after looking at the gradle source code I can’t find generatePomFileForMavenPublication and publishMavenPublicationToMavenRepository tasks anywhere so I don’t know where they are coming from.
Can you point me in the right direction to where in the gradle source those two tasks are being created?
I’m using gradel 4.4.1 – That last suggestion doesn’t work for me. Since my local maven repository is on my hard-drive, dropping the directory is actually more expedient.
In my case I want to prevent publication of any artefact form the IntegrationTesting project. The obvious answer didn’t work, viz:
publishToMavenLocal.onlyIf { false }
In the sub-project’s build.gradle file. While the task output say, “SKIPPED” but the IntegrationTest folder and contents still appear in the repository.
WHY are these tasks immune to the onlyif construct anyway!???