Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all tasks associated with buildType?

I am using the android experimental plugin 0.4 ( gradle 2.8 ) and would like to modify all tasks that are associated with a buildType; debug in my case.

Currently, I am using the following "hack":

tasks.all {
   if( it.name.contains("Debug") ) {
     print it.name
   }
}

Is there a more typesafe way ?

like image 401
JE42 Avatar asked Nov 29 '25 14:11

JE42


1 Answers

I don't know much about this specific plugin, but a better way to do this with the Gradle API might be:

tasks.withType(AndroidTask).all {
  print it.name
}

Where AndroidTask is a Class reference. You'll have to look at the sources of the plugin to figure out the exact class. They also provide tasks.matching {}. Check out the TaskCollection GroovyDocs for specific usage.

like image 172
Eric Wendelin Avatar answered Dec 01 '25 18:12

Eric Wendelin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!