HarmonyOS 编译生成的hap和app文件的名称如何配置追加版本号

HarmonyOS 编译生成的hap和app文件的名称如何配置追加版本号

HarmonyOS
2024-08-23 12:36:17
926浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zbw_apple

参考链接:

https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/ide-hvigor-plugin-0000001778674577-V5

请参考如下Hvigor自定义插件:

interface OhPackage { 
  name: string; 
  version: number; 
  description: string; 
  author: string; 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

动态修改hap包名,模块级的hvigor-file.ts:

import { hapTasks,OhosPluginId } from '@ohos/hvigor-ohos-plugin'; 
import { hvigor } from '@ohos/hvigor' 
const name = 'name' 
const version = '1.0.3' //都可以调用其他api动态获取对应信息 
const artifactName = name + '-' + version 
 
hvigor.afterNodeEvaluate((hvigorNode)=>{ 
  const context = hvigorNode.getContext(OhosPluginId.OHOS_HAP_PLUGIN) 
  if (context && context.getBuildProfileOpt) { 
    const buildProfile = context.getBuildProfileOpt(); 
    const targets = buildProfile.targets 
    for (const target of targets) { 
      if (target.name === 'default') {//这个'default'可以通过接口获取到当前target的名称,此处不写了 
        target['output']={ 
          "artifactName": artifactName 
        } 
      } 
    } 
    context.setBuildProfileOpt(buildProfile); 
  } 
}) 
 
export default { 
  system: hapTasks,  /* Built-in plugin of Hvigor. It cannot be modified. */ 
  plugins:[]         /* Custom plugin to extend the functionality of Hvigor. */ 
}
  • 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.
分享
微博
QQ
微信
回复
2024-08-23 15:31:32
相关问题
HarmonyOS APP版本名称版本号获取
1231浏览 • 1回复 待解决
如何获取app/系统版本号
1212浏览 • 1回复 待解决
HarmonyOS如何获取当前app版本号code
1687浏览 • 1回复 待解决
HarmonyOS 如何获取当前APP版本号
1045浏览 • 1回复 待解决
HarmonyOS 模块版本号怎么统一配置
1630浏览 • 1回复 待解决
如何获取App版本号版本名等信息
5422浏览 • 1回复 待解决
HarmonyOS 代码怎么获取APP版本号
817浏览 • 1回复 待解决
stage模型怎么获取app版本号信息
2873浏览 • 1回复 待解决
HarmonyOS 如何获取系统版本号
922浏览 • 1回复 待解决
HarmonyOS 版本号如何获取
900浏览 • 1回复 待解决
HarmonyOS 获取版本号
868浏览 • 1回复 待解决
如何查看手机支持版本号
8710浏览 • 1回复 待解决
安卓app如何判断鸿蒙系统及版本号
3255浏览 • 1回复 待解决