如何定制构建多目标产物?

如何根据不同的部署环境,不同的目标人群,不同的运行环境等,定制构建多目标产物,将同一个应用定制为不同的版本?

HarmonyOS
2024-05-28 22:27:52
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
xiaohur

请参考以下代码;

项目build-profile.json5配置dmeo如下:

{ 
"app": { 
"products": [ 
{ 
"name": "default", 
"signingConfig": "default", 
"compileSdkVersion": "4.1.0(11)", 
"compatibleSdkVersion": "4.1.0(11)", 
"runtimeOS": "HarmonyOS", 
}, 
{ 
"name": "release", 
"signingConfig": "release", 
"compileSdkVersion": "4.1.0(11)", 
"compatibleSdkVersion": "4.1.0(11)", 
"runtimeOS": "HarmonyOS", 
}, 
{ 
"name": "beta1", 
"compileSdkVersion": "4.1.0(11)", 
"compatibleSdkVersion": "4.1.0(11)", 
"runtimeOS": "HarmonyOS", 
}, 
{ 
"name": "zhaohangzhuanyong", 
"compileSdkVersion": "4.1.0(11)", 
"compatibleSdkVersion": "4.1.0(11)", 
"runtimeOS": "HarmonyOS", 
} 
], 
"buildModeSet": [ 
{ 
"name": "debug", 
}, 
{ 
"name": "beta1" 
} 
], 
"signingConfigs": [ 
{ 
"name": "release", 
"type": "HarmonyOS" 
}, 
{ 
"name": "default", 
"type": "HarmonyOS" 
} 
] 
}, 
"modules": [ 
{ 
"name": "entry", 
"srcPath": "./entry", 
"targets": [ 
{ 
"name": "release", 
"applyToProducts": [ 
"release" 
] 
} 
] 
}, 
{ 
"name": "library1", 
"srcPath": "./library1" 
}, 
{ 
"name": "library2", 
"srcPath": "./library2" 
}, 
{ 
"name": "library", 
"srcPath": "./library", 
"targets": [ 
{ 
"name": "default", 
"applyToProducts": [ 
"release" 
] 
} 
] 
} 
] 
}

target的配置在modules下面的build-profile.json5中;配置demo如下:

{ 
"apiType": "stageMode", 
"buildOption": { 
"arkOptions": { 
// "apPath": "./modules.ap" /* Profile used for profile-guided optimization (PGO), a compiler optimization technique to improve app runtime performance. */ 
} 
}, 
"buildOptionSet": [ 
{ 
"name": "release", 
"arkOptions": { 
"obfuscation": { 
"ruleOptions": { 
"enable": true, 
"files": [ 
"./obfuscation-rules.txt" 
] 
} 
} 
} 
}, 
], 
"targets": [ 
{ 
"name": "default", 
"runtimeOS": "HarmonyOS" 
}, 
{ 
"name": "ohosTest", 
} 
] 
}
分享
微博
QQ
微信
回复
2024-05-29 23:39:04
相关问题
自定义hvigor任务,定制编译产物
407浏览 • 1回复 待解决
ohpm-repo上传产物如何跳过输入密码
298浏览 • 1回复 待解决
使用specified启动模式定制入口
464浏览 • 1回复 待解决
IDE构建项目失败,该如何解决?
237浏览 • 1回复 待解决
sign包和unsign包产物之间是否有差异
236浏览 • 1回复 待解决
如何在Native侧构建一个ArkTS对象
775浏览 • 1回复 待解决
如何构建数据库ORM增删改查基础能力
538浏览 • 1回复 待解决
能否提供命令行构建
330浏览 • 1回复 待解决
自定义构建任务写入文件
360浏览 • 1回复 待解决
获取运行时编译构建参数
511浏览 • 1回复 待解决
hvigor构建过程是否有详细日志
436浏览 • 1回复 待解决
编译构建怎么编写自定义任务?
262浏览 • 1回复 待解决
编译构建报错,提示CONFIGURE_SDK_ERROR
295浏览 • 1回复 待解决