Search code examples
gradleplantumlgradle-task

Plugin extension name clash with task name


I have a plugin that has same name for its plugin extension and for task name (both are named plantUml).

I would like to run task before build. How can I do that?

When I type:

build dependsOn: plantUml

then I get information that it cannot be applied to plugin extension.


Solution

  • It is possible to reference tasks via their names in methods like dependsOn and finalizedBy. This should be possible in both the Groovy and the Kotlin syntax:

    build.dependsOn 'plantUml'
    

    Tasks can also be referenced via the TaskContainer. The method getAt(...) provides a task based on its name. This method gets mapped to the array syntax in Groovy:

    build.dependsOn tasks['plantUml']