Lightweight and Nonintrusive Scala Dependency Injection Library
MacWire is a lightweight and Nonintrusive Scala Dependency Injection Library.
MacWire generates new instance creation code of given classes, using values in the enclosing type for constructor parameters, with the help of Scala Macros.
For a general introduction to DI in Scala, take a look at the Guide to DI in Scala, which also features MacWire.
MacWire helps to implement the Dependency Injection (DI) pattern, by removing the need to write the class-wiring code by hand. Instead, it is enough to declare which classes should be wired, and how the instances should be accessed (see Scopes).
Classes that should be wired should be organized in "modules", which can be Scala traits, classes or objects. Multiple modules can be combined using inheritance; values from the inherited modules are also used for wiring.
MacWire can be in many cases a replacement for DI containers, offering greater control on when and how classes are instantiated, typesafety and using only language (Scala) mechanisms.