Skip to content

Commit 3bc76d5

Browse files
authored
Merge branch 'main' into update/jackson-databind-2.18.4
2 parents ed1452e + 4e6458a commit 3bc76d5

38 files changed

+1109
-1077
lines changed

.github/workflows/CI.yml

Lines changed: 40 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,100 +2,67 @@ name: CI
22

33
on:
44
pull_request:
5-
paths:
6-
- '**.scala'
7-
- '**.java'
8-
- '**.sbt'
9-
- '.github/workflows/**.yml'
10-
- 'project/build.properties'
115
push:
126
branches:
137
- main
14-
paths:
15-
- '**.scala'
16-
- '**.java'
17-
- '**.sbt'
18-
- '.github/workflows/**.yml'
19-
- 'project/build.properties'
20-
workflow_dispatch:
8+
workflow_dispatch:
219

2210
jobs:
11+
changes:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
code: ${{ steps.changes.outputs.code }}
15+
docs: ${{ steps.changes.outputs.docs }}
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
- uses: dorny/paths-filter@v3
20+
id: changes
21+
with:
22+
filters: |
23+
code:
24+
- '**.scala'
25+
- '**.java'
26+
- '**.sbt'
27+
- '.github/workflows/**.yml'
28+
- 'project/build.properties'
29+
- 'msgpack-core/**'
30+
- 'msgpack-jackson/**'
31+
docs:
32+
- '**.md'
33+
- '**.txt'
34+
- 'LICENSE'
35+
2336
code_format:
2437
name: Code Format
2538
runs-on: ubuntu-latest
39+
needs: changes
40+
if: ${{ needs.changes.outputs.code == 'true' }}
2641
steps:
2742
- uses: actions/checkout@v4
2843
- name: jcheckstyle
2944
run: ./sbt jcheckStyle
30-
test_jdk21:
31-
name: Test JDK21
32-
runs-on: ubuntu-latest
33-
steps:
34-
- uses: actions/checkout@v4
35-
- uses: actions/setup-java@v4
36-
with:
37-
distribution: 'zulu'
38-
java-version: '21'
39-
- uses: actions/cache@v4
40-
with:
41-
path: ~/.cache
42-
key: ${{ runner.os }}-jdk21-${{ hashFiles('**/*.sbt') }}
43-
restore-keys: ${{ runner.os }}-jdk21-
44-
- name: Test
45-
run: ./sbt test
46-
- name: Universal Buffer Test
47-
run: ./sbt test -J-Dmsgpack.universal-buffer=true
48-
test_jdk17:
49-
name: Test JDK17
45+
46+
test:
47+
name: Test JDK${{ matrix.java }}
5048
runs-on: ubuntu-latest
49+
needs: changes
50+
if: ${{ needs.changes.outputs.code == 'true' }}
51+
strategy:
52+
matrix:
53+
java: ['8', '11', '17', '21', '24']
5154
steps:
5255
- uses: actions/checkout@v4
5356
- uses: actions/setup-java@v4
5457
with:
5558
distribution: 'zulu'
56-
java-version: '17'
59+
java-version: ${{ matrix.java }}
5760
- uses: actions/cache@v4
5861
with:
5962
path: ~/.cache
60-
key: ${{ runner.os }}-jdk17-${{ hashFiles('**/*.sbt') }}
61-
restore-keys: ${{ runner.os }}-jdk17-
63+
key: ${{ runner.os }}-jdk${{ matrix.java }}-${{ hashFiles('**/*.sbt') }}
64+
restore-keys: ${{ runner.os }}-jdk${{ matrix.java }}-
6265
- name: Test
6366
run: ./sbt test
6467
- name: Universal Buffer Test
65-
run: ./sbt test -J-Dmsgpack.universal-buffer=true
66-
test_jdk11:
67-
name: Test JDK11
68-
runs-on: ubuntu-latest
69-
steps:
70-
- uses: actions/checkout@v4
71-
- uses: actions/setup-java@v4
72-
with:
73-
distribution: 'zulu'
74-
java-version: '11'
75-
- uses: actions/cache@v4
76-
with:
77-
path: ~/.cache
78-
key: ${{ runner.os }}-jdk11-${{ hashFiles('**/*.sbt') }}
79-
restore-keys: ${{ runner.os }}-jdk11-
80-
- name: Test
81-
run: ./sbt test
82-
- name: Universal Buffer Test
83-
run: ./sbt test -J-Dmsgpack.universal-buffer=true
84-
test_jdk8:
85-
name: Test JDK8
86-
runs-on: ubuntu-latest
87-
steps:
88-
- uses: actions/checkout@v4
89-
- uses: actions/setup-java@v4
90-
with:
91-
distribution: 'zulu'
92-
java-version: '8'
93-
- uses: actions/cache@v4
94-
with:
95-
path: ~/.cache
96-
key: ${{ runner.os }}-jdk8-${{ hashFiles('**/*.sbt') }}
97-
restore-keys: ${{ runner.os }}-jdk8-
98-
- name: Test
99-
run: ./sbt test
100-
- name: Universal Buffer Test
101-
run: ./sbt test -J-Dmsgpack.universal-buffer=true
68+
run: ./sbt test -J-Dmsgpack.universal-buffer=true

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ jobs:
3333
./sbt publishSigned
3434
- name: Release to Sonatype
3535
env:
36-
SONATYPE_USERNAME: '${{ secrets.SONATYPE_USER }}'
37-
SONATYPE_PASSWORD: '${{ secrets.SONATYPE_PASS }}'
38-
run: ./sbt sonatypeBundleRelease
36+
SONATYPE_USERNAME: '${{ secrets.SONATYPE_USERNAME }}'
37+
SONATYPE_PASSWORD: '${{ secrets.SONATYPE_PASSWORD }}'
38+
run: ./sbt sonaRelease

