If the files(dependencies) comes from thridparty, maybe you can use Gradle Artifact Transform API to delete the unexpect files.
see: https://docs.gradle.org/current/userguide/artifact_transforms.html