defaultTasks not run

I am trying to enable the some of the tasks from the eclipse plugin to my default tasks:

apply plugin: 'eclipse'
defaultTasks 'cleanEclipseClasspath', 'eclipseClasspath'

but when I run gradle build the above tasks are not run. Is it only possible to use defaultTasks for tasks defined in the build.gradle file?

Default tasks only take effect when you run Gradle without explicitly specifying any tasks.

So Peter, how do you force a task to execute every time a script is run, no matter what tasks are specified?

You could declare a dependency from all other tasks on that task (generically of course), or fiddle with ‘gradle.startParameter.taskNames’.

Just what I needed, thanks Peter.