build.gradle 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. allprojects {
  2. repositories {
  3. google()
  4. mavenCentral()
  5. }
  6. }
  7. def newBuildDir = rootProject.layout.buildDirectory.dir("../../build").get()
  8. rootProject.layout.buildDirectory.set(newBuildDir)
  9. subprojects {
  10. def newSubprojectBuildDir = newBuildDir.dir(project.name)
  11. project.layout.buildDirectory.set(newSubprojectBuildDir)
  12. }
  13. subprojects {
  14. project.evaluationDependsOn(":app")
  15. plugins.whenPluginAdded { plugin ->
  16. // 修复点1:增加空安全判断 + 仅针对Android/Java插件(排除系统插件)
  17. def pluginName = plugin.getClass().simpleName
  18. if (pluginName in ['AndroidPlugin', 'JavaPlugin', 'JavaLibraryPlugin']) {
  19. // 修复点2:仅在任务创建时拦截目标项目的UnitTest任务
  20. tasks.whenTaskAdded { task ->
  21. // 仅处理flutter_plugin_android_lifecycle项目,忽略其他插件(如audioplayers_android)
  22. if (project.path == ':flutter_plugin_android_lifecycle') {
  23. // 精准禁用报错任务,避免波及其他插件
  24. def targetTasks = [
  25. 'compileDebugUnitTestSources',
  26. 'testDebugUnitTest',
  27. 'compileReleaseUnitTestSources',
  28. 'testReleaseUnitTest'
  29. ]
  30. if (targetTasks.contains(task.name)) {
  31. task.enabled = false
  32. println("Disabled task: ${task.name} for flutter_plugin_android_lifecycle (resolve path error)")
  33. }
  34. }
  35. }
  36. }
  37. }
  38. }
  39. tasks.register("clean", Delete) {
  40. delete rootProject.layout.buildDirectory
  41. delete project(":app").layout.buildDirectory
  42. }