123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package com.gradle
- import org.gradle.api.Project
- /**
- * Created by Glen on 2017/2/7.
- */
- public class AresTransform extends ModifyClassTransform {
- public AresTransform(Project project) {
- super(project);
- }
- @Override
- protected void handleChangedFile(File input) {
- String path = input.absolutePath.replace("/", "\\")
- if (input.isFile()) {
- debug("changed:" + input.absolutePath)
- if (path.endsWith(".class")) {
- modifyClass(input)
- } else if (path.endsWith(".jar")) {
- if (path.contains("exploded-aar")) {
- if (!path.contains("com.android.support")) {
- //需要处理的jar包
- File tmp = new File(input.getParent() + File.separator + "tmp")
- tmp.deleteOnExit()
- boolean modify = false
- if (!modify) JarZipUtil.unzipJar(input, tmp.absolutePath)
- tmp.eachFileRecurse { File file ->
- if (file.isFile()) {
- if (modifyClass(file)) {
- modify = true
- }
- }
- }
- if (modify) JarZipUtil.zipJar(tmp.absolutePath, input)
- }
- }
- }
- }
- }
- /**
- * 修改类文件
- * @param clazz
- * @return
- */
- private boolean modifyClass(File clazz) {
- debug("modify:" + clazz.absolutePath)
- return false
- }
- }
|