Adding an action to task.actions results in exception

Following did work with gradle 1.5:

task hello << {
 println "Some action"
  hello.actions.add(0, ({ t ->
    println "In between"
} as Action))

But in gradle 1.6 this results in an exception:

Thank you very much for the report.

Raised as GRADLE-2774.

As a workaround, you should use the ‘doFirst()’ or ‘doLast()’ methods.

I was not using this in production but just playing around. Till now I had no need to add actions this way. ‘doFirst()’ and ‘doLast()’ were sufficient so far.