0

有没有办法对要重用的 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 }

这样的事情可能吗?

4

1 回答 1

0

阅读文档后,如果您正在构建buildType另一个,则可以使用initWith.

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

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

于 2017-11-13T21:15:18.033 回答