Delete generated by annotationProcessor class

android

(Vladimir Kokhanov) #1

I wrote an android library project with using dagger annotation processor, so my aar library contains some generated classes.

But I want to exclude one generated class from aar because of some reasons.

How can I make this?

I’ve found three solutions, but it doesn’t help:

packagingOptions {
        exclude '**/presenter/SomeClass_MembersInjector.java'
}
sourceSets {
    main {
        java {
            srcDirs += ['build']
            exclude '**/presenter/SomeClass_MembersInjector.java'
        }
    }
}
libraryVariants.all { variant ->
    def excludeTask = task("exclude${variant.name.capitalize()}", type: Delete) {
        delete "${buildDir}/**/SomeClass_MembersInjector.java"
    }
    def assembleTask = project.tasks.findByName("extract${variant.name.capitalize()}Annotations")
    assembleTask.finalizedBy excludeTask
}