aboutsummaryrefslogtreecommitdiff
path: root/java/dagger/hilt
AgeCommit message (Collapse)Author
2021-05-12Revert "Merge commit 'upstream/dagger-2.35.1^'"Aurimas Liutikas
This reverts commit 399f4f61132f363e9479e59c550a7bcf005922d8. Reason for revert: b/187908823 Change-Id: I81f7cd3672e65ce1f7e1fa846b6c3e2f87147a26
2021-04-26Add flag to disable cross-compilation root validation.Brad Corso
Fixes #2577 RELNOTES=Fixes #2577: Add flag to disable cross-compilation root validation. PiperOrigin-RevId: 370573954
2021-04-23Detach CtClass instances from the ClassPool as they are inspected by the ↵Daniel Santiago
Javassist transform. It is not necessary to keep them in the ClassPool and detaching them can reduce memory consumption and avoid out of memory errors. Note that this only affects users with AGP older than 4.2.0 since the HiltTransformTestClassesTask was replaced by the ASM pipeline. Fixes: https://github.com/google/dagger/issues/2567 RELNOTES=Reduce the possibility of OOMs in the local unit test transform task that is executed for users with AGP older than 4.2.0. PiperOrigin-RevId: 370120877
2021-04-22Remove the references to beta in preparation for the upcoming stable release.Eric Chang
RELNOTES=n/a PiperOrigin-RevId: 369963385
2021-04-21Fix an issue where internal Kotlin objects were not properly being ↵Eric Chang
processed. Consolidate logic to figure out if a module requires an instance. RELNOTES=Fixes an issue where internal Kotlin object modules were incorrectly depended on directly by the component. PiperOrigin-RevId: 369743121
2021-04-20Remove defaultRootComponentName and pass in default root directly.Brad Corso
RELNOTES=N/A PiperOrigin-RevId: 369482450
2021-04-20Share aggregating metadata logic in a utility class.Brad Corso
RELNOTES=N/A PiperOrigin-RevId: 369466974
2021-04-20Use reflection for obtaining the AGP version since the Version class was ↵Daniel Santiago
moved between 3.5 and 3.6 Fixes: https://github.com/google/dagger/issues/2547 RELNOTES=Fix an issue in the Hilt Gradle Plugin where determining AGP version failed if the AGP version being used was older than 3.6. PiperOrigin-RevId: 369441551
2021-04-19Add aggregating data for roots. Also add tests to verify illegal combinations.Brad Corso
This CL adds AggregatedRoot for each root found and AggregatedRootSentinel for each root processed. We can then use this information to determine if the roots from past and current compilation units are valid. RELNOTES=N/A PiperOrigin-RevId: 369316983
2021-04-19Allow ProcessorErrors.checkState without an associated elementBrad Corso
RELNOTES=N/A PiperOrigin-RevId: 369306095
2021-04-19Make aggregated deps public and prepend "_" to the name to obfuscate it from ↵Brad Corso
auto suggest tools. RELNOTES=N/A PiperOrigin-RevId: 369243374
2021-04-16Merge ViewModel/ActivityRetained targets into the main targets.Eric Chang
RELNOTES=n/a PiperOrigin-RevId: 368944879
2021-04-16Internal changeBrad Corso
RELNOTES=N/A PiperOrigin-RevId: 368922638
2021-04-16Internal changeBrad Corso
RELNOTES=N/A PiperOrigin-RevId: 368911475
2021-04-16Internal changeBrad Corso
RELNOTES=N/A PiperOrigin-RevId: 368872818
2021-04-13Add AggregatedEarlyEntryPointMetadata to aggregate information about ↵Brad Corso
@EarlyEntryPoints. Note: this is a breaking change in the rare case that an app that upgrades Hilt is relying on an @EarlyEntryPoint usage in a library that is not also updated. To fix, all usages of @EarlyEntryPoint must be using the upgraded version of Hilt or later. Otherwise, they may miss the @EarlyEntryPoint usage and fail at runtime during a test. RELNOTES=This is a breaking change in the rare case that an app that upgrades Hilt is relying on an @EarlyEntryPoint usage in a library that is not also updated. To fix, all usages of @EarlyEntryPoint must be using the upgraded version of Hilt or later. Otherwise, they may miss the @EarlyEntryPoint usage and fail at runtime during a test. PiperOrigin-RevId: 368322897
2021-04-09Fix leak in FragmentContextWrapper by releasing the baseInflator if it exists.Brad Corso
Fixes https://github.com/google/dagger/issues/2070 RELNOTES=Fix leak in FragmentContextWrapper by releasing the baseInflator if it exists. PiperOrigin-RevId: 367725173
2021-04-09Add a private constructor to the generated @HiltViewModel module.Eric Chang
RELNOTES=n/a PiperOrigin-RevId: 367674245
2021-04-09Generate a separate TestComponentDataSupplier for each root.Brad Corso
The name generated class will be based on the enclosed name of the root, e.g. `foo.FooTest` will generate `foo.FooTest_TestComponentDataSupplier`. RELNOTES=N/A PiperOrigin-RevId: 367637090
2021-04-08Internal changesBrad Corso
RELNOTES=N/A PiperOrigin-RevId: 367538234
2021-04-08Sort root names before deduplicating them with numeric suffixes in order ↵Grant Oakley
guarantee determinism if this method is called from different processors. RELNOTES=N/A PiperOrigin-RevId: 367533712
2021-04-07Generate all test components in a common directory separate from the test ↵Grant Oakley
class root if shareTestComponents flag is enabled. Before this change, the test component would only be generated in the shared directory if it was able to use the shared test components. If only one root type exists in the compilation unit for a given simple name, that name is used to prefix the generated component name. If more than a one root shares a simple name (tests with the same name in separate packages), we have to disambiguate. RELNOTES=N/A PiperOrigin-RevId: 367252285
2021-04-05Pull AliasOfPropagatedDataMetadata into its own source file.Brad Corso
RELNOTES=N/A PiperOrigin-RevId: 366859328
2021-04-05Pull DefineComponentClassesMetadata into its own source file.Brad Corso
RELNOTES=N/A PiperOrigin-RevId: 366852409
2021-04-05Generate aggregated data for @UninstallModules.Brad Corso
RELNOTES=N/A PiperOrigin-RevId: 366804454
2021-04-02Fix an issue with KotlinMetadata where constructors were not getting added ↵Eric Chang
to the function map. RELNOTES=n/a PiperOrigin-RevId: 366532699
2021-04-02Pull AggregatedDepsMetadata into its own source file.Brad Corso
RELNOTES=N/A PiperOrigin-RevId: 366531336
2021-04-01Reuse the Default root generated components for test roots in the same ↵Grant Oakley
compilation unit that do not have test-specific bindings, rather than generating new components per-test. This can significantly reduce the amount of generated code for large projects with many test classes that do not provide test-specific bindings. This is currently off-by-default behind a compiler flag. This may be turned on by default in a future release. RELNOTES=Only generate and compile a single _HiltComponents class for test roots in the same compilation unit that do not have test-specific bindings, if flag enabled. PiperOrigin-RevId: 366281911
2021-03-30Also generate proxy module classes for Kotlin classes that are marked as ↵Grant Oakley
`internal`, which are analogous to package-private Java modules. RELNOTES=N/A PiperOrigin-RevId: 365865718
2021-03-19Add proguard rules to keep EntryPoint classes so optimizers don't remove them.Eric Chang
RELNOTES=Add proguard rules to keep EntryPoint classes so optimizers don't remove them. PiperOrigin-RevId: 363988696
2021-03-18Remove unused TestApplicationInjector interface.Grant Oakley
RELNOTES=N/A PiperOrigin-RevId: 363740468
2021-03-16Remove support for the deprecated, alpha @ViewModelInject. This also adds ↵Eric Chang
support for falling back to the default view model factory of the base activity/fragment. RELNOTES=@ViewModelInject no longer supported. Hilt now falls back to the base activity/fragment default ViewModelProviderFactory PiperOrigin-RevId: 363228502
2021-03-15Improve GitHub Actions hygiene for DaggerBrad Corso
See https://github.com/google/go-github/pull/1821 This CL makes a few changes to reduce the load of GitHub Actions from Dagger: * Restricts GitHub Actions to only the master or gh-pages branches (Note: For PR, this filter applies to the branch to merge into, not the branch itself). * Cancels previous GitHub Action runs for the same PR branch. * Removes excessive API levels for emulator tests. RELNOTES=N/A PiperOrigin-RevId: 363054339
2021-03-15Internal cleanupBrad Corso
RELNOTES=N/A PiperOrigin-RevId: 362992344
2021-03-12Remove throws declarations from methods that do not throwGrant Oakley
RELNOTES=N/A PiperOrigin-RevId: 362618454
2021-03-08Internal refactorEric Chang
RELNOTES=n/a PiperOrigin-RevId: 361702363
2021-03-05Rename init() method in generated Activity to avoid conflict with user ↵Daniel Santiago
method of same name. Fixes #2456 RELNOTES="Fix #2456: Rename init() method in generated Activity to avoid conflict with user method of same name." PiperOrigin-RevId: 361220626
2021-03-03Prevent KAPT from logging errors when compiling modules without entry points.Nicklas Ansman Giertz
When Hilt Android is run on a module that contains no entry points, KAPT will log an error about `disableAndroidSuperclassValidation` not being a support option. This is because the Hilt Gradle plugin will add this option when applied but if no entry points exists, no processor actually accepts that option. With this fix, all Hilt processors accept these options (though they are unused). This will prevent KAPT from logging these warnings in most cases. It is still possible for warnings to be logged, for example if the Hilt plugin is applied, but Hilt isn't used but for those cases the user can simply skip applying the plugin. Fixes #2040 Closes #2372 RELNOTES="Reduce the possibility of KAPT logging warnings due to no processor supporting `disableAndroidSuperclassValidation` when no Android entry points are in the source module." PiperOrigin-RevId: 360836064
2021-03-01Internal refactoringDagger Team
RELNOTES=n/a PiperOrigin-RevId: 360256525
2021-02-26Clears Fragment reference in FragmentContextWrapper after Fragment#onDestroy()Brad Corso
This CL uses the fragment Lifecycle to clear the fragment instance from the FragmentContextWrapper after onDestroy. Fixes: #2070 See https://github.com/google/dagger/issues/2070 RELNOTES=Fixes #2070: Clears the Fragment reference in FragmentContextWrapper after Fragment#onDestroy() to prevent leaks if a non-Hilt View outlives the Hilt Fragment that created it. PiperOrigin-RevId: 359775904
2021-02-25Update all "alpha" references to "beta" in preparation for the upcoming beta ↵Brad Corso
release. RELNOTES=N/A PiperOrigin-RevId: 359575497
2021-02-24Fixes to javadoc and links for EarlyEntryPointBrad Corso
I noticed that copybara doesn't handle the transformation of links correctly when using references at the bottom of the markdown (they're all relative to "hilt/" like "hilt/https://..."), so I've inlined them until we can figure out what's up with that. Also, noticed that the {@code} doesn't work properly when shown dagger.dev/api, e.g. https://dagger.dev/api/latest/dagger/hilt/android/EarlyEntryPoint.html. I'm thinking this may be due to the <h1> so I switched that to <p> and switched to <code></code> since I'm not sure what's causing it. RELNOTES=N/A PiperOrigin-RevId: 359423319
2021-02-24Add internal utility method.Daniel Santiago
RELNOTES=n/a PiperOrigin-RevId: 359415697
2021-02-24Follow-up changes to the EarlyEntryPoint APIBrad Corso
This CL changes the usage of @EarlyEntryPoint from being an addition to @EntryPoint to being a replacement for @EntryPoint. It also adds the @Beta annotation to the API. RELNOTES=N/A PiperOrigin-RevId: 359399064
2021-02-24Add EarlyTestEntryPoints to allow entry points to be called in tests before ↵Brad Corso
the test instance is instantiated. See https://github.com/google/dagger/issues/2016 RELNOTES=Add EarlyTestEntryPoints to allow entry points to be called in tests before the test instance is instantiated. PiperOrigin-RevId: 359350904
2021-02-22Enable remaining dagger.android and dagger.hilt tests.Brad Corso
Note: previously, dagger.android tests have existed in GitHub, but they were run as a noop in our GitHub Actions because robolectric tests were not enabled. This CL enables them. RELNOTES=N/A PiperOrigin-RevId: 358903809
2021-02-19Internal refactorEric Chang
RELNOTES=n/a PiperOrigin-RevId: 358275713
2021-02-18Add Hilt tests to GitHubBrad Corso
This CL sets up robolectric tests in the Dagger workspace and adds some previously existing, but never synced, tests (note: these tests are just now being synced to GitHub since we didn't have robolectric working before). RELNOTES=N/A PiperOrigin-RevId: 358192699
2021-02-17Internal refactorGrant Oakley
RELNOTES=N/A PiperOrigin-RevId: 358033242
2021-02-16Perform Hilt Activity injection on a OnContextAvailableListener.Daniel Santiago
Delay Hilt activity injection to a OnContextAvailableListener to enable member injecting ViewModels with SavedStateHandle. Note that this means base Hilt classes should not rely on their fields being injected before their onCreate() since injection is moved into super.onCreate() as opposed to before. RELNOTES=Delay Hilt activity injection to a OnContextAvailableListener to enable member injecting ViewModels with SavedStateHandle. To use the ContextAware APIs androidx.activity, androidx.fragment and androidx.lifecycle dependencies are updated across the Dagger libraries. PiperOrigin-RevId: 357829271