-
Notifications
You must be signed in to change notification settings - Fork 170
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
feat: [Guice 6] Migrate to use jakarta.inject.*
for injection annotations
#2890
feat: [Guice 6] Migrate to use jakarta.inject.*
for injection annotations
#2890
Conversation
1d0bd2f
to
4a60568
Compare
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.
4a60568
to
67c4984
Compare
@@ -74,7 +74,7 @@ class AnnotatePublicApisWithJvmOverloads(config: Config) : Rule(config) { | |||
if (!element.valueParameters.any { it.hasDefaultValue() }) return false | |||
|
|||
// Is not annotated with @Inject | |||
if (element.hasAnyAnnotation("javax.inject.Inject", "com.google.inject.Inject")) return false | |||
if (element.hasAnyAnnotation("javax.inject.Inject", "jakarta.inject.Inject", "com.google.inject.Inject")) return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual feature change.
Added support to detekt rule to look at jakarta.
@@ -129,15 +129,23 @@ internal class AnnotatePublicApisWithJvmOverloadsTest(private val env: KotlinCor | |||
NoErrorTestCase( | |||
description = "Public constructor annotated with javax Inject", | |||
code = """ | |||
import javax.inject.Inject | |||
import jakarta.inject.Inject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added related test
@@ -0,0 +1,5 @@ | |||
## misk-inject-guice7-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these add the tests to verify that Guice 7 works with misk-inject
@@ -21,6 +21,22 @@ complexity: | |||
LongParameterList: | |||
active: false | |||
|
|||
style: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bans imports in future code
jakarta.inject.*
for injection annotationsjakarta.inject.*
for injection annotations
cc @adrw / @r3mariano |
@r3mariano I'm unsure how to actually land this change. Could you advise on process or documentation? |
@jdm-square looks like there's some dependency cleanups and general lint things. Is there an autoformat somewhere.. was hoping the detekt formatting rules were in place but seem to not be. Also looks like I need to regenerate the API lockfiles, easy enough. |
I don't see any linting issues that require formatting, only the missing api dump and dependency changes. |
Head branch was pushed to by a user without write access
@Nava2 Nothing particular for the OSS repo. We're already aware of the change and can handle the change in our internal services (i.e. upgrade everyone to 6). Releases already happen automatically, we switched to a date-based versioning scheme that publishes for every change in main. There is an incoming change to add more (non-Guice) modules, hopefully that won't cause a conflict. |
I'll run it again to see if it's an intermittent error. |
…igrate-to-use-com.google.inject
…igrate-to-use-com.google.inject
@jdm-square / @r3mariano / @JGulbronson could one of you enable the tests to run again? :) This should be bueno now! |
Thanks to whomever enabled the CI, I can't actually merge this |
Part of #2863.
This replaces usages to enable migration to Guice 7+. 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 ofjavax.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.The exception is using
com.google.inject.Provider
as Guice 6 does not provide bindings that work withjakarta.inject.Provider
in all cases, making this a frustrating requirement.