Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit b2477eb

Browse files
author
Kit Plummer
authored
INIT: Java Library Functionality (#8)
* update: working java tests and example, ready for eyeball review, once full multi-peer test has validated all field merging as expected
1 parent beb0e97 commit b2477eb

40 files changed

Lines changed: 5250 additions & 215 deletions

.github/workflows/java-ci.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Java CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
JAVA_VERSION: '17'
11+
GRADLE_OPTS: -Dorg.gradle.daemon=false
12+
13+
jobs:
14+
lint-and-check:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up JDK ${{ env.JAVA_VERSION }}
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: ${{ env.JAVA_VERSION }}
23+
distribution: 'temurin'
24+
25+
- name: Cache Gradle packages
26+
uses: actions/cache@v4
27+
with:
28+
path: |
29+
~/.gradle/caches
30+
~/.gradle/wrapper
31+
key: ${{ runner.os }}-gradle-${{ hashFiles('java/**/*.gradle*', 'java/**/gradle-wrapper.properties') }}
32+
restore-keys: |
33+
${{ runner.os }}-gradle-
34+
35+
- name: Make gradlew executable
36+
working-directory: ./java
37+
run: chmod +x gradlew
38+
39+
- name: Run Checkstyle
40+
working-directory: ./java
41+
run: ./gradlew :library:checkstyleMain :library:checkstyleTest :example:checkstyleMain :example:checkstyleTest
42+
43+
- name: Generate schema classes
44+
working-directory: ./java
45+
run: ./gradlew :library:generateSchemaClasses
46+
47+
build-and-test:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: Set up JDK ${{ env.JAVA_VERSION }}
53+
uses: actions/setup-java@v4
54+
with:
55+
java-version: ${{ env.JAVA_VERSION }}
56+
distribution: 'temurin'
57+
58+
- name: Cache Gradle packages
59+
uses: actions/cache@v4
60+
with:
61+
path: |
62+
~/.gradle/caches
63+
~/.gradle/wrapper
64+
key: ${{ runner.os }}-gradle-${{ hashFiles('java/**/*.gradle*', 'java/**/gradle-wrapper.properties') }}
65+
restore-keys: |
66+
${{ runner.os }}-gradle-
67+
68+
- name: Make gradlew executable
69+
working-directory: ./java
70+
run: chmod +x gradlew
71+
72+
- name: Generate schema classes
73+
working-directory: ./java
74+
run: ./gradlew :library:generateSchemaClasses
75+
76+
- name: Build library
77+
working-directory: ./java
78+
run: ./gradlew :library:build -x test
79+
80+
- name: Run tests
81+
working-directory: ./java
82+
run: ./gradlew :library:test :example:test
83+
84+
- name: Generate test report
85+
working-directory: ./java
86+
run: ./gradlew :library:jacocoTestReport
87+
88+
- name: Upload test results
89+
uses: actions/upload-artifact@v4
90+
if: always()
91+
with:
92+
name: test-results
93+
path: |
94+
java/library/build/reports/tests/
95+
java/library/build/reports/jacoco/
96+
97+
- name: Upload coverage to Codecov (optional)
98+
uses: codecov/codecov-action@v4
99+
if: success()
100+
with:
101+
file: java/library/build/reports/jacoco/test/jacocoTestReport.xml
102+
flags: java
103+
name: java-coverage
104+
fail_ci_if_error: false
105+
106+
integration-test:
107+
runs-on: ubuntu-latest
108+
needs: build-and-test
109+
steps:
110+
- uses: actions/checkout@v4
111+
112+
- name: Set up JDK ${{ env.JAVA_VERSION }}
113+
uses: actions/setup-java@v4
114+
with:
115+
java-version: ${{ env.JAVA_VERSION }}
116+
distribution: 'temurin'
117+
118+
- name: Cache Gradle packages
119+
uses: actions/cache@v4
120+
with:
121+
path: |
122+
~/.gradle/caches
123+
~/.gradle/wrapper
124+
key: ${{ runner.os }}-gradle-${{ hashFiles('java/**/*.gradle*', 'java/**/gradle-wrapper.properties') }}
125+
restore-keys: |
126+
${{ runner.os }}-gradle-
127+
128+
- name: Make gradlew executable
129+
working-directory: ./java
130+
run: chmod +x gradlew
131+
132+
- name: Run integration tests
133+
working-directory: ./java
134+
run: ./gradlew :library:test --tests "com.ditto.cot.CoTConverterIntegrationTest"
135+
136+
- name: Run XML round-trip tests
137+
working-directory: ./java
138+
run: ./gradlew :library:test --tests "com.ditto.cot.CoTXmlRoundTripTest"

.mcp.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"mcpServers": {
3+
"linear": {
4+
"command": "npx",
5+
"args": [
6+
"-y",
7+
"@modelcontextprotocol/server-linear"
8+
]
9+
},
10+
"notion": {
11+
"command": "npx",
12+
"args": [
13+
"-y",
14+
"@modelcontextprotocol/server-notion"
15+
]
16+
}
17+
}
18+
}

