henrikhorbovyi
04/04/2020, 7:04 PMwasyl
04/04/2020, 7:28 PMbuildSrc
is evaluated before the project is configured. You can think of buildSrc
as a separate plugin you’d import, it doesn’t have any knowledge about the project where it’s used.
What kind of logic is it?wasyl
04/04/2020, 7:29 PMBuildConfig.DEBUG
in the context of Gradle configuration — what if you build both debug and release variants in the same Gradle invocation? (for example ./gradlew app:assembleDebug app:assembleRelease
)henrikhorbovyi
04/04/2020, 8:02 PMhenrikhorbovyi
04/04/2020, 8:04 PMapplicationVariants.all { variant ->
if (variant.buildType.name == "release"){
variant.assemble.doFirst {
executeSomething()
}
} else if (variant.buildType.name == "homolog") {
variant.assemble.doFirst {
}
}
}
henrikhorbovyi
04/04/2020, 8:05 PMhenrikhorbovyi
04/04/2020, 8:05 PMhenrikhorbovyi
04/04/2020, 8:05 PMhenrikhorbovyi
04/04/2020, 8:05 PMwasyl
04/04/2020, 8:23 PMapplicationVariants.configureEach { }
wasyl
04/04/2020, 8:25 PMwasyl
04/04/2020, 8:28 PMassembleRelease
and assembleHomolog
tasks — these are well defined and part of the API (I think). So you don’t need to search for variants first, just do project.tasks.named("assembleDebug") { taskProvider -> taskProvider.dependsOn("yourTaskName") }
. You then also need to register a yourTaskName
task in the project, but that’s what you shoud aim to do with Gradle anyway (model your work using Tasks, not doFirst/doLast blocks)henrikhorbovyi
04/04/2020, 8:36 PM