Вопрос < /strong> < /p>
В Градле есть ли способ получить текущий тип сборки во время выполнения. Например, при выполнении задачи сборки Debug < /strong>, могут ли задачи в файле build.gradle принимать решения на основе того факта, что эта задача связана с вариантом построения отладки?
Код: Выделить всё
apply plugin: 'com.android.library'
ext.buildInProgress = ""
buildscript {
repositories {
maven {
url = url_here
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
configurations {
//get current build in progress here e.g buildInProgress = this.getBuildType()
}
android {
//Android build settings here
}
buildTypes {
release {
//release type details here
}
debug {
//debug type details here
}
anotherBuildType{
//another build type details here
}
}
}
dependencies {
//dependency list here
}
repositories{
maven(url=url2_here)
}
task myTask{
if(buildInProgress=='release'){
//do something this way
}
else if(buildInProgress=='debug'){
//do something this way
}
else if(buildInProgress=='anotherBuildType'){
//do it another way
}
}
есть ли для меня способ получить именно тип сборки в mytask {} ?
Подробнее здесь: https://stackoverflow.com/questions/501 ... -in-gradle