How to override processAndroidResources

I’m trying to provide a custom aapt command, but I can’t see how to override an existing task’s behavior. Is there a generic way to do that? Based on some other similar posts I saw, I tried:

 project.afterEvaluate {
            tasks.getByPath('processDebugResources').actions = [ ];
            tasks.getByPath('processDebugResources').doLast = [ MyAapt  ];
}

but

No such property: doLast for class: com.android.build.gradle.tasks.ProcessAndroidResources_Decorated

I’ve also tried using aaptOptions, but it doesn’t provide sufficient control. Specifically I need to remove the “-I … android.jar” that gets added for me, since I’m working in a system build and need to provide my own framework resources.

Any suggestions?