Visitar URL original
Add Jackson 3 support as org.msgpack.jackson3:jackson-dataformat-msgpack by xerial · Pull Request #1012 · msgpack/msgpack-java · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add msgpack-jackson3 module for Jackson 3.x support
  • Loading branch information
komamitsu committed May 31, 2026
commit 9b818d39b144e6f68495dd7c07967381a0c31bdc
15 changes: 13 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- 'project/build.properties'
- 'msgpack-core/**'
- 'msgpack-jackson/**'
- 'msgpack-jackson3/**'
docs:
- '**.md'
- '**.txt'
Expand Down Expand Up @@ -65,6 +66,16 @@ jobs:
key: ${{ runner.os }}-jdk${{ matrix.java }}-${{ hashFiles('**/*.sbt') }}
restore-keys: ${{ runner.os }}-jdk${{ matrix.java }}-
- name: Test
run: ./sbt test
run: |
if [[ ${{ matrix.java }} -lt 17 ]]; then
./sbt msgpack-core/test msgpack-jackson/test
else
./sbt test
fi
- name: Universal Buffer Test
run: ./sbt test -J-Dmsgpack.universal-buffer=true
run: |
if [[ ${{ matrix.java }} -lt 17 ]]; then
./sbt msgpack-core/test msgpack-jackson/test -J-Dmsgpack.universal-buffer=true
else
./sbt test -J-Dmsgpack.universal-buffer=true
fi
12 changes: 11 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ jobs:
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: |
./sbt publishSigned
./sbt msgpack-core/publishSigned msgpack-jackson/publishSigned
# msgpack-jackson3 requires JDK 17+
- uses: actions/setup-java@v5
with:
java-version: 17
distribution: temurin
- name: Build bundle for msgpack-jackson3
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: |
./sbt msgpack-jackson3/publishSigned
- name: Release to Sonatype
env:
SONATYPE_USERNAME: '${{ secrets.SONATYPE_USERNAME }}'
Expand Down
42 changes: 39 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,18 @@ val buildSettings = Seq[Setting[?]](
Test / compile := ((Test / compile) dependsOn (Test / jcheckStyle)).value
)

val junitJupiter = "org.junit.jupiter" % "junit-jupiter" % "5.14.4" % "test"
val junitVintage = "org.junit.vintage" % "junit-vintage-engine" % "5.14.4" % "test"
val junitJupiter = "org.junit.jupiter" % "junit-jupiter" % "5.14.4" % "test"
val junitVintage = "org.junit.vintage" % "junit-vintage-engine" % "5.14.4" % "test"
val junitInterface = "com.github.sbt" % "junit-interface" % "0.13.3" % "test"

// Project settings
val isJava17Plus: Boolean = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is meant to skip msgpack-jackson3, which compiles with --release 17, when the target JDK is older. But java.specification.version is the JDK running sbt, not the one compiling. Since #998 those are two different JDKs whenever TEST_JAVA_HOME is set, and sbt 2 requires its own to be 17+, so this is always true and the module is never skipped.

Before #998 there was no TEST_JAVA_HOME and one JDK did both, so it worked.

TEST_JAVA_HOME=<jdk8> ./sbt clean compile fails with javac: invalid flag: --release. The clean matters, stale classes hide it.

Minor: the comment says "the Jackson 3 module (msgpack-jackson)", which is the Jackson 2 module now.

val v = sys.props.getOrElse("java.specification.version", "1.8")
// getOrElse(false): non-numeric versions (e.g. early-access "17-ea") fail safe
// by not compiling the jackson3 module rather than making an optimistic guess.
if (v.startsWith("1.")) false else scala.util.Try(v.toInt >= 17).getOrElse(false)
}

lazy val root = Project(id = "msgpack-java", base = file("."))
.settings(
buildSettings,
Expand All @@ -108,7 +116,10 @@ lazy val root = Project(id = "msgpack-java", base = file("."))
publish := {},
publishLocal := {}
)
.aggregate(msgpackCore, msgpackJackson)
.aggregate(
Seq[ProjectReference](msgpackCore, msgpackJackson) ++
(if (isJava17Plus) Seq[ProjectReference](msgpackJackson3) else Nil): _*
)

lazy val msgpackCore = Project(id = "msgpack-core", base = file("msgpack-core"))
.enablePlugins(SbtOsgi)
Expand Down Expand Up @@ -170,3 +181,28 @@ lazy val msgpackJackson = Project(id = "msgpack-jackson", base = file("msgpack-j
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v")
)
.dependsOn(msgpackCore)

lazy val msgpackJackson3 = Project(id = "msgpack-jackson3", base = file("msgpack-jackson3"))
.enablePlugins(SbtOsgi, JmhPlugin)
.settings(
buildSettings,
name := "jackson-dataformat-msgpack-jackson3",
description := "Jackson 3.x extension that adds support for MessagePack",
OsgiKeys.bundleSymbolicName := "org.msgpack.msgpack-jackson3",
OsgiKeys.exportPackage := Seq("org.msgpack.jackson", "org.msgpack.jackson.dataformat"),
OsgiKeys.importPackage := Seq("!android.os", "!sun.*"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bnd drops any referenced package that matches nothing in this list, so with only exclusions the bundle gets no Import-Package header at all and can't resolve tools.jackson.* in OSGi. msgpack-jackson doesn't set this key and gets a correct header.

msgpack-jackson3 references neither sun.misc nor android.os, so the line can just go. My bug from #987.

Suggested change
OsgiKeys.importPackage := Seq("!android.os", "!sun.*"),

Test / fork := true,
javacOptions := Seq("--release", "17"),
doc / javacOptions := Seq("--release", "17", "-Xdoclint:none"),
libraryDependencies ++=
Seq(
"tools.jackson.core" % "jackson-databind" % "3.1.2",
junitInterface
),
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v"),
Jmh / javaOptions ++= Seq(
"--add-opens=java.base/java.nio=ALL-UNNAMED",
"--add-opens=java.base/sun.nio.ch=ALL-UNNAMED"
)
)
.dependsOn(msgpackCore)
Loading
Loading