.github/workflows/snapshot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ jobs:
2727
distribution: adopt
2828
- name: Publish snapshots
2929
env:
30-
SONATYPE_USERNAME: '${{ secrets.SONATYPE_USER }}'
31-
SONATYPE_PASSWORD: '${{ secrets.SONATYPE_PASS }}'
30+
SONATYPE_USERNAME: '${{ secrets.SONATYPE_USERNAME }}'
31+
SONATYPE_PASSWORD: '${{ secrets.SONATYPE_PASSWORD }}'
3232
run: ./sbt publish

.scalafmt.conf

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
maxColumn = 180
1+
version = 3.9.8
2+
project.layout = StandardConvention
3+
runner.dialect = scala3
4+
maxColumn = 100
25
style = defaultWithAlign
6+
docstrings.blankFirstLine = yes
7+
rewrite.scala3.convertToNewSyntax = true
8+
rewrite.scala3.removeOptionalBraces = yes
9+
rewrite.scala3.insertEndMarkerMinLines = 30
10+
# Add a new line before case class
11+
newlines.topLevelStatementBlankLines = [
12+
{
13+
blanks { after = 1 }
14+
}
15+
]
16+
newlines.source = unfold
317
optIn.breaksInsideChains = true

CLAUDE.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
MessagePack-Java is a binary serialization library that provides a fast and compact alternative to JSON. The project consists of two main modules:
8+
- **msgpack-core**: Standalone MessagePack implementation with no external dependencies
9+
- **msgpack-jackson**: Jackson integration for object mapping capabilities
10+
11+
## Essential Development Commands
12+
13+
### Build and Compile
14+
```bash
15+
./sbt compile # Compile source code
16+
./sbt "Test / compile" # Compile source and test code
17+
./sbt package # Create JAR files
18+
```
19+
20+
### Testing
21+
```bash
22+
./sbt test # Run all tests
23+
./sbt ~test # Run tests continuously on file changes
24+
./sbt testOnly *TestClass # Run specific test class
25+
./sbt "testOnly *TestClass -- -z pattern" # Run tests matching pattern
26+
27+
# Test with universal buffer mode (for compatibility testing)
28+
./sbt test -J-Dmsgpack.universal-buffer=true
29+
```
30+
31+
### Code Quality
32+
```bash
33+
./sbt jcheckStyle # Run checkstyle (Facebook Presto style)
34+
./sbt scalafmtAll # Format all Scala and sbt code
35+
```
36+
37+
### Publishing
38+
```bash
39+
./sbt publishLocal # Install to local .ivy2 repository
40+
./sbt publishM2 # Install to local .m2 Maven repository
41+
```
42+
43+
## Architecture Overview
44+
45+
### Core API Structure
46+
The main entry point is the `MessagePack` factory class which creates:
47+
- **MessagePacker**: Serializes objects to MessagePack binary format
48+
- **MessageUnpacker**: Deserializes MessagePack binary data
49+
50+
Key locations:
51+
- Core interfaces: `msgpack-core/src/main/java/org/msgpack/core/`
52+
- Jackson integration: `msgpack-jackson/src/main/java/org/msgpack/jackson/dataformat/`
53+
54+
### Buffer Management System
55+
MessagePack uses an efficient buffer abstraction layer:
56+
- **MessageBuffer**: Platform-optimized buffer implementations
57+
- Uses `sun.misc.Unsafe` for performance when available
58+
- Falls back to ByteBuffer on restricted platforms
59+
- **MessageBufferInput/Output**: Manages buffer sequences for streaming
60+
61+
### Jackson Integration
62+
The msgpack-jackson module provides:
63+
- **MessagePackFactory**: Jackson JsonFactory implementation
64+
- **MessagePackMapper**: Pre-configured ObjectMapper for MessagePack
65+
- Support for field IDs (integer keys) for compact serialization
66+
- Extension type support including timestamps
67+
68+
### Testing Structure
69+
- **msgpack-core tests**: Written in Scala (always use the latest Scala 3 version) using AirSpec framework
70+
- Location: `msgpack-core/src/test/scala/`
71+
- **msgpack-jackson tests**: Written in Java using JUnit
72+
- Location: `msgpack-jackson/src/test/java/`
73+
74+
## Important JVM Options
75+
76+
For JDK 17+ compatibility, these options are automatically added:
77+
```
78+
--add-opens=java.base/java.nio=ALL-UNNAMED
79+
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
80+
```
81+
82+
## Code Style Requirements
83+
- Java code follows Facebook Presto style (enforced by checkstyle)
84+
- Scala test code uses Scalafmt with Scala 3 dialect and 100 character line limit
85+
- Checkstyle runs automatically during compilation
86+
- No external dependencies allowed in msgpack-core
87+
88+
## Key Design Principles
89+
1. **Zero Dependencies**: msgpack-core has no external dependencies
90+
2. **Platform Optimization**: Uses platform-specific optimizations when available
91+
3. **Streaming Support**: Both streaming and object-based APIs
92+
4. **Type Safety**: Immutable Value hierarchy for type-safe data handling
93+
5. **Extension Support**: Extensible type system for custom data types

