Cannot set tasks dependencies on task clean (base plugin)


FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':clean'.

my build.gradle is the same from grails-gradle-plugin ( inside project description -

Same issue posted on Github:

Things tried to make it work: Commented line 33: to disable the dependencies

project.tasks.getByName(BasePlugin.CLEAN_TASK_NAME).dependsOn grailsClean

on follow file:

Don’t know if this is a issue for base plugin or something else.

Looking forward to hear back from someone Thanks in advance Yong

It’s very unlikely a Gradle issue. Looking at the file you linked to, the task name is ‘grails-clean’, not ‘grailsClean’.

Peter, grailsClean is a ref to the task. And this dependsOn is happening not thought a build.gradle file.

def grailsClean = project.tasks.create(GRAILS_CLEAN_TASK, GrailsTask).with {
            command = "clean"
            description = 'Executes Grails clean'
        project.tasks.getByName(BasePlugin.CLEAN_TASK_NAME).dependsOn grailsClean

And more interesting, I tried to changed to following:

project.tasks.getByName(BasePlugin.CLEAN_TASK_NAME).dependsOn grailsClean 'grails-clean'

It works, and why can not dependsOn a task variable?

So interesting…

The way your code uses ‘with’, the ‘grailsClean’ variable will contain the string ‘‘Executes Grails clean’’, rather than the task instance. This could be fixed by adding ‘it’ as the last statement of the closure, but it’s better to either use an overload of ‘create’ that accepts a configuration closure, or to use ‘project.configure’.

Oh, that’s why, thank you, Peter.