瀏覽代碼

优化gradle配置

johnclot69 3 月之前
父節點
當前提交
852fa20244
共有 2 個文件被更改,包括 59 次插入50 次删除
  1. 36 34
      incubator-common/build.gradle
  2. 23 16
      incubator-message/build.gradle

+ 36 - 34
incubator-common/build.gradle

@@ -9,39 +9,41 @@ dependencies {
     testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
     testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
 
-    //系统使用log4j2作为系统日志实现 slf4J作为门面
-//    api 'org.slf4j:slf4j-api:1.7.36'
-    api 'org.slf4j:slf4j-api:2.0.16'
-    //声明slf4j转SLF4J的桥接包
-//    api 'org.apache.logging.log4j:log4j-slf4j-impl:2.19.0'
-    api 'org.apache.logging.log4j:log4j-slf4j2-impl:2.24.1'
-    //使用log4j2作为实际的日志实现
-    api 'org.apache.logging.log4j:log4j-api:2.24.1'
-    api 'org.apache.logging.log4j:log4j-core:2.24.1'
-
-    api 'org.quartz-scheduler:quartz:2.4.0'
-    api 'com.zaxxer:HikariCP:6.2.0'
-    api 'com.mysql:mysql-connector-j:9.1.0'
-    api 'org.mybatis:mybatis:3.5.16'
-    api 'redis.clients:jedis:5.2.0'
-    api 'org.mongodb:mongo-java-driver:3.12.14'
-    api 'org.dom4j:dom4j:2.1.4'
-
-    api 'com.lmax:disruptor:3.4.4'
-
-    api 'org.msgpack:msgpack-core:0.9.8'
-
-    api 'io.netty:netty-all:4.1.115.Final'
-    api 'org.apache.commons:commons-lang3:3.17.0'
-    api 'com.dyuproject.protostuff:protostuff-core:1.3.1'
-    api 'com.dyuproject.protostuff:protostuff-runtime:1.3.1'
-    api 'org.bouncycastle:bcprov-jdk18on:1.79'
-    api 'it.unimi.dsi:dsiutils:2.7.3'
-    api 'org.reflections:reflections:0.10.2'
-    api 'com.alibaba:easyexcel:4.0.3'
-    api 'org.apache.poi:poi:5.3.0'
-    api 'org.apache.poi:poi-ooxml:5.3.0'
-    api 'cn.hutool:hutool-all:5.8.25'
+    // 日志相关
+    api 'org.slf4j:slf4j-api:2.0.16' // SLF4J API
+    api 'org.apache.logging.log4j:log4j-slf4j2-impl:2.24.2' // SLF4J -> Log4j2 桥接
+    api 'org.apache.logging.log4j:log4j-core:2.24.2' // Log4j2 实现
+
+    // 系统核心依赖
+    api 'com.lmax:disruptor:3.4.4' // 高性能队列
+    api 'org.quartz-scheduler:quartz:2.4.0' // 定时任务调度
+    api 'com.zaxxer:HikariCP:6.2.0' // 高性能数据库连接池
+    api 'com.mysql:mysql-connector-j:9.1.0' // MySQL 数据库驱动
+    api 'org.mybatis:mybatis:3.5.16' // MyBatis 持久层框架
+    api 'redis.clients:jedis:5.2.0' // Redis 客户端
+    api 'org.mongodb:mongo-java-driver:3.12.14' // MongoDB 驱动
+    api 'org.dom4j:dom4j:2.1.4' // XML 操作工具
+
+    // 网络通信和序列化
+    api 'io.netty:netty-all:4.1.115.Final' // Netty 全功能包
+    api 'org.msgpack:msgpack-core:0.9.8' // MessagePack 序列化
+    api 'com.dyuproject.protostuff:protostuff-core:1.3.1' // Protostuff 核心
+    api 'com.dyuproject.protostuff:protostuff-runtime:1.3.1' // Protostuff 运行时
+
+    // 工具和辅助库
+    api 'org.apache.commons:commons-lang3:3.17.0' // Apache Commons Lang
+    api 'org.bouncycastle:bcprov-jdk18on:1.79' // 加密库
+    api 'it.unimi.dsi:dsiutils:2.7.3' // 数据结构和算法工具
+    api 'org.reflections:reflections:0.10.2' // 反射工具
+    api 'cn.hutool:hutool-all:5.8.25' // Hutool 工具包
+
+    // Excel 操作
+    api 'com.alibaba:easyexcel:4.0.3' // EasyExcel
+    api 'org.apache.poi:poi:5.3.0' // Apache POI
+    api 'org.apache.poi:poi-ooxml:5.3.0' // Apache POI OOXML
 }
 
-build.dependsOn(copyAllDependencies)
+tasks {
+    // 清理冗余的 copyAllDependencies 任务,如有必要重新定义
+    build.dependsOn("jar")
+}

+ 23 - 16
incubator-message/build.gradle

@@ -9,37 +9,44 @@ version '1.0-SNAPSHOT'
 dependencies {
     testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
     testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
-//    implementation 'org.projectlombok:lombok:1.18.36'
 
     api 'com.alibaba.fastjson2:fastjson2:2.0.53'
     api 'com.google.protobuf:protobuf-java:4.28.3'
     api 'io.grpc:grpc-all:1.68.1'
 }
 
-build.dependsOn(copyAllDependencies)
-
-sourceSets {
-    main {
-        java {
-            srcDirs 'build/generated/source/proto/main/grpc'
-            srcDirs 'build/generated/source/proto/main/java'
-        }
-    }
-}
-
 protobuf {
-    //protobuf编译器
+    // 配置 Protocol Buffers 编译器版本
     protoc {
-        artifact = 'com.google.protobuf:protoc:4.28.3' // 使用合适的 protoc 版本
+        artifact = 'com.google.protobuf:protoc:4.28.3'
     }
+    // 配置 gRPC 插件
     plugins {
         grpc {
             artifact = 'io.grpc:protoc-gen-grpc-java:1.68.1'
         }
     }
+    // 自动为所有 proto 生成 Java 和 gRPC 代码
     generateProtoTasks {
-        all()*.plugins {
-            grpc {}
+        all().forEach {
+            it.plugins {
+                grpc {}
+            }
         }
     }
+}
+
+sourceSets {
+    main {
+        java {
+            // 将生成的代码目录添加到主代码源路径
+            srcDirs 'build/generated/source/proto/main/grpc'
+            srcDirs 'build/generated/source/proto/main/java'
+        }
+    }
+}
+
+tasks {
+    // 为构建任务添加依赖
+    build.dependsOn("generateProto")
 }