README.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ msgpack-java uses [sbt](http://www.scala-sbt.org/) for building the projects. Fo
6666
Coding style
6767
* msgpack-java uses [the same coding style](https://github.com/airlift/codestyle) with Facebook Presto
6868
* [IntelliJ setting file](https://raw.githubusercontent.com/airlift/codestyle/master/IntelliJIdea14/Airlift.xml)
69+
* Scala test code uses Scalafmt with Scala 3 dialect (always use the latest Scala 3 version)
6970

7071
### Basic sbt commands
7172
Enter the sbt console:
@@ -76,14 +77,14 @@ $ ./sbt
7677
Here is a list of sbt commands for daily development:
7778
```
7879
> ~compile # Compile source codes
79-
> ~test:compile # Compile both source and test codes
80+
> ~"Test / compile" # Compile both source and test codes
8081
> ~test # Run tests upon source code change
8182
> ~testOnly *MessagePackTest # Run tests in the specified class
8283
> ~testOnly *MessagePackTest -- (pattern) # Run tests matching the pattern
8384
> project msgpack-core # Focus on a specific project
8485
> package # Create a jar file in the target folder of each project
8586
> jcheckStyle # Run check style
86-
> scalafmtAll # Reformat code
87+
> scalafmtAll # Format all Scala and sbt code
8788
```
8889

8990
### Publishing
@@ -107,27 +108,38 @@ A new release note will be generated automatically at the [GitHub Releases](http
107108

108109
#### Publishing to Sonatype from Local Machine
109110

110-
If you need to publish to Maven central using a local machine, you need to configure [sbt-sonatype](https://github.com/xerial/sbt-sonatype) plugin. First set Sonatype account information (user name and password) in the global sbt settings. To protect your password, never include this file in your project.
111+
If you need to publish to Maven central using a local machine, you need to configure credentials for Sonatype Central. First set Sonatype account information (user name and password) in the global sbt settings. To protect your password, never include this file in your project.
111112

112-
___$HOME/.sbt/(sbt-version)/sonatype.sbt___
113+
___$HOME/.sbt/1.0/credentials.sbt___
113114

114115
```
115-
credentials += Credentials("Sonatype Nexus Repository Manager",
116-
"oss.sonatype.org",
117-
"(Sonatype user name)",
118-
"(Sonatype password)")
116+
credentials += Credentials(Path.userHome / ".sbt" / "sonatype_central_credentials")
117+
```
118+
119+
Then create a credentials file at `~/.sbt/sonatype_central_credentials`:
120+
121+
```
122+
host=central.sonatype.com
123+
user=<your username>
124+
password=<your password>
125+
```
126+
127+
Alternatively, you can use environment variables:
128+
```bash
129+
export SONATYPE_USERNAME=<your username>
130+
export SONATYPE_PASSWORD=<your password>
119131
```
120132

121133
You may also need to configure GPG. See the instruction in [sbt-pgp](https://github.com/sbt/sbt-pgp).
122134

123-
Then, run `publishedSigned` followed by `sonatypeBundleRelease`:
135+
Then, run `publishSigned` followed by `sonaRelease`:
124136
```
125137
# [optional] When you need to perform the individual release steps manually, use the following commands:
126138
> publishSigned # Publish GPG signed artifacts to the Sonatype repository
127-
> sonatypeBundleRelease # Publish to the Maven Central (It will be synched within less than 4 hours)
139+
> sonaRelease # Publish to the Maven Central (It will be synched within less than 4 hours)
128140
```
129141

130-
If some sporadic error happens (e.g., Sonatype timeout), rerun `sonatypeBundleRelease` again.
142+
If some sporadic error happens (e.g., Sonatype timeout), rerun `sonaRelease` again.
131143

132144
### Project Structure
133145

0 commit comments

Comments
 (0)