Android Gradle Group Common Properties

问题描述 投票:0回答:1

有没有办法将gradle属性分组重用?我可以通过重复属性来完成以下操作,但我试图通过将它们分组在一个公共位置来避免这种情况。我有以下构建类型

buildTypes {
    debug {}
    qa {
        applicationIdSuffix = ".qa" //Duplicate
    }
    qa2 {
        applicationIdSuffix = ".qa" //Duplicate
    }
    release {} 
}

flavors { 
    flagship {}
    other1 {}
    other2 {}
}

我已经定义了不同的风格,所以我认为我不能将公共属性放在不同的风格中。我希望我能做点什么

def commonQaProps {
   applicationIdSuffix = ".qa"
   //Other properties
}

然后有

qa { commonQaProps }
qa2 { commonQaProps }

这样的事情可能吗?

android gradle android-gradle android-build-type
1个回答
0
投票

阅读文档后,如果你正在建立一个buildType,你可以使用initWith

buildTypes {
    debug {}
    qa {
        applicationIdSuffix = ".qa" //Duplicate
    }
    qa2 {
        initWith qa
        //Customize other properties here
    }
    release {} 
}

我仍然想知道分组属性是否可以用于许多不相互继承的变体。

© www.soinside.com 2019 - 2024. All rights reserved.