I have an interface
public interface SomeInterface {
void test();
}
and an annotation processor which generates an implementation of SomeInterface
called SomeInterfaceImpl
.
To make this type available with Dagger dependency injection I would create the following:
@Component(modules = {ApplicationModule.class})
@Singleton
public interface ApplicationComponent {
SomeInterface getSomeInterface();
}
and
@Module
public class ApplicationModule {
@Provides
@Singleton
SomeInterface provideSomeInterface() {
return new SomeInterfaceImpl();
}
}
The problem is that I cannot use use SomeInterfaceImpl
in my ApplicationModule because it is not yet available and will be generated by an annotation processor.
How can I extend my annotation processor such that I can use SomeInterface
is available for Dagger dependency injection and that the generated implementation SomeInterfaceImpl
will be resolved correctly?
Edit:
The example works, but I want to create the ApplicationModule with another annotation processor and let the processor integrate the ApplicationModule in the dagger graph somehow. @Component(modules={ApplicationModule.class}) Will not exist because I do not know in code that ApplicationModule will be generated. Is there a way to integrate a generated a @Module class into the Dagger Graph? Note that I do not want to guess that ABCModule will be generated and add it to the @Component. I want that this happens automatically somehow.