Reputation: 3060
I have an android gradle project and I'm trying to configure the buildTypes for the same. Here is a part of my build.gradle
:
android {
...
buildTypes {
debug {
println("inside debug...")
}
release {
println("inside release...")
}
}
...
}
When I run the assembleDebug task from the terminal, I get the output as:
inside debug...
inside release...
Why is the release block getting printed? What should I do to print only the debug block when I execute assembleDebug task and only the release block when I execute assembleRelease task?
I'm very new to both android and gradle, so any help will be great.
Upvotes: 3
Views: 768
Reputation: 84786
The simple answer is: they're not.
Gradle (it's a simplification) works in two phases: configuration and execution. During configuration phase the whole script is evaluated - this is why the println
statements you added do occur in the output.
To verify if both release and debug tasks are run add the following piece of code:
assembleDebug << {
println 'debug run'
}
assembleRelease << {
println 'release run'
}
With <<
an action is added, which will be executed while task is run. Actions are run during execution phase.
Upvotes: 4