[英]How to eliminate default build variants in android gradle
We have already different build variants in our project (dev,qa and others), making the default variants irrelevant and confusing. 我们的项目中已经有不同的构建变体(dev,qa和其他),这使得默认变体无关紧要且令人困惑。
Is there a way to completely remove the default build variants, namely debug
and release
? 有没有办法完全删除默认的构建版本,即
debug
和release
? They're already generating compiler errors that won't be fixed since they won't be supported anymore. 他们已经在生成编译器错误,由于不再受支持,因此无法修复。 I'd like them to be completely removed from existence.
我希望将它们从存在中彻底移除。
If that's not possible I'd like to make most tasks that depend on them to be obsolete as if they never existed, like assembleDebug
, compileDebugSources
, installDebug
, testDebugUnitTest
etc. 如果不可能的话,我想使大多数依赖于它们的任务过时,就好像它们永远不存在一样,例如
assembleDebug
, compileDebugSources
, installDebug
, testDebugUnitTest
等。
It's ok to override a couple of tasks and generate nice error messages, but I'm afraid I'd end up overriding lots of tasks. 可以覆盖几个任务并生成漂亮的错误消息是可以的,但是我恐怕最终会覆盖很多任务。
Putting these on build.gradle will make most if not all references to debug variant tasks to disapear. 将它们放在build.gradle上会使大多数(即使不是全部)调试变量任务引用消失。
android.variantFilter { variant ->
if(variant.buildType.name.equals('debug') ) {
variant.setIgnore(true);
}
}
It's interesting to note though that if you have another variant based on debug it will still work. 有趣的是,如果您有另一个基于debug的变体,它将仍然有效。 For example you can still run QA variant if you have it defined this way:
例如,如果您通过以下方式定义了质量检查变体,则仍然可以运行它:
buildTypes {
qa {
initWith debug
. . .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.