arm64.gradle 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. apply plugin: Arm64Plugin
  2. class Arm64Plugin implements Plugin<Project> {
  3. private Properties localProperties
  4. private Properties readPropertiesIfExist(File propertiesFile) {
  5. Properties result = new Properties()
  6. if (propertiesFile.exists()) {
  7. propertiesFile.withReader('UTF-8') { reader -> result.load(reader) }
  8. }
  9. return result
  10. }
  11. private String resolveProperty(Project project, String name, String defaultValue) {
  12. if (localProperties == null) {
  13. localProperties = readPropertiesIfExist(new File(project.projectDir.parentFile, "local.properties"))
  14. }
  15. String result
  16. if (project.hasProperty(name)) {
  17. result = project.property(name)
  18. }
  19. if (result == null) {
  20. result = localProperties.getProperty(name)
  21. }
  22. if (result == null) {
  23. result = defaultValue
  24. }
  25. return result
  26. }
  27. @Override
  28. void apply(Project project) {
  29. project.android.buildTypes {
  30. profile {
  31. initWith debug
  32. if (it.hasProperty('matchingFallbacks')) {
  33. matchingFallbacks = ['debug', 'release']
  34. }
  35. }
  36. dynamicProfile {
  37. initWith debug
  38. if (it.hasProperty('matchingFallbacks')) {
  39. matchingFallbacks = ['debug', 'release']
  40. }
  41. }
  42. dynamicRelease {
  43. initWith debug
  44. if (it.hasProperty('matchingFallbacks')) {
  45. matchingFallbacks = ['debug', 'release']
  46. }
  47. }
  48. }
  49. String flutterRoot = resolveProperty(project, "flutter.sdk", System.env.FLUTTER_ROOT)
  50. // 原始jar包文件
  51. def zipFile = file("$flutterRoot/bin/cache/artifacts/engine/android-arm64-dynamic-release/flutter.jar")
  52. // 解压缩目标目录
  53. def outputDir = file("$flutterRoot/bin/cache/artifacts/engine/android-arm64-dynamic-release/dist")
  54. // FileTree jarTree = zipTree(zipFile)
  55. //
  56. // from jarTree
  57. // into outputDir
  58. }
  59. }