Espada is a project born out of the desire to better understand Dependency Injection (DI). While it's important to note that Espada is primarily an educational experiment, it is meticulously documented to assist in comprehending DI concepts.
-
processor
- The core module containing annotation processing and code generation logic.
- Extensively documented with comments for every class to aid understanding.
- Comments serve as a learning resource and reference guide for those seeking insights into the project.
-
annotations
- Provides the
@Module
annotation andjavax.inject
API for DI users.
- Provides the
-
kotlin-poet-extensions
- A compact DSL using Kotlin extension functions to enhance the creation of files within the Kotlin Poet.
-
app
- A small Android module featuring examples of using mocked dependencies.
- Includes generated factories and few comments for better understanding.
Espada's codebase is richly annotated with comments, especially in the processor
module, making it a valuable resource for learning about DI.
To integrate Espada into your project:
- Add the following dependencies:
- Use
implementation()
for theannotations
module. - Use
ksp()
for theprocessor
module.
dependencies { ksp(project(":processor")) implementation(project(":annotations")) }
- Use
- Apply the KSP (Kotlin Symbol Processing) plugin.
To use Espada:
-
Declare your dependencies in any number of
@Module
annotated classes. -
Mark the properties you want to inject with
@Inject.
-
Espada will automatically generate factories, validate the dependency graph, and, if everything is in order, generate Injector classes with methods
inject(recipient)
that facilitate member injection into your classes.
For explanations with examples you can look inside the
app
module
Espada is an educational experiment designed to foster a deeper understanding of DI concepts. Enjoy exploring and learning with Espada!