AresTransform.groovy 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package com.gradle
  2. import org.gradle.api.Project
  3. /**
  4. * Created by Glen on 2017/2/7.
  5. */
  6. public class AresTransform extends ModifyClassTransform {
  7. public AresTransform(Project project) {
  8. super(project);
  9. }
  10. @Override
  11. protected void handleChangedFile(File input) {
  12. String path = input.absolutePath.replace("/", "\\")
  13. if (input.isFile()) {
  14. debug("changed:" + input.absolutePath)
  15. if (path.endsWith(".class")) {
  16. modifyClass(input)
  17. } else if (path.endsWith(".jar")) {
  18. if (path.contains("exploded-aar")) {
  19. if (!path.contains("com.android.support")) {
  20. // //需要处理的jar包
  21. // File tmp = new File(input.getParent() + File.separator + "tmp")
  22. // tmp.deleteOnExit()
  23. // boolean modify = false
  24. // if (!modify) JarZipUtil.unzipJar(input, tmp.absolutePath)
  25. // tmp.eachFileRecurse { File file ->
  26. // if (file.isFile()) {
  27. // if (modifyClass(file)) {
  28. // modify = true
  29. // }
  30. // }
  31. // }
  32. // if (modify) JarZipUtil.zipJar(tmp.absolutePath, input)
  33. }
  34. }
  35. }
  36. }
  37. }
  38. /**
  39. * 修改类文件
  40. * @param clazz
  41. * @return
  42. */
  43. private boolean modifyClass(File clazz) {
  44. debug("modify:" + clazz.absolutePath)
  45. return false
  46. }
  47. }