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

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

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" 
] 
} 
] 
} 
] 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.

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", 
} 
] 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
分享
微博
QQ
微信
回复
2024-05-29 23:39:04
相关问题
HarmonyOS如何建立多目标的工程呢
1002浏览 • 1回复 待解决
har多目标,多值问题如何解决?
1210浏览 • 1回复 待解决
自定义hvigor任务,定制编译产物
2365浏览 • 1回复 待解决
HarmonyOS har多产物构建问题
871浏览 • 1回复 待解决
如何减小编译产物so大小
1244浏览 • 1回复 待解决
如何对编译产物进行反编译
1864浏览 • 1回复 待解决
HarmonyOS AVCastPicker组件定制问题
657浏览 • 1回复 待解决