1

I have defined a task in a gradle file as shown below:

task groupTherapy (dependsOn: yayGradle2) << {
    println 'This is not fun!'
}

I believe that below are the methods that get called when a task is defined:

Task    task(Map<String,?> args, String name)

Task    task(Map<String,?> args, String name, Closure configureClosure)

Task    task(String name)

Task    task(String name, Closure configureClosure)

Can you please explain me in my case which of these methods will get invoked? And help me understand why?

Opal
  • 81,889
  • 28
  • 189
  • 210
Ajay
  • 2,976
  • 2
  • 28
  • 35
  • Forgot to mention that I am new to gradle and groovy. – Ajay Oct 14 '15 at 13:20
  • 1
    This is what you might be looking for: http://stackoverflow.com/questions/27584463/understing-the-groovy-syntax-in-a-gradle-task-definition/27584555#27584555 – Opal Oct 14 '15 at 13:21
  • Thanks. That Helped. :) – Ajay Oct 14 '15 at 13:25
  • but still I want to know , how the " dependsOn: yayGradle2 " gets interpreted ? is that also a AST transformation ? any idea Opal ? – Ajay Oct 14 '15 at 13:27
  • 2
    This is just a `Map`. – Opal Oct 14 '15 at 13:30
  • 2
    In this particular case the first one will be invoked. – Opal Oct 14 '15 at 13:37
  • have you upvoted the answer I linked? May I add the asnwer to be accepted? – Opal Oct 15 '15 at 06:31
  • Hi Opal please add the answer I will accept it. One more thing , I understand that "dependsOn: yayGradle2" will be passed as a Map, what about the name of the task ? – Ajay Nov 09 '15 at 13:31
  • Here you are. The name will be extracted and passed as a `String` argument. – Opal Nov 09 '15 at 13:35

1 Answers1

1

Here you can find an answer that might be interesting. dependsOn: yayGradle2 will be passed as an instance of Map. The name of the task will be extracted internally by gradle and passed as a name.

Community
  • 1
  • 1
Opal
  • 81,889
  • 28
  • 189
  • 210