Hilt - SingletonC build files generated for *each* unit test significantly impacting unit test build times
See original GitHub issueAfter having migrated our codebase from a pure Dagger 2 implementation to a Hilt-enabled one, we noticed a significant impact in build times for unit tests.
After some investigation into the matter we noticed that there are _HiltComponents_SingletonC.java
-suffixed files created for every single unit test that has been enabled for Hilt usage… All files have the same size and content, which seems to indicate that the same SingletonC class is being recreated and packaged as a build artifact for all Hilt-enabled unit tests.
Having removed these in another branch, we were able to also confirm that a significant amount of the increase in build time we had noticed can be attributed to the proliferation of these files…
Is there something we’re missing with our implementation?
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (1 by maintainers)
Top GitHub Comments
@snepalnetflix, see the Dagger 2.34 release notes for details on the
-Adagger.hilt.shareTestComponents
flag.Also, see the docs for how to enable the flag and expected issues you might hit when trying to enable it.
@mhernand40 thanks for the extra info.
That’s great! This is the first use case we’re going to optimize for. All of your tests should be able to share a single component, which should hopefully bring your build times back down to where they were before.