google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.45k stars 2.02k forks source link

KMP version of Dagger? #3916

Open Zeyad-37 opened 1 year ago

Zeyad-37 commented 1 year ago

Dagger is the king of DI on Android. With the rise of KMP & KMM only service locator libs are available. It would be great if Dagger can become a multiplatform DI framework to avoid all these runtime crashes

Chang-Eric commented 1 year ago

In order to do KMP we would have to finish KSP work (https://github.com/google/dagger/issues/2349). KMP is also a very large project as we would have to rewrite all of our generated code to be in Kotlin. We also still have to consider users who only use Java, so it would probably mean having two modes, which is a lot of extra work. Basically this is all to say, this is a lot of work and probably won't happen for a while given we aren't done with KSP yet.

shalva97 commented 1 year ago

Java is deprecated, you dont have to consider its users

natros commented 1 year ago

I’m a Java user and I’m using dagger for Java projects. Is there any official statement where it says Java is deprecated?

On Mon, 17 Jul 2023 at 10:35 George Shalvashvili @.***> wrote:

Java is deprecated, you dont have to consider its users

— Reply to this email directly, view it on GitHub https://github.com/google/dagger/issues/3916#issuecomment-1637692262, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGDZQPDSLGJBV4M4MRLL6TXQUBM7ANCNFSM6AAAAAAZONO7IQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Filipe Sousa

shalva97 commented 1 year ago

Okay, my bad. At first I though it would be a good joke, but now when I read it, it looks weird

robercoding commented 7 months ago

Hey folks, so it's been almost a year since the discussion started and Hilt has already made its transition to ksp. Got me thinking, any chance we might see Hilt jumping on the KMP train in 2025-26? Any buzz or plans floating around? That'd be awesome!

Shusek commented 7 months ago

Hey folks, so it's been almost a year since the discussion started and Hilt has already made its transition to ksp. Got me thinking, any chance we might see Hilt jumping on the KMP train in 2025-26? Any buzz or plans floating around? That'd be awesome!

Not all issues related to KSP are closed: https://github.com/google/dagger/labels/area%3A%20ksp

ryanw-mobile commented 6 months ago

Dagger(/Hilt) on Android is popular, as we see people prefer it over other available options. When extending Android projects to KMP, Dagger(/Hilt) would still be my first preference if had a choice. I know many others share the same thoughts when they have to consider other options on KMP for DI.

I understand the effort is significant, but I hope the team can at least agree there is a plan to support KMP, even if the timeline does not exist yet? Thank you.

Chang-Eric commented 6 months ago

Currently, there aren’t plans to work on a KMP version of Dagger or Hilt right now. Our team has discussed this but it isn’t in our current roadmap. KSP is also still in alpha since there are still a number of edge cases we’re working on, so it is a bit premature for us start on KMP. Also, while KSP was a large project, KMP support might somehow be even larger in that we’d have to support generating Kotlin as well as Java (there are still Java users out there who may not want Kotlin generated) and we already know of some tough compatibility issues we’d have to deal with there. This isn't ruling out KMP support, but also just want to set realistic expectations.

juliocbcotta commented 6 months ago

Hey @Chang-Eric , is ksp in alpha? From their versioning scheme it doesn't seem to be the case. Do you keep a list of issues that are considered blockers ?(if you could share those, I would like to follow them)

Chang-Eric commented 6 months ago

@juliocbcotta Sorry if that was confusing, I meant to say Dagger's support of KSP is still in alpha.

Most of what we're trying to resolve as blockers before moving our support from alpha to stable is performance and getting internal projects on to Dagger KSP successfully. There's some performance stuff discussed in https://github.com/google/dagger/issues/4180, but also there are a number of issues we've run into internally while trying to switch projects at Google over to KSP from KAPT. Some of those issues are internal only and some of them have publicly filed issues, but I don't really want to list them out here since I don't really want to drive traffic to them. We already work pretty closely with the KSP team internally and they know about the issues we're hitting, so I don't want to add pressure from people since they already know it is a priority.