Skip to content

Add Jackson 3 support for @JsonDeserialize and @JsonPOJOBuilder#918

Merged
jiholee17 merged 4 commits intomasterfrom
feature/jackson-3-support
Feb 11, 2026
Merged

Add Jackson 3 support for @JsonDeserialize and @JsonPOJOBuilder#918
jiholee17 merged 4 commits intomasterfrom
feature/jackson-3-support

Conversation

@jiholee17
Copy link
Copy Markdown
Collaborator

Closes #899

This PR adds support for Jackson 3 (now configured by default in Spring Boot 4 projects) by detecting which versions of Jackson annotations are available on the compile classpath and adding annotations for the available version(s). If neither version is found, codegen defaults to Jackson 2 annotations for backwards compatibility. If both versions are found, codegen adds both annotations and defers to runtime selection behavior.

Affected annotations are:

  • @JsonDeserialize in com.fasterxml.jackson.databind.annotation (Jackson 2) and tools.jackson.databind.annotation (Jackson 3)
  • @JsonPOJOBuilder in com.fasterxml.jackson.databind.annotation (Jackson 2) and tools.jackson.databind.annotation (Jackson 3)

@JsonProperty, @JsonTypeInfo, and @JsonSubTypes are unaffected and remain in the com.fasterxml.jackson.annotation package.

Example with both Jackson versions:

import com.fasterxml.jackson.databind.`annotation`.JsonDeserialize as FasterxmlJacksonDatabindAnnotationJsonDeserialize
import tools.jackson.databind.`annotation`.JsonDeserialize as ToolsJacksonDatabindAnnotationJsonDeserialize
...
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
@FasterxmlJacksonDatabindAnnotationJsonDeserialize(builder = Country.Builder::class)
@ToolsJacksonDatabindAnnotationJsonDeserialize(builder = Country.Builder::class)
public class Country(
...

Example with single Jackson version:

import com.fasterxml.jackson.databind.`annotation`.JsonDeserialize
...
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
@JsonDeserialize(builder = Query.Builder::class)
public class Query(
...

@jiholee17 jiholee17 merged commit 5dfd192 into master Feb 11, 2026
6 of 10 checks passed
@jiholee17 jiholee17 added the enhancement New feature or request label Apr 8, 2026
mrmegapolys added a commit to mrmegapolys/dgs-codegen that referenced this pull request Apr 15, 2026
JacksonVersionDetector.detectVersions(project) was called in the
@TaskAction method, accessing Task.project at execution time which
is unsupported with configuration cache.

Move Jackson version detection to configuration time by adding a
@input property to GenerateJavaTask and resolving it in the plugin
afterEvaluate block.

Fixes Netflix#933
mrmegapolys added a commit to mrmegapolys/dgs-codegen that referenced this pull request Apr 15, 2026
JacksonVersionDetector.detectVersions(project) was called in the
@TaskAction method, accessing Task.project at execution time which
is unsupported with configuration cache.

Move Jackson version detection to configuration time by adding a
@input property to GenerateJavaTask and resolving it in the plugin
afterEvaluate block.

Fixes Netflix#933
mrmegapolys added a commit to mrmegapolys/dgs-codegen that referenced this pull request Apr 15, 2026
JacksonVersionDetector.detectVersions(project) was called in the
@TaskAction method, accessing Task.project at execution time which
is unsupported with configuration cache.

Move Jackson version detection to configuration time by adding a
@input property to GenerateJavaTask and resolving it in the plugin
afterEvaluate block.

Fixes Netflix#933
mrmegapolys added a commit to mrmegapolys/dgs-codegen that referenced this pull request Apr 15, 2026
JacksonVersionDetector.detectVersions(project) was called in the
@TaskAction method, accessing Task.project at execution time which
is unsupported with configuration cache.

Move Jackson version detection to configuration time by adding a
@input property to GenerateJavaTask and resolving it in the plugin
afterEvaluate block.

Fixes Netflix#933
jiholee17 added a commit that referenced this pull request Apr 15, 2026
…son-detection

Fix Gradle configuration cache regression from #918
jiholee17 added a commit that referenced this pull request Apr 15, 2026
…he-jackson-detection

Revert "Fix Gradle configuration cache regression from #918"
@jiholee17 jiholee17 deleted the feature/jackson-3-support branch April 21, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jackson 3 support

3 participants