{"id":16838683,"url":"https://github.com/jakewharton/dagger-reflect","last_synced_at":"2025-04-04T18:07:59.393Z","repository":{"id":46929675,"uuid":"168431743","full_name":"JakeWharton/dagger-reflect","owner":"JakeWharton","description":"A reflection-based implementation of the Dagger dependency injection library for fast IDE builds.","archived":false,"fork":false,"pushed_at":"2021-05-19T15:41:07.000Z","size":681,"stargazers_count":655,"open_issues_count":37,"forks_count":44,"subscribers_count":30,"default_branch":"master","last_synced_at":"2024-10-14T12:24:55.271Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JakeWharton.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-30T23:32:04.000Z","updated_at":"2024-09-15T17:07:05.000Z","dependencies_parsed_at":"2022-09-11T20:30:43.248Z","dependency_job_id":null,"html_url":"https://github.com/JakeWharton/dagger-reflect","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeWharton%2Fdagger-reflect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeWharton%2Fdagger-reflect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeWharton%2Fdagger-reflect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakeWharton%2Fdagger-reflect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JakeWharton","download_url":"https://codeload.github.com/JakeWharton/dagger-reflect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226215,"owners_count":20904465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T12:25:24.718Z","updated_at":"2025-04-04T18:07:59.369Z","avatar_url":"https://github.com/JakeWharton.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Dagger Reflect\n==============\n\nA reflection-based implementation of the [Dagger][dagger] dependency injection library for fast\nIDE builds and tests.\n\nMore info soon...\n\n\n**Current release**: [0.3.0](CHANGELOG.md)\n\nSnapshots of the next development version are available in [Sonatype's `snapshots` repository][snap].\n\n\nUsage\n-----\n\nThere are two methods of integrating Dagger Reflect to replace Dagger:\n\n### Partial Reflection\n\nThis approach still uses an annotation processor to generate implementations of your component\ninterfaces which then call into the reflection runtime. The annotation processor is fully\nincremental and does no validation to ensure minimal overhead.\n\n  * Pros:\n    * Your code does not have to change when switching between Dagger and Dagger Reflect\n      (modulo limitations below)\n\n  * Cons:\n    * The use of an annotation processor still causes a build-time impact\n\nFor an Android build, configure your dependencies:\n\n```groovy\ndependencies {\n  if (properties.containsKey('android.injected.invoked.from.ide')) {\n    debugAnnotationProcessor 'com.jakewharton.dagger:dagger-reflect-compiler:0.3.0'\n    debugApi 'com.jakewharton.dagger:dagger-reflect:0.3.0' // or debugImplementation\n  } else {\n    debugAnnotationProcessor \"com.google.dagger:dagger-compiler:$daggerVersion\"\n  }\n  releaseAnnotationProcessor \"com.google.dagger:dagger-compiler:$daggerVersion\"\n  api \"com.google.dagger:dagger:$daggerVersion\" // or implementation\n}\n```\n\nThis will enable Dagger Reflect only for debug builds in the IDE.\n\n\n### Full Reflection\n\nThis approach avoids all annotation processor usage enabling the quickest builds at the expense of\nhaving to change your production Dagger code. In order to avoid the need to \n\n  * Pros:\n    * No annotation processors!\n\n  * Cons:\n    * Rewrite bridges into generated code to call into runtime library.\n    * Special care has to be taken for R8/ProGuard (for now).\n\n```groovy\ndependencies {\n  if (properties.containsKey('android.injected.invoked.from.ide')) {\n    debugApi 'com.jakewharton.dagger:dagger-reflect:0.3.0' // or debugImplementation  \n  } else {\n    debugAnnotationProcessor \"com.google.dagger:dagger-compiler:$daggerVersion\"\n    debugApi 'com.jakewharton.dagger:dagger-codegen:0.3.0' // or debugImplementation\n  }\n  releaseAnnotationProcessor \"com.google.dagger:dagger-compiler:$daggerVersion\"\n  releaseApi 'com.jakewharton.dagger:dagger-codegen:0.3.0' // or releaseImplementation\n  api \"com.google.dagger:dagger:$daggerVersion\" // or implementation\n}\n```\n\nThis will enable Dagger Reflect only for debug builds in the IDE.\n\nWhen creating a component, builder, or factory in your code, replace calls into generated code with\ncalls into the static `Dagger` factory with the associated class literal.\n\n```diff\n-MyComponent component = DaggerMyComponent.create();\n+MyComponent component = Dagger.create(MyComponent.class);\n```\n```diff\n-MyComponent.Factory factory = DaggerMyComponent.factory();\n+MyComponent.Factory factory = Dagger.factory(MyComponent.Factory.class);\n```\n```diff\n-MyComponent.Builder builder = DaggerMyComponent.builder();\n+MyComponent.Builder builder = Dagger.builder(MyComponent.Builder.class);\n```\n\nUsing specific Lint rules\n-------------------------\n\nThere are Lint rules for Dagger reflect to simplify the usage:\n\n  * `WrongRetention`:  \n    When using a Dagger related custom annotation (e.g. `MapKey`, `Qualifier`), they require\n    a runtime retention by adding `@Retention(RUNTIME)`.\n\nThey can be enabled in an Android-project by adding\n\n```groovy\ndependencies {\n  lintChecks 'com.jakewharton.dagger:dagger-reflect-lint:0.3.0'\n}\n```\n\nTo use them in a non-Android project (blocked by [this issue](https://issuetracker.google.com/issues/112526243)),\nyou'd need to add the (Android) Lint Gradle Plugin:\n```groovy\nbuildscript {\n  repositories {\n    google()\n  }\n  dependencies {\n    classpath \"com.android.tools.build:gradle:3.1.0\" // or higher\n  }\n}\napply plugin: \"com.android.lint\"\n```\n\nUnsupported Features and Limitations\n------------------------------------\n\n### Abstract Classes\n\nBecause Dagger Reflect is implemented using a [`Proxy`][proxy], only interface components,\nfactories, and builders are supported.\n\n### Component Visibility\n\nIn order for a factory or builder which is backed by a `Proxy` to create an instance of the\nenclosing component which is also backed by a `Proxy`, the component has to be public.\n\n### Producers\n\nPretty sure no one but Google uses this. PRs welcome.\n\n\n\nLicense\n-------\n\n    Copyright 2018 Jake Wharton\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n\n\n [dagger]: https://github.com/google/dagger/\n [snap]: https://oss.sonatype.org/content/repositories/snapshots/\n [proxy]: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/reflect/Proxy.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakewharton%2Fdagger-reflect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakewharton%2Fdagger-reflect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakewharton%2Fdagger-reflect/lists"}