JE42
JE42

Reputation: 5149

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 ?

Upvotes: 3

Views: 1968

Answers (1)

Eric Wendelin
Eric Wendelin

Reputation: 44349

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.

Upvotes: 3

Related Questions