• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Application Package Structure in Stage Model
2<!--Kit: Ability Kit-->
3<!--Subsystem: BundleManager-->
4<!--Owner: @wanghang904-->
5<!--Designer: @hanfeng6-->
6<!--Tester: @kongjing2-->
7<!--Adviser: @Brilliantry_Rui-->
8
9This topic explores the structure of an application package in different phases of application development – development phase, build phase, and release phase.
10
11## Package Structure in the Development Phase
12Create a project in DevEco Studio and try to create multiple modules of different types. As such, first create a project in DevEco Studio and add modules of different types to the project.
13
14**Figure 1** Project structure (for reference only)
15
16![project](figures/project.png)
17
18> **NOTE**
19>
20> - The **AppScope** directory is automatically generated by DevEco Studio. If the directory name is changed, the configuration files and resources in the current directory cannot be loaded. As a result, a compilation error is reported. Therefore, do not change the directory name.
21> - The module directory name can be automatically generated by DevEco Studio (for example, **entry** and **library**) or customized. For ease of description, **ModuleName** is used below to represent the module directory name.
22
23The table below lists the main file types in the project structure.
24
25| File Type| Description|
26| -------- | -------- |
27| Configuration files| A collection of application-level and module-level configurations.<br> - **AppScope &gt; [app.json5](app-configuration-file.md)**: application-wide configuration, such as the bundle name, version number, application icon, application name, and dependent SDK version number.<br> - **ModuleName &gt; src &gt; main &gt; [module.json5](module-configuration-file.md)**: basic information, supported device types, component information, and required permissions of the module.|
28| ArkTS source code files| **ModuleName &gt; src &gt; main &gt; ets**: ArkTS source code files of the module.|
29| Resource files| A collection of application-level and module-level resource files, including images, multimedia, strings, and layout files. For details, see [Resource Categories and Access](resource-categories-and-access.md).<br> - **AppScope &gt; resources**: resource files required for the application.<br> - **ModuleName &gt; src &gt; main &gt; resources**: resource files required for the module.|
30| Other configuration files| A collection of files used for compilation and building, including build configuration files, build scripts, obfuscation rule files, and files declaring dependencies.<br> - **build-profile.json5**: [project-level](https://developer.huawei.com/consumer/en/doc/harmonyos-guides/ide-hvigor-build-profile-app) or [module-level](https://developer.huawei.com/consumer/en/doc/harmonyos-guides/ide-hvigor-build-profile) build configuration file, including the [application signature](https://developer.huawei.com/consumer/en/doc/harmonyos-guides/ide-signing) and product configuration.<br> - **hvigorfile.ts**: project-level or module-level build task script. Developers can customize the build tool version and configuration parameters that control the build behavior.<br> - **[obfuscation-rules.txt](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/ide-build-obfuscation#section760533133313)**: obfuscation rule file. When obfuscation is enabled, DevEco Studio compiles, obfuscates, and compresses code during builds in Release mode.<br> - **[oh-package.json5](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/ide-oh-package-json5)**: stores information about dependent libraries, including the dependent third-party libraries and shared packages.|
31
32
33## Package Structure in the Build Phase
34Depending on its type, a module is built into a HAP, HAR, or HSP. Below you can see the mapping between the development view (in the development phase) and the view after build and packaging (in the build phase).
35
36**Figure 2** Mapping between the development view and the view after build and packaging
37
38![app-view](figures/app-view.png)
39
40The module file is changed from the development state to the compilation state as follows:
41- **ets** directory: The ArkTS source code files are built into .abc files.
42- **resources** directory: The resource files in the **AppScope** directory are merged into this directory. If files with the same name exist in these two directories, the ones in the **AppScope** directory are retained after build and packaging.
43- Module configuration file: Fields in the **app.json5** file in the **AppScope** directory are integrated into the **module.json5** file in the **Module_name** directory, generating the final **module.json** file for the created HAP or HSP.
44
45> **NOTE**
46>
47> When the HAP and HSP are built, the HARs on which they depend are also packaged into them.
48
49## Package Structure in the Release Phase
50
51Each application contains at least one HAP and zero, one or more HSPs. The collection of HAP and HSP files in an application is called a bundle, and the bundle name is the unique identifier of the application. For details, see the **bundleName** tag in the [app.json5 configuration file](app-configuration-file.md).
52
53To release an application to the application market, the bundle must be first packed into an Application Package (App Pack) in .app format. With the packing, DevEco Studio automatically generates a **pack.info** file, which describes the attributes of each HAP and HSP in the App Pack, including the application-level information (bundle name and version code) and module-level information (name, type, and abilities).
54
55> **NOTE**
56>
57> - The App Pack is merely used to release an application to the application market and cannot be directly installed or run on devices.
58> - [Applications are signed](https://developer.huawei.com/consumer/en/doc/harmonyos-guides/ide-signing), distributed in the cloud, and installed on the device, all of which are performed in units of HAP or HSP.
59
60**Figure 3** Compilation, release, and deployment process
61
62![hap-release](figures/hap-release.png)
63