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

Use new Immutables Jakarta style to generate jakarta annotations #283

Closed
sleberknight opened this issue Oct 10, 2023 · 0 comments · Fixed by #285
Closed

Use new Immutables Jakarta style to generate jakarta annotations #283

sleberknight opened this issue Oct 10, 2023 · 0 comments · Fixed by #285
Assignees
Labels
code cleanup Fix issues reported by Sonar or any other code analysis tools
Milestone

Comments

@sleberknight
Copy link
Member

Immutables 2.10.0 adds the jakarta style in @Value.Style. Setting this to true tells Immutables to use jakarta packages instead of java, which as far as I can tell mainly affects the annotations.

See support generating jakarta annotations instead of javax in Immutables.

Also see the Value source code and search for "jakarta". As of this writing, the jakarta attribute is on line 1578 but this will probably change by the time anyone reads this.

The javadoc description as of this writing is:

If enabled, jakarta.* packages will take over any relevant javax.*
This includes primarily jakarta.annotation.* and jakarta.validation.*.
Note that classpath inhibitor or #allowedClasspathAnnotations() will still
take effect, it's just so that

It seems like there should be some text after "it's just so that", i.e. like someone got distracted in the middle of a sentence but never finished it. But in any case, it causes Immutables to use Jakarta annotations instead of the javax (old JSR-305) ones. The net effect is that it removes a bunch of annotations such as javax.annotation.CheckReturnValue, javax.annotation.NotThreadSafe, and javax.annotation.ParametersAreNonnullByDefault. The main one that remains is jakarta.annotation.Nullable.

But by making this change, we will avoid split-package issues with the Java module system. See Nicolais' excellent explanation on split packages for more details.

@sleberknight sleberknight added the code cleanup Fix issues reported by Sonar or any other code analysis tools label Oct 10, 2023
@sleberknight sleberknight added this to the 1.1.1 milestone Oct 10, 2023
@sleberknight sleberknight self-assigned this Oct 10, 2023
sleberknight added a commit that referenced this issue Oct 11, 2023
* Add jakarta.annotation-api as a compile-scope dependency, since the
  generated classes will contain jakarta annotations
* Add the "jakarta = true" style to all the classes using Immutables
* Note that Value and TxResponse (which uses Value) must import
  org.immutables.value.Value.Immutable and org.immutables.value.Value.Style
  because otherwise, they conflict with org.kiwiproject.consul.model.kv.Value.
  All other model classes import org.immutables.value.Value and then
  use the annotations as Value.Immutable and Value.Style. I retained this
  semantic, which was how these classes were originally defined well
  before we forked this project.

Closes #283
dsingley pushed a commit that referenced this issue Oct 11, 2023
* Add jakarta.annotation-api as a compile-scope dependency, since the
  generated classes will contain jakarta annotations
* Add the "jakarta = true" style to all the classes using Immutables
* Note that Value and TxResponse (which uses Value) must import
  org.immutables.value.Value.Immutable and org.immutables.value.Value.Style
  because otherwise, they conflict with org.kiwiproject.consul.model.kv.Value.
  All other model classes import org.immutables.value.Value and then
  use the annotations as Value.Immutable and Value.Style. I retained this
  semantic, which was how these classes were originally defined well
  before we forked this project.

Closes #283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code cleanup Fix issues reported by Sonar or any other code analysis tools
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant