M0: 搭建多模块工程骨架(T-M0-01/T-M0-02)

- 在 entry 基础上新增 6 个 HAR:contracts/common/platform/domain_resource/feature_bridge/feature_capabilities(框架§4 工程结构)
- 依赖单向向下、无环、无传递依赖(T-M0-02):
  contracts←common←platform←domain_resource;feature_bridge←(contracts,common);
  feature_capabilities←(全部下层);entry←(全部下层)
- 各 HAR 含 build-profile/hvigorfile(harTasks)/module.json5(type:har)/Index.ets 导出入口
- devecocli build(debug) 全模块编译通过,entry 打包 HAP 成功

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
lanterngamescn
2026-06-25 06:58:29 +08:00
co-authored by Claude Opus 4.8
parent 561af47817
commit 6de9038a54
68 changed files with 848 additions and 1 deletions
+24
View File
@@ -37,6 +37,30 @@
]
}
]
},
{
"name": "contracts",
"srcPath": "./contracts"
},
{
"name": "common",
"srcPath": "./common"
},
{
"name": "platform",
"srcPath": "./platform"
},
{
"name": "domain_resource",
"srcPath": "./domain_resource"
},
{
"name": "feature_bridge",
"srcPath": "./feature_bridge"
},
{
"name": "feature_capabilities",
"srcPath": "./feature_capabilities"
}
]
}
+6
View File
@@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
+17
View File
@@ -0,0 +1,17 @@
/**
* Use these variables when you tailor your ArkTS code. They must be of the const type.
*/
export const HAR_VERSION = '1.0.0';
export const BUILD_MODE_NAME = 'debug';
export const DEBUG = true;
export const TARGET_NAME = 'default';
/**
* BuildProfile Class is used only for compatibility purposes.
*/
export default class BuildProfile {
static readonly HAR_VERSION = HAR_VERSION;
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
static readonly DEBUG = DEBUG;
static readonly TARGET_NAME = TARGET_NAME;
}
+3
View File
@@ -0,0 +1,3 @@
// common HAR —— 横切基础设施(导出入口 SSOT)
// 各子模块实现完成后在此统一 export。占位常量确保 HAR 可编译。
export const common_MODULE_VERSION: string = '1.0.0';
+28
View File
@@ -0,0 +1,28 @@
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
},
"consumerFiles": [
"./consumer-rules.txt"
]
}
}
}
],
"targets": [
{
"name": "default"
}
]
}
+1
View File
@@ -0,0 +1 @@
+6
View File
@@ -0,0 +1,6 @@
import { harTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
}
+3
View File
@@ -0,0 +1,3 @@
# Obfuscation rules for this HAR module.
# See https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/source-obfuscation
-disable-obfuscation
+19
View File
@@ -0,0 +1,19 @@
{
"meta": {
"stableOrder": true,
"enableUnifiedLockfile": false
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"contracts@../contracts": "contracts@../contracts"
},
"packages": {
"contracts@../contracts": {
"name": "contracts",
"version": "1.0.0",
"resolved": "../contracts",
"registryType": "local"
}
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"name": "common",
"version": "1.0.0",
"description": "横切基础设施:Logger/Tracer/EventBus/DIContainer/ErrorCenter",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"dependencies": {
"contracts": "file:../contracts"
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"module": {
"name": "common",
"type": "har",
"deviceTypes": [
"phone"
]
}
}
@@ -0,0 +1,8 @@
{
"string": [
{
"name": "common_desc",
"value": "common module"
}
]
}
+6
View File
@@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
+17
View File
@@ -0,0 +1,17 @@
/**
* Use these variables when you tailor your ArkTS code. They must be of the const type.
*/
export const HAR_VERSION = '1.0.0';
export const BUILD_MODE_NAME = 'debug';
export const DEBUG = true;
export const TARGET_NAME = 'default';
/**
* BuildProfile Class is used only for compatibility purposes.
*/
export default class BuildProfile {
static readonly HAR_VERSION = HAR_VERSION;
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
static readonly DEBUG = DEBUG;
static readonly TARGET_NAME = TARGET_NAME;
}
+3
View File
@@ -0,0 +1,3 @@
// contracts HAR —— 契约类型 SSOT(导出入口 SSOT)
// 各子模块实现完成后在此统一 export。占位常量确保 HAR 可编译。
export const contracts_MODULE_VERSION: string = '1.0.0';
+28
View File
@@ -0,0 +1,28 @@
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
},
"consumerFiles": [
"./consumer-rules.txt"
]
}
}
}
],
"targets": [
{
"name": "default"
}
]
}
+1
View File
@@ -0,0 +1 @@
+6
View File
@@ -0,0 +1,6 @@
import { harTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
}
+3
View File
@@ -0,0 +1,3 @@
# Obfuscation rules for this HAR module.
# See https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/source-obfuscation
-disable-obfuscation
+10
View File
@@ -0,0 +1,10 @@
{
"name": "contracts",
"version": "1.0.0",
"description": "契约类型 SSOThandler 名、DTO、Result、Errors(全工程唯一来源)",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"dependencies": {
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"module": {
"name": "contracts",
"type": "har",
"deviceTypes": [
"phone"
]
}
}
@@ -0,0 +1,8 @@
{
"string": [
{
"name": "contracts_desc",
"value": "contracts module"
}
]
}
+6
View File
@@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
+17
View File
@@ -0,0 +1,17 @@
/**
* Use these variables when you tailor your ArkTS code. They must be of the const type.
*/
export const HAR_VERSION = '1.0.0';
export const BUILD_MODE_NAME = 'debug';
export const DEBUG = true;
export const TARGET_NAME = 'default';
/**
* BuildProfile Class is used only for compatibility purposes.
*/
export default class BuildProfile {
static readonly HAR_VERSION = HAR_VERSION;
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
static readonly DEBUG = DEBUG;
static readonly TARGET_NAME = TARGET_NAME;
}
+3
View File
@@ -0,0 +1,3 @@
// domain_resource HAR —— 领域服务层(导出入口 SSOT)
// 各子模块实现完成后在此统一 export。占位常量确保 HAR 可编译。
export const domain_resource_MODULE_VERSION: string = '1.0.0';
+28
View File
@@ -0,0 +1,28 @@
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
},
"consumerFiles": [
"./consumer-rules.txt"
]
}
}
}
],
"targets": [
{
"name": "default"
}
]
}
+1
View File
@@ -0,0 +1 @@
+6
View File
@@ -0,0 +1,6 @@
import { harTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
}
+3
View File
@@ -0,0 +1,3 @@
# Obfuscation rules for this HAR module.
# See https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/source-obfuscation
-disable-obfuscation
+40
View File
@@ -0,0 +1,40 @@
{
"meta": {
"stableOrder": true,
"enableUnifiedLockfile": false
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"common@../common": "common@../common",
"contracts@../contracts": "contracts@../contracts",
"platform@../platform": "platform@../platform"
},
"packages": {
"common@../common": {
"name": "common",
"version": "1.0.0",
"resolved": "../common",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts"
}
},
"contracts@../contracts": {
"name": "contracts",
"version": "1.0.0",
"resolved": "../contracts",
"registryType": "local"
},
"platform@../platform": {
"name": "platform",
"version": "1.0.0",
"resolved": "../platform",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common"
}
}
}
}
+13
View File
@@ -0,0 +1,13 @@
{
"name": "domain_resource",
"version": "1.0.0",
"description": "领域服务层:ConfigManager/ResourceManager/AppDataInjector/VersionResolver",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common",
"platform": "file:../platform"
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"module": {
"name": "domain_resource",
"type": "har",
"deviceTypes": [
"phone"
]
}
}
@@ -0,0 +1,8 @@
{
"string": [
{
"name": "domain_resource_desc",
"value": "domain_resource module"
}
]
}
+77
View File
@@ -0,0 +1,77 @@
{
"meta": {
"stableOrder": true,
"enableUnifiedLockfile": false
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"common@../common": "common@../common",
"contracts@../contracts": "contracts@../contracts",
"domain_resource@../domain_resource": "domain_resource@../domain_resource",
"feature_bridge@../feature_bridge": "feature_bridge@../feature_bridge",
"feature_capabilities@../feature_capabilities": "feature_capabilities@../feature_capabilities",
"platform@../platform": "platform@../platform"
},
"packages": {
"common@../common": {
"name": "common",
"version": "1.0.0",
"resolved": "../common",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts"
}
},
"contracts@../contracts": {
"name": "contracts",
"version": "1.0.0",
"resolved": "../contracts",
"registryType": "local"
},
"domain_resource@../domain_resource": {
"name": "domain_resource",
"version": "1.0.0",
"resolved": "../domain_resource",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common",
"platform": "file:../platform"
}
},
"feature_bridge@../feature_bridge": {
"name": "feature_bridge",
"version": "1.0.0",
"resolved": "../feature_bridge",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common"
}
},
"feature_capabilities@../feature_capabilities": {
"name": "feature_capabilities",
"version": "1.0.0",
"resolved": "../feature_capabilities",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common",
"platform": "file:../platform",
"domain_resource": "file:../domain_resource",
"feature_bridge": "file:../feature_bridge"
}
},
"platform@../platform": {
"name": "platform",
"version": "1.0.0",
"resolved": "../platform",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common"
}
}
}
}
+8 -1
View File
@@ -5,6 +5,13 @@
"main": "",
"author": "",
"license": "",
"dependencies": {}
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common",
"platform": "file:../platform",
"domain_resource": "file:../domain_resource",
"feature_bridge": "file:../feature_bridge",
"feature_capabilities": "file:../feature_capabilities"
}
}
+6
View File
@@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
+17
View File
@@ -0,0 +1,17 @@
/**
* Use these variables when you tailor your ArkTS code. They must be of the const type.
*/
export const HAR_VERSION = '1.0.0';
export const BUILD_MODE_NAME = 'debug';
export const DEBUG = true;
export const TARGET_NAME = 'default';
/**
* BuildProfile Class is used only for compatibility purposes.
*/
export default class BuildProfile {
static readonly HAR_VERSION = HAR_VERSION;
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
static readonly DEBUG = DEBUG;
static readonly TARGET_NAME = TARGET_NAME;
}
+3
View File
@@ -0,0 +1,3 @@
// feature_bridge HAR —— 桥引擎层(导出入口 SSOT)
// 各子模块实现完成后在此统一 export。占位常量确保 HAR 可编译。
export const feature_bridge_MODULE_VERSION: string = '1.0.0';
+28
View File
@@ -0,0 +1,28 @@
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
},
"consumerFiles": [
"./consumer-rules.txt"
]
}
}
}
],
"targets": [
{
"name": "default"
}
]
}
+1
View File
@@ -0,0 +1 @@
+6
View File
@@ -0,0 +1,6 @@
import { harTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
}
+3
View File
@@ -0,0 +1,3 @@
# Obfuscation rules for this HAR module.
# See https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/source-obfuscation
-disable-obfuscation
+29
View File
@@ -0,0 +1,29 @@
{
"meta": {
"stableOrder": true,
"enableUnifiedLockfile": false
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"common@../common": "common@../common",
"contracts@../contracts": "contracts@../contracts"
},
"packages": {
"common@../common": {
"name": "common",
"version": "1.0.0",
"resolved": "../common",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts"
}
},
"contracts@../contracts": {
"name": "contracts",
"version": "1.0.0",
"resolved": "../contracts",
"registryType": "local"
}
}
}
+12
View File
@@ -0,0 +1,12 @@
{
"name": "feature_bridge",
"version": "1.0.0",
"description": "桥引擎层:BridgeController/MessageCodec/HandlerRegistry/SettingsProxy(与业务解耦,对能力零感知)",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common"
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"module": {
"name": "feature_bridge",
"type": "har",
"deviceTypes": [
"phone"
]
}
}
@@ -0,0 +1,8 @@
{
"string": [
{
"name": "feature_bridge_desc",
"value": "feature_bridge module"
}
]
}
+6
View File
@@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
+17
View File
@@ -0,0 +1,17 @@
/**
* Use these variables when you tailor your ArkTS code. They must be of the const type.
*/
export const HAR_VERSION = '1.0.0';
export const BUILD_MODE_NAME = 'debug';
export const DEBUG = true;
export const TARGET_NAME = 'default';
/**
* BuildProfile Class is used only for compatibility purposes.
*/
export default class BuildProfile {
static readonly HAR_VERSION = HAR_VERSION;
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
static readonly DEBUG = DEBUG;
static readonly TARGET_NAME = TARGET_NAME;
}
+3
View File
@@ -0,0 +1,3 @@
// feature_capabilities HAR —— 能力层(导出入口 SSOT)
// 各子模块实现完成后在此统一 export。占位常量确保 HAR 可编译。
export const feature_capabilities_MODULE_VERSION: string = '1.0.0';
+28
View File
@@ -0,0 +1,28 @@
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
},
"consumerFiles": [
"./consumer-rules.txt"
]
}
}
}
],
"targets": [
{
"name": "default"
}
]
}
+1
View File
@@ -0,0 +1 @@
+6
View File
@@ -0,0 +1,6 @@
import { harTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
}
@@ -0,0 +1,3 @@
# Obfuscation rules for this HAR module.
# See https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/source-obfuscation
-disable-obfuscation
@@ -0,0 +1,63 @@
{
"meta": {
"stableOrder": true,
"enableUnifiedLockfile": false
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"common@../common": "common@../common",
"contracts@../contracts": "contracts@../contracts",
"domain_resource@../domain_resource": "domain_resource@../domain_resource",
"feature_bridge@../feature_bridge": "feature_bridge@../feature_bridge",
"platform@../platform": "platform@../platform"
},
"packages": {
"common@../common": {
"name": "common",
"version": "1.0.0",
"resolved": "../common",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts"
}
},
"contracts@../contracts": {
"name": "contracts",
"version": "1.0.0",
"resolved": "../contracts",
"registryType": "local"
},
"domain_resource@../domain_resource": {
"name": "domain_resource",
"version": "1.0.0",
"resolved": "../domain_resource",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common",
"platform": "file:../platform"
}
},
"feature_bridge@../feature_bridge": {
"name": "feature_bridge",
"version": "1.0.0",
"resolved": "../feature_bridge",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common"
}
},
"platform@../platform": {
"name": "platform",
"version": "1.0.0",
"resolved": "../platform",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common"
}
}
}
}
+15
View File
@@ -0,0 +1,15 @@
{
"name": "feature_capabilities",
"version": "1.0.0",
"description": "能力层:每个原生能力 = 一个 CapabilityProvider 插件",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common",
"platform": "file:../platform",
"domain_resource": "file:../domain_resource",
"feature_bridge": "file:../feature_bridge"
}
}
@@ -0,0 +1,9 @@
{
"module": {
"name": "feature_capabilities",
"type": "har",
"deviceTypes": [
"phone"
]
}
}
@@ -0,0 +1,8 @@
{
"string": [
{
"name": "feature_capabilities_desc",
"value": "feature_capabilities module"
}
]
}
+6
View File
@@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
+17
View File
@@ -0,0 +1,17 @@
/**
* Use these variables when you tailor your ArkTS code. They must be of the const type.
*/
export const HAR_VERSION = '1.0.0';
export const BUILD_MODE_NAME = 'debug';
export const DEBUG = true;
export const TARGET_NAME = 'default';
/**
* BuildProfile Class is used only for compatibility purposes.
*/
export default class BuildProfile {
static readonly HAR_VERSION = HAR_VERSION;
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
static readonly DEBUG = DEBUG;
static readonly TARGET_NAME = TARGET_NAME;
}
+3
View File
@@ -0,0 +1,3 @@
// platform HAR —— 平台服务层(导出入口 SSOT)
// 各子模块实现完成后在此统一 export。占位常量确保 HAR 可编译。
export const platform_MODULE_VERSION: string = '1.0.0';
+28
View File
@@ -0,0 +1,28 @@
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
},
"consumerFiles": [
"./consumer-rules.txt"
]
}
}
}
],
"targets": [
{
"name": "default"
}
]
}
+1
View File
@@ -0,0 +1 @@
+6
View File
@@ -0,0 +1,6 @@
import { harTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
}
+3
View File
@@ -0,0 +1,3 @@
# Obfuscation rules for this HAR module.
# See https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/source-obfuscation
-disable-obfuscation
+29
View File
@@ -0,0 +1,29 @@
{
"meta": {
"stableOrder": true,
"enableUnifiedLockfile": false
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"common@../common": "common@../common",
"contracts@../contracts": "contracts@../contracts"
},
"packages": {
"common@../common": {
"name": "common",
"version": "1.0.0",
"resolved": "../common",
"registryType": "local",
"dependencies": {
"contracts": "file:../contracts"
}
},
"contracts@../contracts": {
"name": "contracts",
"version": "1.0.0",
"resolved": "../contracts",
"registryType": "local"
}
}
}
+12
View File
@@ -0,0 +1,12 @@
{
"name": "platform",
"version": "1.0.0",
"description": "平台服务层:HttpClient/Downloader/Unzipper/KvStore/PermissionGuard/LocalUploadServer/FileSystem/TaskScheduler",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"dependencies": {
"contracts": "file:../contracts",
"common": "file:../common"
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"module": {
"name": "platform",
"type": "har",
"deviceTypes": [
"phone"
]
}
}
@@ -0,0 +1,8 @@
{
"string": [
{
"name": "platform_desc",
"value": "platform module"
}
]
}