CLAUDE.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Claude Configuration for Ditto CoT Library
2+
3+
This document provides specific instructions for Claude when working with the Ditto CoT library project.
4+
5+
## Project Context
6+
7+
Multi-language libraries (starting from a single managed JSON Schema) for translating between Cursor-on-Target (CoT) XML events and Ditto-compatible CRDT documents.
8+
9+
## Linear Integration Guidelines
10+
11+
**IMPORTANT:** When working with Linear tickets:
12+
13+
- **NEVER** automatically change the status or state of Linear issues
14+
- **NEVER** transition issues between states (e.g., from "In Progress" to "Done")
15+
- **DO** read and reference Linear tickets for context
16+
- **DO** add comments to issues when explicitly requested
17+
- **DO NOT** modify any issue properties (assignee, labels, priority, etc.)
18+
- All status transitions should be handled manually by the development team
19+
20+
## Development Guidelines
21+
22+
### Testing Requirements
23+
24+
- Always run tests before suggesting code completion
25+
- For Ditto CoT library development:
26+
- All tests: `make test`
27+
- Suggest running lint and type checking if available
28+
- Verify that all tests pass before marking any task as complete
29+
30+
### Build Commands
31+
32+
- Build debug: `make clean`
33+
34+
## Code Style Guidelines
35+
36+
### General
37+
38+
- Follow existing code conventions in the codebase
39+
- Use meaningful variable and function names
40+
- Maintain consistent indentation (check existing files)
41+
- Avoid adding debug prints or logs unless specifically requested
42+
43+
### Java/Android/Kotlin Specific
44+
45+
- Follow Java/Androind/Kotlin coding conventions
46+
- Use proper null safety patterns
47+
- Prefer data classes for data models
48+
- Use appropriate visibility modifiers
49+
50+
### Rust Specific
51+
52+
- Follow Rust coding conventions and idioms
53+
54+
### C# Specific
55+
56+
- Follow C# and .NET coding conventions and idioms
57+
58+
### Documentation
59+
60+
- Do not create documentation files unless explicitly requested
61+
- Keep code comments minimal and meaningful
62+
- Update existing documentation when making related changes
63+
64+
## Important Reminders
65+
66+
1. **Security**: Never commit sensitive information like API keys, passwords, or tokens
67+
2. **Dependencies**: Check existing dependencies before suggesting new ones
68+
3. **File Creation**: Prefer modifying existing files over creating new ones
69+
4. **Breaking Changes**: Always highlight potential breaking changes
70+
5. **Error Handling**: Implement proper error handling for all new features
71+
72+
## Learning More About Ditto
73+
74+
When you need more context about Ditto's architecture, conventions, or specific implementations:
75+
76+
https://docs.ditto.live
77+
78+
For Rust SDK: https://software.ditto.live/rust/Ditto/4.11.0/x86_64-unknown-linux-gnu/docs/dittolive_ditto/index.html
79+
For Java SDK: https://software.ditto.live/java/ditto-java/4.11.0-preview.1/api-reference/
80+
For C# SDK: https://software.ditto.live/dotnet/Ditto/4.11.0/api-reference/
81+
82+
### When in Doubt, Ask First
83+
84+
If you don't know how to do something, and you can't find accurate and up-to-date information from sources such as online documentation, content in Notion or Linear, or a tool's help output or man pages, then ask about an approach before doing it instead of guessing.

Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,16 @@ clean-rust:
1919
# Java targets
2020
.PHONY: java
2121
java:
22-
@echo "Building Java library..."
22+
@echo "Cleaning previous build and generated sources..."
2323
@if [ -f "java/build.gradle" ] || [ -f "java/build.gradle.kts" ]; then \
24-
cd java && ./gradlew build -x test; \
24+
cd java && \
25+
rm -rf build/generated-src build/classes build/resources build/tmp build/libs build/reports build/test-results && \
26+
mkdir -p src/main/java/com/ditto/cot/schema && \
27+
find src/main/java/com/ditto/cot/schema -type f -name '*.java' -delete; \
28+
echo "Generating Java classes from schema..."; \
29+
./gradlew generateSchemaClasses; \
30+
echo "Building Java library..."; \
31+
./gradlew build -x test; \
2532
else \
2633
echo "Java build files not found. Skipping."; \
2734
fi
@@ -61,13 +68,13 @@ test: test-rust test-java test-csharp
6168
.PHONY: test-rust
6269
test-rust:
6370
@echo "Testing Rust library..."
64-
@cd rust && cargo test --all-targets
71+
@cd rust && cargo nextest run
6572

