HarmonyOS Development: hvigorw, Compile and Build, Implement Command Packaging

Foreword 

this article is based on DevEco Studio 5.0.5 Release 

in the last article, we simply understood hvigorw and learned that hvigorw is an indispensable building weapon in Hongmeng’s development. In addition to helping us perform some…


This content originally appeared on DEV Community and was authored by 程序员一鸣

Foreword 

this article is based on DevEco Studio 5.0.5 Release 

in the last article, we simply understood hvigorw and learned that hvigorw is an indispensable building weapon in Hongmeng's development. In addition to helping us perform some process operations normally, hvigorw also plays a very important role, that is, the important task of compiling each hap, hsp, har and app when building the assembly line. Without it, the assembly line cannot run normally. 

What is a pipeline? Under normal circumstances, when we Build an application or meta-service, we use DevEco Studio development tools to operate. The common thing is to type our final shelf package or hap, har, hsp package through the Build option in the top navigation bar. 

Image description

Pipeline allows us to use command line tools to call Hvigor tasks for construction and build applications or meta-services through command line. The advantage of doing so is that we no longer need to rely on DevEco Studio development tools, which is convenient for us to build CI(Continuous Integration) pipeline and automatically build HAP/APP, signature, installation and operation according to our own planning time. 

One sentence is concise, that is, you can do it without manual packaging, you can use tools to automate signature packaging.

Moreover, with hvigorw, we can build our own application download platform, which can be the same as dandelion and other three-party platforms, and then similar to Android, directly packaged to test students, and no longer need to submit to Huawei's application market during the testing phase. Based on this, hvigorw, for us, has to pay attention to it. After all, Huawei's application market has an audit mechanism. The submitted test packages are often not so timely because the audit time is handed over to the testers. There is a time difference, which leads to the delay in verifying the functions and wastes a lot of time. 

How to build our own application testing platform will be explained one by one in the future. This is all a later story. In this article, we will continue to understand hvigorw and focus on several of its commands to facilitate the subsequent assembly line construction. 

hvigorw Common Commands 

when hvigorw executes relevant commands, it needs to be noted that it needs to be executed in combination with categories, otherwise the execution will fail, so what is a category? 

The products field under the build-profile.json5 file in the root project is the category information. 

Image description

clean 

the clean command is mainly responsible for cleaning up the build directory of the build product. In future automated packaging, our first command is to execute it. 

Execute the command as follows:

if you are using the DevEco Studio development tool, then the command is as follows:

 

node + hvigorw.js + -p product=Category Name clear

first of all, node can be used if you configure environment variables. No, please complete the path, for example.

If you use Command Line Tools and configure environment variables, you can directly omit node.

 

hvigorw + -p product=Category Name clear

For example, the following example completes the execution of the clean command. 

Image description

assembleHar 

the assembleHar command is primarily to build a Har package, when executing this command, you need to specify which module to build. The execution format is as follows: 

command Operation 

DevEco Studio development tools:

node + hvigorw.js + --mode module -p product=Category information -p module=module assembleHar

Command Line Tools

hvigorw + --mode module -p product=Category information -p module=module assembleHar

for example, the Har package is generated in this way. 

Image description

Similarly, when targeting modules, whether it is a static shared package or a dynamic shared package, it is also necessary to carry the upper category information, that is, the module name @ category information. 

Open Build Analyzer Build analysis 

if you want to open the Build Analyzer Build analysis for the static package when building the package, then we append the command through -- analyze = normal, to implement simple point data analysis. 

Execute the command as follows, just append it later: 

Image description

in Build, you can analyze the data: 

Image description

Image description

after the command is executed, a har package is finally generated in the static shared package in the following Directory: 

Image description

assembleHsp

The assembleHsp command is primarily to build an Hsp package, which is consistent with a static package, is nothing more than replacing assembleHar assembleHsp, and the module name and category information need to be switched. 

Image description

After the command is executed, an hsp package will be generated in the dynamic shared package. The directory is as follows: 

Image description

assembleHap 

hap type is generally our main module, that is, a module with type entry type, which is executed the command of assembleHap is the same as above, and can be changed to assembleHap, but the module name and category information need to be changed. 

Image description

After executing the command, a hap package will be generated in the main module in the following Directory: 

Image description

assembleApp 

there is a little difference between assembleApp and the above Command. The above command only generates a certain type of package separately, but does not make the final package, and the final package ends with. app; Execute the assembleApp command without specifying the module, only specifying the category information. 

Image description

After the execution, a build directory will be generated under the project, and the. app in it is our final shelf or test package. 

Image description

Related Summary 

the above are several common commands of hvigorw, which are mainly used to build different types of packages. They are also the following assembly line packaging and several commonly used commands. Therefore, they are mainly summarized. Of course, hvigorw also has some common commands. You can directly look at the introduction in official website and will not repeat them.

One thing to note is that there is defined signature information in the so-called category information, which cannot be ignored. 

This article label: Hongmeng Development Tools/DevEco Studio


This content originally appeared on DEV Community and was authored by 程序员一鸣


Print Share Comment Cite Upload Translate Updates
APA

程序员一鸣 | Sciencx (2025-06-28T03:56:08+00:00) HarmonyOS Development: hvigorw, Compile and Build, Implement Command Packaging. Retrieved from https://www.scien.cx/2025/06/28/harmonyos-development-hvigorw-compile-and-build-implement-command-packaging/

MLA
" » HarmonyOS Development: hvigorw, Compile and Build, Implement Command Packaging." 程序员一鸣 | Sciencx - Saturday June 28, 2025, https://www.scien.cx/2025/06/28/harmonyos-development-hvigorw-compile-and-build-implement-command-packaging/
HARVARD
程序员一鸣 | Sciencx Saturday June 28, 2025 » HarmonyOS Development: hvigorw, Compile and Build, Implement Command Packaging., viewed ,<https://www.scien.cx/2025/06/28/harmonyos-development-hvigorw-compile-and-build-implement-command-packaging/>
VANCOUVER
程序员一鸣 | Sciencx - » HarmonyOS Development: hvigorw, Compile and Build, Implement Command Packaging. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/06/28/harmonyos-development-hvigorw-compile-and-build-implement-command-packaging/
CHICAGO
" » HarmonyOS Development: hvigorw, Compile and Build, Implement Command Packaging." 程序员一鸣 | Sciencx - Accessed . https://www.scien.cx/2025/06/28/harmonyos-development-hvigorw-compile-and-build-implement-command-packaging/
IEEE
" » HarmonyOS Development: hvigorw, Compile and Build, Implement Command Packaging." 程序员一鸣 | Sciencx [Online]. Available: https://www.scien.cx/2025/06/28/harmonyos-development-hvigorw-compile-and-build-implement-command-packaging/. [Accessed: ]
rf:citation
» HarmonyOS Development: hvigorw, Compile and Build, Implement Command Packaging | 程序员一鸣 | Sciencx | https://www.scien.cx/2025/06/28/harmonyos-development-hvigorw-compile-and-build-implement-command-packaging/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.