Transformer proguard hook

This commit is contained in:
Gravit 2018-09-24 18:02:07 +07:00
parent 23a1c9a7e1
commit b6ea3e0aa5

View file

@ -22,10 +22,6 @@ public interface PostBuildHook {
public interface PreBuildHook {
void build(BuildContext context);
}
@FunctionalInterface
public interface ProGuardTransformHook {
byte[] transform(byte[] input, CharSequence classname);
}
@FunctionalInterface
public interface Transformer {
@ -34,7 +30,7 @@ public interface Transformer {
private boolean BUILDRUNTIME;
private final Set<PostBuildHook> POST_HOOKS;
private final Set<ProGuardTransformHook> POST_PROGUARD_HOOKS;
private final Set<Transformer> POST_PROGUARD_HOOKS;
private final Set<PreBuildHook> PRE_HOOKS;
private final Set<Transformer> CLASS_TRANSFORMER;
private final Set<String> CLASS_BLACKLIST;
@ -72,7 +68,7 @@ public byte[] classTransform(byte[] clazz, CharSequence classname) {
}
public byte[] proGuardClassTransform(byte[] clazz, CharSequence classname) {
byte[] result = clazz;
for (ProGuardTransformHook transformer : POST_PROGUARD_HOOKS) result = transformer.transform(result, classname);
for (Transformer transformer : POST_PROGUARD_HOOKS) result = transformer.transform(result, classname);
return result;
}
@ -115,7 +111,7 @@ public void registerIgnoredClass(String clazz) {
public void registerPostHook(PostBuildHook hook) {
POST_HOOKS.add(hook);
}
public void registerProGuardHook(ProGuardTransformHook hook) {
public void registerProGuardHook(Transformer hook) {
POST_PROGUARD_HOOKS.add(hook);
}
public boolean isNeedPostProguardHook()