[GRADLE-411] Replace doFirst and doLast with new args for createTask Created: 19/Feb/09  Updated: 04/Jan/13  Resolved: 31/Aug/09

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Improvement
Reporter: Jon Cox Assignee: Hans Dockter
Resolution: Won't Fix Votes: 0


 Description   

For the reasons described in GRADLE-410 , I prefer something like doBefore and doAfter over doFirst and doLast,
and I believe these task-creating declarators shouldn't create anonymous tasks (anon tasks are hard to 'skip').

The anon / hard-to-skip task issue got me think about whether gradle would be better just augmenting createTask,
Perhaps syntax like this might work:

createTask("hello")  {  println "hello world" }

createTask("moo",  doBefore: 'hello' )   { println  "runs before hello task" }
createTask("cow",  doAfter:  'hello')        { println  "runs after hello task" }

As I see it, the 'doAfter' feature is more useful than 'doBefore'
because you can already doBefore via dependsOn. That said,
I'm not lobbying for the removal of doBefore/doFirst because
it's a good symmetric counterpart to doAfter (it may even be
handy for keeping debug operations that wrap the target
lexically out-of-band).

Anyway, I'm hoping that by adding a few more bells & whistles
to createTask(), the overall syntax can be streamlined a bit.



 Comments   
Comment by Hans Dockter [ 31/Aug/09 ]

Hi Jon,

I think this issue is partly bases on a misunderstanding. doFirst and doLast do not affect the execution order between tasks. They just add actions to a single task. With 0.7 we have a convenience notation for doLast by saying:

task hello << { println 'Equivalent to doLast }
Generated at Wed Jun 30 11:29:25 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.