hvigorfile.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
  2. import { getHvigorNode } from '@ohos/hvigor'
  3. import { hapTasks } from '@ohos/hvigor-ohos-plugin'
  4. import * as path from 'path'
  5. // import { executeOnlineSign } from '../hw_sign/sign.js'
  6. const mModule = getHvigorNode(__filename)
  7. const ohosPlugin = hapTasks(mModule)
  8. const onlineSignHapTaskName = "onlineSignHap"
  9. const curTargetName = "default"
  10. const mModuleName = mModule.getName()
  11. const projectRootPath = process.cwd()
  12. // 若是feature模块签名,此处填写依赖的entry模块名称
  13. const entryName = '';
  14. // 注册在线签名任务和创建任务依赖
  15. const onlineSignTask = mModule.task(() => {
  16. // 构建的未签名的hap的输出根目录
  17. const moduleBuildOutputDir = path.resolve(projectRootPath, mModuleName, 'build/default/outputs/default/')
  18. // 未签名的hap包路径
  19. const inputFile = path.resolve(moduleBuildOutputDir, `${mModuleName}${entryName? '-' + entryName: ''}-default-unsigned.hap`)
  20. // 签名后的hap包路径
  21. const outputFile = path.resolve(moduleBuildOutputDir, `${mModuleName}${entryName? '-' + entryName: ''}-default-signed.hap`)
  22. // executeOnlineSign(inputFile, outputFile)
  23. }, onlineSignHapTaskName).dependsOn(`${curTargetName}@PackageHap`)
  24. // 使用在线签名,可以把离线签名任务disable掉
  25. // if (onlineSignTask.getEnabled()) {
  26. // mModule.getTaskByName(`${curTargetName}@SignHap`).setEnabled(false)
  27. // }
  28. // 将在线签名任务挂接在assembleHap任务上,如果需要在IDE上使用,assembleHap任务是固定的
  29. mModule.getTaskByName("assembleHap").dependsOn(onlineSignHapTaskName)
  30. module.exports = {
  31. ohos: ohosPlugin
  32. }