在进行应用/服务的编译构建前,需要对工程和编译构建的Module进行设置。API Version 9、API Version 8与API Version 4~7的构建体系不同,因此在设置编译构建信息时也存在差异:
- API Version 9:需要对构建配置文件、构建脚本、应用依赖的共享包等信息进行设置。
- build-profile.json5:应用/服务构建配置文件。
- hvigorfile.ts:自定义编译构建脚本。
- oh-package.json5:应用的三方包依赖,支持共享包的依赖。
- API Version 8:需要对构建配置文件、构建脚本、应用依赖的npm包等信息进行设置。
- build-profile.json5:HarmonyOS应用/服务构建配置文件。
- hvigorfile.ts:自定义编译构建脚本。
- package.json:应用的三方包依赖,支持HAR(遵循npm标准规范)和npm包的依赖。
- API Version 4~7:需要通过build.gradle来对工程编译构建参数进行设置。
build-profile.json5(API Version 8~9)
工程级build-profile.json5
工程级build-profile.json5的示例如下所示:
{
"app": {
//工程的签名信息,可包含多个签名信息
"signingConfigs": [
{
"name": "default", //标识签名方案的名称
"type": "HarmonyOS", //标识HarmonyOS应用
//该方案的签名材料
"material": {
"certpath": "D:\\SigningConfig\\debug_hos.cer", //调试或发布证书文件,格式为.cer
"storePassword": "******", //密钥库密码,以密文形式呈现
"keyAlias": "debugKey", //密钥别名信息
"keyPassword": "******", //密钥密码,以密文形式呈现
"profile": "D:\\SigningConfig\\debug_hos.p7b", //调试或发布证书Profile文件,格式为.p7b
"signAlg": "SHA256withECDSA", //密钥库signAlg参数
"storeFile": "D:\\SigningConfig\\debug_hos.p12" //密钥库文件,格式为.p12
}
}
],
"compileSdkVersion": 9, //指定HarmonyOS应用/服务编译时的SDK版本
"compatibleSdkVersion": 9, //指定HarmonyOS应用/服务兼容的最低SDK版本
//定义构建的产品品类,如通用默认版、付费版、免费版等
"products": [
{
"name": "default", //定义产品的名称,支持定制多product目标产物,具体请参考定制多目标构建产物
"signingConfig": "default", //指定当前产品品类对应的签名信息,签名信息需要在signingConfigs中进行定义
}
]
},
"modules": [
{
"name": "entry", //模块名称
"srcPath": "./entry", //标明模块根目录相对工程根目录的相对路径
"targets": [ //定义构建的APP产物,由product和各模块定义的targets共同定义
{
"name": "default", //target名称,由各个模块的build-profile.json5中的targets字段定义
"applyToProducts": [
"default" //表示将该模块下的“default” Target打包到“default” Product中
]
}
]
}
]
}
模块级build-profile.json5
模块级build-profile.json5的示例如下所示:
{
"apiType": 'faMode', //API类型,支持FA和Stage模型
"s