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

formatAnnotations merges type and non-type annotations in records #2336

Open
jskov opened this issue Nov 10, 2024 · 3 comments
Open

formatAnnotations merges type and non-type annotations in records #2336

jskov opened this issue Nov 10, 2024 · 3 comments

Comments

@jskov
Copy link
Contributor

jskov commented Nov 10, 2024

I find that FormatAnnotationsStep works OK with annotations on fields/getters that follow the form mentioned in this note.

But I have started using records in my project and have code like this:

public record EnumsDto(
        @JsonbProperty("external") @Valid @Nullable ExternalEnum external,
        @JsonbProperty("externalLower") @Valid @Nullable ExternalLowerEnum externalLower,
...

The above is the formatAnnotations() output.

But it should (if I understand things correctly) be:

public record EnumsDto(
        @JsonbProperty("external")
        @Valid @Nullable ExternalEnum external,
        @JsonbProperty("externalLower")
        @Valid @Nullable ExternalLowerEnum externalLower,
...

But since there is no protection keyword (public/private) to separate the non-type annotations from the type-annotations, they all get merged into the same line by FormatAnnotationsStep.

This is observed with version Gradle Plugin v7.0.0.BETA4

@jskov
Copy link
Contributor Author

jskov commented Nov 14, 2024

I think this can be fixed simply by only stripping newlines from type-annotations.
And thus leaving them for unknown annotations (which does not happen now).

I will work on a patch for this.

@jskov jskov closed this as completed Nov 14, 2024
@jskov jskov reopened this Nov 14, 2024
@nedtwigg
Copy link
Member

This is a breaking change that makes me nervous. If you can gate it behind a flag, then I can easily merge. If you can't, we need to consider the impact to existing users a bit. @mernst any thoughts?

@jskov
Copy link
Contributor Author

jskov commented Nov 15, 2024

Sounds reasonable.

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

No branches or pull requests

2 participants