DEV Community

HarmonyOS
HarmonyOS

Posted on

HarmonyOS Build Process Configuration Files

Read the original article:HarmonyOS Build Process Configuration Files

Context

The project application contains build configuration files (hvigor-config.json5 and build-profile.json5) that define the build environment, tool versions, dependencies, and multi-product build settings. These files help manage both project-level and module-level build configurations to ensure consistency and flexibility in the build process.

Description

  • hvigor-config.json5 (stored in the hvigor directory):
    • Specifies the development version of build tools, build tasks, and dependency versions for the project.
    • Defines capabilities of the build tool, including log levels and execution policies.
    • Provides runtime node configuration and additional parameters passed to build scripts.
  • build-profile.json5:
    • Available at both project and module levels.
    • Project-level file (root directory):
      • Lists all modules in the app project (module name and path).
      • Contains basic build configurations: app name, SDK version, signature.
      • Supports multi-product builds: product and buildMode settings.
    • Module-level file:
      • Overrides project-level settings for specific modules.
      • Contains module-level API model type, target configurations, compilation, and packaging settings for ArkTS/C++ source code and resources.
  • Configuration hierarchy: Module-level settings take precedence over project-level settings when both define the same buildOption item.

Solution / Approach

  • Use hvigor-config.json5 to manage build tool versions, logging, and runtime parameters.
  • Use project-level build-profile.json5 to define global project modules, SDK version, app metadata, and multi-product configurations.
  • Use module-level build-profile.json5 for module-specific configurations, overriding project-level settings where necessary.
  • Ensure consistency in multi-product builds by properly managing module-level overrides and project-level defaults.

Key Takeaways

  • Separation of concerns: hvigor-config.json5 focuses on build tool environment; build-profile.json5 focuses on project and module-specific build options.
  • Module-level precedence: Module-specific settings override project-level settings for the same buildOption.
  • Support for multi-product builds: Configuration files provide flexibility for different products, build modes, and target API levels.
  • Customizability: Developers can tailor compilation and packaging settings for ArkTS/C++ resources per module.

Additional Resources

https://developer.huawei.com/consumer/en/doc/harmonyos-guides/ide-hvigor-configuration-file

Written by Emine Inan

Top comments (0)