Android Gradle 组通用属性
Android Gradle Group Common Properties
有没有办法将 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 }
这样的事情可能吗?
阅读文档后,如果您正在构建另一个 buildType
,您可以使用 initWith
。
buildTypes {
debug {}
qa {
applicationIdSuffix = ".qa" //Duplicate
}
qa2 {
initWith qa
//Customize other properties here
}
release {}
}
我仍然想知道分组属性是否可以用于许多不相互继承的变体。
有没有办法将 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 }
这样的事情可能吗?
阅读文档后,如果您正在构建另一个 buildType
,您可以使用 initWith
。
buildTypes {
debug {}
qa {
applicationIdSuffix = ".qa" //Duplicate
}
qa2 {
initWith qa
//Customize other properties here
}
release {}
}
我仍然想知道分组属性是否可以用于许多不相互继承的变体。