Home > database >  Disable tasks from specific plugin (maven-publish) for specific subprojects in Gradle
Disable tasks from specific plugin (maven-publish) for specific subprojects in Gradle

Time:01-04

I would like to disable all tasks which names start with 'publish' in Gradle. Something like

tasks.matching {
  it.name.startWith('publish') }.all {
    enabled = false
  }
}

Am I missing something?

EDIT: I have a multi project build and I am using convention plugins like in this example provided (https://docs.gradle.org/current/samples/sample_convention_plugins.html). For the sake of keeping a clean structure I define all tasks in one convention plugin, which applies to every subproject.

Unfortunately I do not want all tasks to be available for every plugin. E. g. I do not want the tasks that come with maven-publish (publish, generatePomFileForMavenPublication, publishToMavenLocal...) in specific subprojects.

CodePudding user response:

As a workaround I disabled all tasks in publishing-group.

// ugly workaround: disable all tasks that come with maven-publish plugin
tasks.matching { it.group == 'publishing' }.each {it.enabled = false}

I don't know if this counts as a solution, as there could be other tasks in publishing group which comes not from maven-publish.

  • Related