TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Rapier – Generate Dagger Modules from Annotations for Config Data

3 pointsby sigpwned4 months ago
Hey HN!<p>I built Rapier, a code-generation companion library to Dagger that Dagger modules automatically from annotations to eliminate boilerplate code when pulling configuration data from sources like environment variables, system properties, AWS SSM Parameter Store, and CLI arguments.<p>Why Rapier?<p>Dagger is a powerful dependency injection framework, but setting it up to handle configuration data can get tedious and repetitive. Rapier solves this by generating Dagger modules directly from annotations, saving time and reducing errors.<p>For example, with this Dagger interface:<p><pre><code> @Component(modules = {RapierExampleComponentEnvironmentVariableModule.class}) public interface ExampleComponent { @EnvironmentVariable(value = &quot;TIMEOUT&quot;, defaultValue = &quot;30000&quot;) long timeout(); } </code></pre> Rapier generates the RapierExampleComponentEnvironmentVariableModule module automatically to retrieve the TIMEOUT environment variable (or use the default 30000 if it’s not set) and convert it to long.<p>Key Features<p>Out-of-the-box integrations for: Environment variables (@EnvironmentVariable), System properties (@SystemProperty), AWS SSM Parameters (@AwsSsmStringParameter), CLI arguments (@CliPositionalParameter, etc.)<p>Supports type conversion (e.g., String -&gt; int, boolean, or custom types)<p>Easily testable with generated test constructors to inject test data.<p>Works seamlessly with core Dagger features (components, modules, lazy providers, etc.)<p>Why Beta?<p>I’m already using it in production on some of my other projects, so I’m pretty confident it works well, at least for simple use-cases. But Rapier is still in Beta releases, primarily I’m not absolutely sure all the major design decisions are worked out yet, and there may be some non-backwards compatible changes to the user-facing annotations.<p>Try it out!<p>Rapier is open source (<a href="https:&#x2F;&#x2F;github.com&#x2F;aleph0io&#x2F;rapier">https:&#x2F;&#x2F;github.com&#x2F;aleph0io&#x2F;rapier</a>), and in Maven Central.<p>I Want Your Input!<p>I would love your feedback, questions, or suggestions—especially around other configuration sources you’d like to see supported! Even just comment here or a vote on the Rapier roadmap (<a href="https:&#x2F;&#x2F;github.com&#x2F;orgs&#x2F;aleph0io&#x2F;projects&#x2F;11&#x2F;views&#x2F;1">https:&#x2F;&#x2F;github.com&#x2F;orgs&#x2F;aleph0io&#x2F;projects&#x2F;11&#x2F;views&#x2F;1</a>) would be very helpful to help me prioritize new features! And let me know if you want any tweaks, too!<p>Other Interesting Things<p>Some of you Java geeks may also find some of the code and technologies used in Rapier interesting as well.<p>Detailed Dagger assumptions testing <a href="https:&#x2F;&#x2F;github.com&#x2F;aleph0io&#x2F;rapier&#x2F;tree&#x2F;main&#x2F;rapier-assumptions-tests">https:&#x2F;&#x2F;github.com&#x2F;aleph0io&#x2F;rapier&#x2F;tree&#x2F;main&#x2F;rapier-assumpti...</a><p>Annotation processor (e.g., <a href="https:&#x2F;&#x2F;github.com&#x2F;aleph0io&#x2F;rapier&#x2F;blob&#x2F;main&#x2F;rapier-environment-variable-compiler&#x2F;src&#x2F;main&#x2F;java&#x2F;rapier&#x2F;envvar&#x2F;compiler&#x2F;EnvironmentVariableProcessor.java">https:&#x2F;&#x2F;github.com&#x2F;aleph0io&#x2F;rapier&#x2F;blob&#x2F;main&#x2F;rapier-environm...</a>)<p>Using Google compile-testing to test the build and run of Java applications during unit testing (e.g., <a href="https:&#x2F;&#x2F;github.com&#x2F;aleph0io&#x2F;rapier&#x2F;blob&#x2F;main&#x2F;rapier-environment-variable-compiler&#x2F;src&#x2F;test&#x2F;java&#x2F;rapier&#x2F;envvar&#x2F;compiler&#x2F;EnvironmentVariableProcessorRunTest.java">https:&#x2F;&#x2F;github.com&#x2F;aleph0io&#x2F;rapier&#x2F;blob&#x2F;main&#x2F;rapier-environm...</a>)

no comments

no comments