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

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

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
相关问题
har多目标,多值问题如何解决?
410浏览 • 1回复 待解决
HarmonyOS如何建立多目标的工程呢
321浏览 • 1回复 待解决
自定义hvigor任务,定制编译产物
1092浏览 • 1回复 待解决
如何减小编译产物so大小
450浏览 • 1回复 待解决
如何对编译产物进行反编译
646浏览 • 1回复 待解决
#鸿蒙通关秘籍#怎样定制编译HAP?
91浏览 • 1回复 待解决
ohpm-repo上传产物如何跳过输入密码
686浏览 • 1回复 待解决
关于定制不同的product
375浏览 • 1回复 待解决