Annotation processor Implementation

This commit is contained in:
Gergely Hegedus 2021-07-30 22:36:48 +03:00
parent c1b8d92461
commit edf94325d8
19 changed files with 484 additions and 0 deletions

1
annotation/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

12
annotation/build.gradle Normal file
View file

@ -0,0 +1,12 @@
plugins {
id 'java-library'
id 'kotlin'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
sourceCompatibility = "8"
targetCompatibility = "8"

View file

@ -0,0 +1,19 @@
package org.fnives.library.reloadable.module.annotation
/**
* Annotate your custom Annotation with this to apply the annotation processor.
*
* The annotation processor will generate 2 classes for you.
*
* First will be an interface Reload<YourAnnotation>Module with only one method, reload.
* This Reload<YourAnnotation>Module can be injected anywhere where you want to reload the module.
*
* Second will be a class Reload<YourAnnotation>ModuleImpl which is the actual Module implementation for Hilt.
* This provides every class which constructor you annotate with YourAnnotation.
*
* Reload in this context means, every instance will be cleared and the next time Hilt accesses it, a new will be created.
* This newly created instance is reused until the next reload call.
*/
@Target(AnnotationTarget.ANNOTATION_CLASS)
@Retention(AnnotationRetention.SOURCE)
annotation class ReloadableModule