Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable generating dagger factories for specific source sets #718

Open
matejdro opened this issue Jun 15, 2023 · 1 comment · May be fixed by #727
Open

Add option to disable generating dagger factories for specific source sets #718

matejdro opened this issue Jun 15, 2023 · 1 comment · May be fixed by #727
Labels
dagger factory Happens when generateDaggerFactories is set to true enhancement New feature or request

Comments

@matejdro
Copy link

matejdro commented Jun 15, 2023

We have an use case where we want to use anvil only (with generateDaggerFactories = true) inside main source set of a module. However, inside instrumented tests, we want to run full Dagger to generate components for integration tests (kaptAndroidTest("com.google.dagger:dagger-compiler") dependency declaration).

Anvil does not seem to support this configuration:

  1. If we enable kapt inside tests, Anvil will complain that generateDaggerFactories is enabled and Dagger must not coexist and that generating dagger factories should be disabled
  2. But if we disable generating dagger factories, factories will not get generated in the main source set (that does not contain kapt)

Maybe it would be a good idea to add a per-source-set dagger factory generation toggle instead of one global toggle?

@JoelWilcox JoelWilcox added enhancement New feature or request dagger factory Happens when generateDaggerFactories is set to true labels Jun 15, 2023
@matejdro
Copy link
Author

matejdro commented Jul 21, 2023

From what I can see, there is no easy access to source sets from Anvil compiler, since it only includes kotlin compiler API, not Gradle API.

I'm thinking of making PR for this, would having path whitelist instead of source set list be a acceptable workaround?

EDIT: What if compiler receives list of paths as whitelist (CommandLineOptions), but those are generated from the source sets by the anvil Gradle plugin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dagger factory Happens when generateDaggerFactories is set to true enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants