瀏覽代碼

优化gradle配置

johnclot69 2 月之前
父節點
當前提交
6b3b8ceb26
共有 1 個文件被更改,包括 13 次插入4 次删除
  1. 13 4
      build.gradle

+ 13 - 4
build.gradle

@@ -26,9 +26,18 @@ subprojects {
         options.incremental = true // 启用增量编译
     }
 
-    // 复制依赖任务,使用更现代的 `runtimeClasspath`
-    task copyAllDependencies(type: Copy) {
-        from configurations.runtimeClasspath
-        into "${buildDir}/libs/lib"
+    // 任务:复制所有依赖到指定目录
+    tasks.register('copyAllDependencies', Copy) {
+        description = 'Copies all runtime dependencies to the libs directory'
+        group = 'build' // 将任务归类到构建任务组中
+        from(configurations.runtimeClasspath) // 使用 runtimeClasspath
+        into("${buildDir}/libs/lib")
+    }
+
+    // 可选:启用 Gradle 缓存和并行化构建
+    gradle.projectsEvaluated {
+        tasks.withType(JavaCompile).configureEach {
+            options.fork = true // 启用编译器分叉,提高性能
+        }
     }
 }