DontPanic
DontPanic

Reputation: 2416

Android Studio: Where are Gradle build tasks defined?

I am trying to learn about how a gradle build works. When I do a build, I see a bunch of tasks executed, e.g.:

app:assembleDebug
app:preBuild
app:packageDebug

I would like to see exactly what these tasks are doing. I assume these are Gradle / Groovy scripts. I tried unzipping all the jars under Android Studio. Lots of stuff there, but I don't see anything relevant (I may have missed something in the voluminous listing). Are these tasks hidden within a class file? Am I looking in the wrong place?

Upvotes: 9

Views: 2484

Answers (1)

Lukas Körfer
Lukas Körfer

Reputation: 14533

All these tasks are created by the Gradle Android plugin, either the library version (com.android.library) or the application version (com.android.application). You can find the source code of these plugins in this repository.

However, it may be difficult to get insight on each task as some of them may be implemented by custom task types of the Android plugin, others may only be regular configured Gradle tasks. Also, the configuration of the tasks may be spreaded across multiple files, as many of them may be created dynamically.

But, in my opinion, it is unnecessary to know the exact functionality of each task, instead you should focus on the basic concepts of Android development and the Gradle plugin, e.g. build types and variants. The Android plugin provides a specific DSL and depending on the specified configuration, it will create the tasks automatically.

Upvotes: 5

Related Questions