1. Gradle构建结构(Kotlin DSL)
根目录 build.gradle.kts
|
|
子模块 settings.gradle.kts
|
|
子模块 build.gradle.kts
示例
以下是每个子模块的build.gradle.kts
配置,包含外部和内部依赖:
jdbc-driver/build.gradle.kts
1 2 3 4 5 6
dependencies { implementation(project(":sql-parser")) implementation(project(":execution-engine")) api("javax.json:javax.json-api:1.1.4") implementation("org.glassfish:javax.json:1.1.4") }
sql-parser/build.gradle.kts
1 2 3
dependencies { implementation("org.antlr:antlr4-runtime:4.13.1") }
query-optimizer/build.gradle.kts
1
// 暂无依赖
execution-engine/build.gradle.kts
1 2 3 4 5
dependencies { implementation(project(":query-optimizer")) implementation(project(":storage-engine")) implementation(project(":transaction-manager")) }
storage-engine/build.gradle.kts
1 2 3 4
dependencies { implementation(project(":metadata-manager")) implementation("org.roaringbitmap:RoaringBitmap:0.9.45") }
transaction-manager/build.gradle.kts
1
// 暂无依赖
metadata-manager/build.gradle.kts
1
// 暂无依赖
2. 外部依赖关系图
外部依赖保持不变,使用Mermaid展示:
graph TD
A[jdbc-driver] --> B[javax.json-api:1.1.4]
A --> C[javax.json:1.1.4]
D[sql-parser] --> E[antlr4-runtime:4.13.1]
F[storage-engine] --> G[RoaringBitmap:0.9.45]
- 说明:
jdbc-driver
:依赖JSON-P处理JSON数据。sql-parser
:依赖ANTLR解析SQL。storage-engine
:依赖RoaringBitmap优化索引。
3. 内部模块依赖关系图
内部依赖关系不变,使用Mermaid展示:
graph TD
A[jdbc-driver] --> B[sql-parser]
A --> C[execution-engine]
C --> D[query-optimizer]
C --> E[storage-engine]
C --> F[transaction-manager]
E --> G[metadata-manager]
- 依赖说明:
jdbc-driver
:依赖sql-parser
和execution-engine
。execution-engine
:依赖query-optimizer
、storage-engine
和transaction-manager
。storage-engine
:依赖metadata-manager
。
4. 项目目录结构
目录结构保持不变:
lightweight-database/
├── jdbc-driver/
│ └── src/main/java/com/yinlongfei/lightweight/database/jdbc/
│ └── build.gradle.kts
├── sql-parser/
│ └── src/main/java/com/yinlongfei/lightweight/database/parser/
│ └── build.gradle.kts
├── query-optimizer/
│ └── src/main/java/com/yinlongfei/lightweight/database/optimizer/
│ └── build.gradle.kts
├── execution-engine/
│ └── src/main/java/com/yinlongfei/lightweight/database/execution/
│ └── build.gradle.kts
├── storage-engine/
│ └── src/main/java/com/yinlongfei/lightweight/database/storage/
│ └── build.gradle.kts
├── transaction-manager/
│ └── src/main/java/com/yinlongfei/lightweight/database/transaction/
│ └── build.gradle.kts
├── metadata-manager/
│ └── src/main/java/com/yinlongfei/lightweight/database/metadata/
│ └── build.gradle.kts
├── build.gradle.kts
└── settings.gradle.kts
5. 使用Kotlin DSL的优势
- 类型安全:Kotlin DSL提供更好的类型检查,减少配置错误。
- 可读性:语法更简洁,接近现代编程风格。
- IDE支持:IntelliJ IDEA对Kotlin DSL有更好的自动补全支持。
6. 验证与运行
在根目录运行以下命令验证构建:
|
|
编译并打包所有模块:
|
|