Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
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
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 = {
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)
}
Comment on lines +104 to +109

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The parsing of java.specification.version can fail to identify Java 17+ correctly on early-access releases (e.g., "17-ea"), as v.toInt will throw a NumberFormatException and default to false.

We can make this check more robust by extracting only the leading digits of the specification version.

val isJava17Plus: Boolean = {
  val v = sys.props.getOrElse("java.specification.version", "1.8")
  val majorStr = if (v.startsWith("1.")) v.drop(2) else v
  val major = majorStr.takeWhile(_.isDigit)
  scala.util.Try(major.toInt >= 17).getOrElse(false)
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@gemini-code-assist Declining — the current behavior is intentional and documented in the comment on that line: early-access versions like "17-ea" fail safe by skipping the module rather than making an optimistic guess about compatibility.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I understand. Thank you for clarifying that the current behavior is intentional and documented to ensure a fail-safe mechanism for early-access Java versions. I will keep this in mind for future reviews.


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.*"),
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