vach
vach

Reputation: 11377

Gradle protobuf custom task

Given this protobuf gradle configuration:

protobuf configuration

When we execute generateProto task (which is generated by protobuf plugin) we will get following output:

output

As you can see the custom defined task cleanProto is getting executed before generateProto.

Why is it executing at all if I havent defined dependency between those tasks?

Upvotes: 1

Views: 1620

Answers (1)

Opal
Opal

Reputation: 84786

Actually.. it's not executed at all. The println statement is executed at configuration phase, not at execution phase. To verify it, change cleanProto to:

task cleanProto << {
   println 'deleting gen'
   delete 'gen'
}

Now, it won't execute at all if no dependency is defined. With << an action is added. Actions are run during execution phase.

Please have a look at this answer as well.

P.S. Next time instead of providing images of the code, copy and paste it. You can use cmd+k combination - on Mac.

Upvotes: 3

Related Questions