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

[Proposal] Migration plan for Guice 7+ #2863

Open
Nava2 opened this issue Jul 16, 2023 · 5 comments
Open

[Proposal] Migration plan for Guice 7+ #2863

Nava2 opened this issue Jul 16, 2023 · 5 comments

Comments

@Nava2
Copy link
Contributor

Nava2 commented Jul 16, 2023

Wanted to make an issue for tracking migration to Guice 7.0.0.

@ThePumpingLemma migrated to using Guice 6.0.0 (#2846), however, there remains issues with projects wanting to use misk-inject with Guice 7+. The largest issue is that when a project tries to use Guice 7+, it can not inject classes that are labelled with javax.inject.XXX annotations. Guice 6+ happily accepts both jakarta and javax.

Proposed path forwards

It seems like the path to migration would be twp steps:

  1. Replace all usages of javax.inject.XXX with com.google.inject.XXX
    • This enables projects to transition to using jakarta.inject in their own projects, while consuming misk-inject @ 6.0.0
  2. Eventually cut over to Guice 7.0.0 at some point
  3. Optional: Replace com.google.inject.XXX with jakarta.inject.XXX

Open question

  1. misk uses detekt. Could we enable forbidding imports to enforce only using jakarta.inject.XXX?
  • IntelliJ can also be adjusted to ignore certain imports for "Auto import" (Link), but there is no intellij configuration within misk by default

P.S. I'm happy to do the find-and-replace 😄

@Nava2 Nava2 changed the title Migration to Guice 7+ [Proposal] Migration plan for Guice 7+ Jul 16, 2023
@r3mariano
Copy link
Collaborator

👋 I'm one of the engineers working on frameworks at Cash.

We'd have to migrate our internal downstream services before we're able to do the migration to Guice 7. Will talk to the team about where to prioritise that. Given Guice 7 doesn't really have anything that isn't in Guice 6 at the moment, I'd lean towards doing the cutover later.

Using detekt would be great to check for imports!

@r3mariano
Copy link
Collaborator

I'm curious btw, why com.google.inject instead of jakarta.inject if they both work? I think I'd prefer to use the more generic one of the two where possible.

@Nava2
Copy link
Contributor Author

Nava2 commented Jul 25, 2023

If we used Jakarta, it would force usage of 6.0+.. which seems fine... 🤦🏻 Admittedly, I'm biased as our downstream services are not on 6.0 yet and it would force our update - which we need to do.

@Nava2
Copy link
Contributor Author

Nava2 commented Jul 25, 2023

I agree strongly with holding off on the cutover until later, but doing the initial migration to Jakarta seems good to get done.

@adrw
Copy link
Collaborator

adrw commented Jul 25, 2023

I'd also lean towards jakarta.inject instead of com.google.inject since it looks like javax.inject has been replaced by jakarta.inject google/dagger#2058 (comment)

Nava2 added a commit to Nava2/misk that referenced this issue Jul 31, 2023
Part of cashapp#2863.

This replaces usages to enable migration to [Guice 7+](https://github.com/google/guice/wiki/Guice700). This is the first (only?) step to allow projects using Guice 6.0.0 or Guice 7.0.0 to use misk-inject.

By using `jakarta.inject` instead of `javax.inject`, injections work in both 6+ and 7+ versions. The new project, `:misk-inject-guice7-test` sets up a test project with the classpath forced to Guice 7+. This acts as a guard project for basic usages. As needed, we can add more content.
Nava2 added a commit to Nava2/misk that referenced this issue Jul 31, 2023
Part of cashapp#2863.

This replaces usages to enable migration to [Guice 7+](https://github.com/google/guice/wiki/Guice700). This is the first (only?) step to allow projects using Guice 6.0.0 or Guice 7.0.0 to use misk-inject.

By using `jakarta.inject` instead of `javax.inject`, injections work in both 6+ and 7+ versions. The new project, `:misk-inject-guice7-test` sets up a test project with the classpath forced to Guice 7+. This acts as a guard project for basic usages. As needed, we can add more content.
Nava2 added a commit to Nava2/misk that referenced this issue Jul 31, 2023
Part of cashapp#2863.

This replaces usages to enable migration to [Guice 7+](https://github.com/google/guice/wiki/Guice700). This is the first (only?) step to allow projects using Guice 6.0.0 or Guice 7.0.0 to use misk-inject.

By using `jakarta.inject` instead of `javax.inject`, injections work in both 6+ and 7+ versions. The new project, `:misk-inject-guice7-test` sets up a test project with the classpath forced to Guice 7+. This acts as a guard project for basic usages. As needed, we can add more content.
jdm-square pushed a commit that referenced this issue Aug 3, 2023
…ations (#2890)

* [Guice 6] Migrate to use `com.guice.inject.*` for injection annotations

Part of #2863.

This replaces usages to enable migration to [Guice 7+](https://github.com/google/guice/wiki/Guice700). This is the first (only?) step to allow projects using Guice 6.0.0 or Guice 7.0.0 to use misk-inject.

By using `jakarta.inject` instead of `javax.inject`, injections work in both 6+ and 7+ versions. The new project, `:misk-inject-guice7-test` sets up a test project with the classpath forced to Guice 7+. This acts as a guard project for basic usages. As needed, we can add more content.

* remove BindingAnnotation, oops

* Fix dependencies and apiDump

* fix bad refactors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants