We’re thrilled to announce the release of Rapier, our open-source library designed to streamline the integration of configuration sources with Google Dagger. If you’ve ever been frustrated by the boilerplate involved in wiring up configuration data in your Dagger-based applications, Rapier is here to help.
Rapier’s mission is simple: eliminate the tedious work of writing boilerplate code for common configuration tasks. It automatically generates Dagger modules from simple annotations, allowing you to focus on what matters most — building great software.
We work on many projects that require robust configuration management, often using Dagger as the foundation. Over time, we noticed a common pain point: the repetitive boilerplate needed to connect configuration data to Dagger components. Rapier was born from this frustration. It’s our solution to a problem we faced—and we hope it will make your life easier, too.
Here's how it works:
With Rapier, you annotate your Dagger components or injection sites, specifying details about how configuration data should be retrieved. Rapier then generates the necessary Dagger modules to retrieve that configuration data for you.
For example, consider this simple use case:
@Component(modules = {RapierExampleComponentEnvironmentVariableModule.class})
public interface ExampleComponent {
@EnvironmentVariable(value = "TIMEOUT", defaultValue = "30000")
public long getTimeout();
}
For this code, Rapier automatically generates the referenced RapierExampleComponentEnvironmentVariableModule
module, which handles retrieving the TIMEOUT
environment variable, applying the default value if necessary, and converting it to the appropriate type.
Rapier integrates seamlessly with a variety of configuration sources:
Each source comes with its own annotation and module, giving you the flexibility to mix and match based on your application’s needs. More configuration sources are being added in every release.
Rapier handles common type conversions out of the box, including primitive types, boxed types, and even custom objects (using static factory methods or single-argument constructors). This eliminates yet another layer of manual work.
Testing applications built with Rapier is straightforward. The library’s generated modules include constructors that let you inject custom values for configuration sources, making it easy to test edge cases and scenarios without relying on real environment variables, system properties, or external data sources from vendors like AWS.
Using Rapier is as simple as adding a few dependencies and configuring your build. For detailed instructions, visit the Rapier GitHub repository. There, you’ll find everything you need, from installation guides to example projects demonstrating real-world use cases.
Rapier is currently in beta. While we already use it successfully in production, we’re still fine-tuning certain features. This means some aspects of the library may evolve as we gather feedback and expand functionality. That said, the core user interface is expected to remain stable, so you can adopt Rapier with confidence.
We’d love to hear your thoughts on Rapier! Whether you’re using it in a project or just curious, your feedback is invaluable. Open an issue or join the discussion on GitHub. Even just weighing in on the Rapier roadmap and letting us know which features would be most useful to you is enormously helpful.
We hope you try it, and find that you love using it as much as we do.
Happy coding!