6673
.PHONY: test-java
6774
test-java:
68-
@echo "Testing Java library..."
75+
@echo "Testing Java library and example..."
6976
@if [ -f "java/build.gradle" ] || [ -f "java/build.gradle.kts" ]; then \
70-
cd java && ./gradlew test; \
77+
cd java && ./gradlew :library:test :example:test --console=rich --rerun-tasks; \
7178
else \
7279
echo "Java build files not found. Skipping tests."; \
7380
fi

java/.gitignore

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,94 @@
11
# Gradle
22
.gradle/
33
build/
4+
!gradle/wrapper/gradle-wrapper.jar
5+
.gradletasknamecache
6+
7+
# Build outputs
8+
bin/
9+
classes/
10+
out/
411

512
# IDE files
613
.idea/
714
*.iml
8-
.classpath
15+
*.ipr
16+
*.iws
17+
*.classpath
918
.project
1019
.settings/
11-
bin/
20+
.vscode/
21+
*.launch
22+
*.sublime-workspace
23+
*.sublime-project
1224

1325
# Local configuration
1426
local.properties
27+
local.gradle
28+
.gradle.properties
1529

1630
# Compiled class files
1731
*.class
1832

1933
# Log files
2034
*.log
35+
logs/
2136

2237
# Package files
2338
*.jar
24-
!gradle/wrapper/gradle-wrapper.jar
39+
*.war
40+
*.ear
41+
*.zip
42+
*.tar.gz
43+
*.rar
44+
45+
# Virtual machine crash logs
46+
hs_err_pid*
47+
48+
# Generated files and directories
49+
**/generated-src/
50+
**/generated/
51+
**/generated_test/
52+
53+
# Test reports and coverage
54+
**/test-results/
55+
**/test-results-*/
56+
**/test-output-*/
57+
**/test-report-*/
58+
**/reports/
59+
**/coverage/
60+
**/jacoco/
61+
62+
# OS specific files
63+
.DS_Store
64+
.DS_Store?
65+
._*
66+
.Spotlight-V100
67+
.Trashes
68+
ehthumbs.db
69+
Thumbs.db
70+
71+
# Build scan files
72+
build/scan*/
73+
build/reports/scan/
74+
75+
# Gradle Daemon files
76+
.gradle/native
77+
.gradle/daemon/
78+
.gradle/vcs-1/
79+
.gradle/buildOutputCleanup/
80+
.gradle/build-scan-data/
81+
.gradle/buildOutputCleanup/
82+
.gradle/checksums/
83+
.gradle/configuration-cache/
84+
.gradle/daemon/
85+
.gradle/jdks/
86+
.gradle/normalization/
87+
.gradle/notifications/
88+
.gradle/workers/
89+
.gradle/workers/
90+
.gradle/wrapper/dists/
91+
92+
# Ditto specific
93+
target/
94+
buildSrc/build/

java/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Ditto
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)