Skip to content

Commit 78c382b

Browse files
committed
Rename langchain4j module to llama-langchain4j; wire CI build/test + Central publish
Cleans up the integration of the merged langchain4j adapters (PR #284) so the module is built, gated, version-locked and releasable — without touching the native build/release pipeline. - Rename artifact + directory langchain4j-jllama -> llama-langchain4j so it groups with the core net.ladenthin:llama family (Java package unchanged). - Pin the core dependency to ${project.version} (drops the drift-prone jllama.version property); a CI guard fails the build if the module version ever diverges from the core version (standalone module can't inherit it from a reactor). - Add per-artifact release plumbing (sources + javadoc + gpg + Central Publishing) mirroring the core release profile, so the module can deploy to Maven Central at the same version. - publish.yml: new test-java-llama-langchain4j job (install core Java jar, version-lockstep guard, mvn verify — builds the javadoc jar so a release-time javadoc break is caught in PR CI). publish-snapshot/publish-release now depend on it and deploy the module alongside the core. - REUSE.toml + README updated to the new name; CLAUDE.md documents the module, why it is a separate artifact (not a classifier), and the CI/publish wiring. Verified locally: core Java jar installs, module builds green (7 mapping tests pass, 2 model-backed integration tests self-skip), and the main/sources/javadoc jars all build under doclint=all. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rt1paYztGJ2AKUuBuAGDXE
1 parent b5ee309 commit 78c382b

14 files changed

Lines changed: 304 additions & 100 deletions

File tree

.github/workflows/publish.yml

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,45 @@ jobs:
9393
echo "=== internal package dependency graph (jdeps, bytecode) ==="
9494
jdeps -verbose:package target/classes | grep 'net.ladenthin.llama' || true
9595
96+
# ---------------------------------------------------------------------------
97+
# Sibling module `llama-langchain4j` (LangChain4j adapters). Pure Java, no native
98+
# code and no per-classifier matrix: it compiles against the core's stable Java API
99+
# (identical across every classifier) and the backend is a runtime choice for the
100+
# consumer. This job installs the core Java jar, guards that the module version is in
101+
# lockstep with the core, then builds + tests the module (Java 17; langchain4j 1.x
102+
# baseline). It runs its mapping unit tests; the model-backed integration test
103+
# self-skips without a GGUF. `verify` also builds the javadoc/sources jars so a
104+
# release-time javadoc break is caught here in PR CI.
105+
# ---------------------------------------------------------------------------
106+
107+
test-java-llama-langchain4j:
108+
name: Build and Test llama-langchain4j
109+
needs: startgate
110+
runs-on: ubuntu-latest
111+
steps:
112+
- uses: actions/checkout@v7
113+
- uses: actions/setup-java@v5
114+
with:
115+
java-version: ${{ env.JAVA_VERSION }}
116+
distribution: temurin
117+
- name: Version lockstep guard (module version must equal core version)
118+
shell: bash
119+
run: |
120+
CORE=$(mvn -q -DforceStdout help:evaluate -Dexpression=project.version | tail -n1)
121+
MOD=$(mvn -q -DforceStdout -f llama-langchain4j/pom.xml help:evaluate -Dexpression=project.version | tail -n1)
122+
echo "core=$CORE module=$MOD"
123+
if [ "$CORE" != "$MOD" ]; then
124+
echo "::error::Version drift: core ($CORE) != llama-langchain4j ($MOD). Keep llama-langchain4j/pom.xml <version> in lockstep with the root pom.xml."
125+
exit 1
126+
fi
127+
- name: Install core net.ladenthin:llama jar (Java only)
128+
run: >
129+
mvn -B --no-transfer-progress -DskipTests -Denforcer.skip=true
130+
-Dspotless.check.skip=true -Dspotbugs.skip=true
131+
-Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Dgpg.skip=true install
132+
- name: Build and test llama-langchain4j
133+
run: mvn -B --no-transfer-progress -f llama-langchain4j/pom.xml verify
134+
96135
# ---------------------------------------------------------------------------
97136
# Build the llama.cpp WebUI ONCE, from the same pinned tag CMakeLists.txt fetches,
98137
# and share it to every native build as the generated, platform-independent
@@ -1665,7 +1704,7 @@ jobs:
16651704

16661705
publish-snapshot:
16671706
name: Publish Snapshot to Central
1668-
needs: [check-snapshot, crosscompile-linux-x86_64-cuda, crosscompile-android-aarch64-opencl, code-style]
1707+
needs: [check-snapshot, crosscompile-linux-x86_64-cuda, crosscompile-android-aarch64-opencl, code-style, test-java-llama-langchain4j]
16691708
if: needs.check-snapshot.result == 'success' && inputs.publish_to_central
16701709
runs-on: ubuntu-latest
16711710
environment: maven-central
@@ -1731,11 +1770,23 @@ jobs:
17311770
MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
17321771
MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN }}
17331772
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
1773+
# Deploy the sibling llama-langchain4j at the same version. The core `deploy`
1774+
# above ran through `install`, so net.ladenthin:llama is in the local repo for
1775+
# the module to resolve. Standalone module (not in the reactor), so it is a
1776+
# separate deploy invocation.
1777+
- name: Publish snapshot (llama-langchain4j)
1778+
run: mvn --batch-mode --no-transfer-progress -f llama-langchain4j/pom.xml -P release -Dmaven.test.skip=true deploy
1779+
env:
1780+
MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
1781+
MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN }}
1782+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
17341783
- name: Collect signed artifacts
17351784
run: |
17361785
mkdir -p signed-snapshot-assets
17371786
cp target/*.jar signed-snapshot-assets/ 2>/dev/null || true
17381787
cp target/*.jar.asc signed-snapshot-assets/ 2>/dev/null || true
1788+
cp llama-langchain4j/target/*.jar signed-snapshot-assets/ 2>/dev/null || true
1789+
cp llama-langchain4j/target/*.jar.asc signed-snapshot-assets/ 2>/dev/null || true
17391790
- uses: actions/upload-artifact@v7
17401791
with:
17411792
name: signed-snapshot-assets
@@ -1770,7 +1821,7 @@ jobs:
17701821
publish-release:
17711822
name: Publish Release to Central
17721823
if: needs.check-tag.result == 'success' && inputs.publish_to_central
1773-
needs: [check-tag, crosscompile-linux-x86_64-cuda, crosscompile-android-aarch64-opencl, code-style]
1824+
needs: [check-tag, crosscompile-linux-x86_64-cuda, crosscompile-android-aarch64-opencl, code-style, test-java-llama-langchain4j]
17741825
runs-on: ubuntu-latest
17751826
environment: maven-central
17761827
permissions:
@@ -1826,11 +1877,23 @@ jobs:
18261877
MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
18271878
MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN }}
18281879
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
1880+
# Deploy the sibling llama-langchain4j at the same version. The core `deploy`
1881+
# above ran through `install`, so net.ladenthin:llama is in the local repo for
1882+
# the module to resolve. Standalone module (not in the reactor), so it is a
1883+
# separate deploy invocation.
1884+
- name: Publish release (llama-langchain4j)
1885+
run: mvn --batch-mode --no-transfer-progress -f llama-langchain4j/pom.xml -P release -Dmaven.test.skip=true deploy
1886+
env:
1887+
MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
1888+
MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN }}
1889+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
18291890
- name: Collect signed artifacts
18301891
run: |
18311892
mkdir -p signed-release-assets
18321893
cp target/*.jar signed-release-assets/ 2>/dev/null || true
18331894
cp target/*.jar.asc signed-release-assets/ 2>/dev/null || true
1895+
cp llama-langchain4j/target/*.jar signed-release-assets/ 2>/dev/null || true
1896+
cp llama-langchain4j/target/*.jar.asc signed-release-assets/ 2>/dev/null || true
18341897
- uses: actions/upload-artifact@v7
18351898
with:
18361899
name: signed-release-assets

CLAUDE.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,48 @@ keeping it clear of the JPMS module-mode javadoc trap that bit BAF. **Before rai
12191219
javadoc source level to ≥ 9, read**
12201220
[`../workspace/policies/jpms-module-descriptor.md`](../workspace/policies/jpms-module-descriptor.md).
12211221
1222+
## LangChain4j integration (`llama-langchain4j` sibling module)
1223+
1224+
`llama-langchain4j/` adapts a `LlamaModel` to LangChain4j's `ChatModel`,
1225+
`StreamingChatModel`, `EmbeddingModel` and `ScoringModel` interfaces **in-process over
1226+
JNI** (no HTTP hop). It is a **standalone sibling module**, deliberately *not* in the root
1227+
reactor, so the native build/release pipeline is untouched.
1228+
1229+
Why it is a **separate artifact** and not a classifier of the core: langchain4j 1.x
1230+
requires **Java 17** (the core stays Java 8), and classifiers share the core's single POM —
1231+
adding `langchain4j-core` there would force it (and the Java 17 floor) on every plain
1232+
`net.ladenthin:llama` consumer. A separate `artifactId` with its own POM is the only way to
1233+
keep that dependency (and Java floor) off the core. It is pure Java with **no per-classifier
1234+
matrix**: it compiles against the core's Java API, which is identical across every native
1235+
classifier; the backend (CPU/CUDA/OpenCL/Vulkan) is a runtime classpath choice for the
1236+
consumer.
1237+
1238+
Wiring:
1239+
1240+
1. **`llama-langchain4j/pom.xml`** — `net.ladenthin:llama-langchain4j`, `release 17`,
1241+
depends on `net.ladenthin:llama:${project.version}` (so the core dep always matches the
1242+
module's own version) and `dev.langchain4j:langchain4j-core`. Carries its own
1243+
sources/javadoc/gpg + `release` profile (Central requires per-artifact signing; the module
1244+
has no parent to inherit them from — plugin versions are pinned in lockstep with the root
1245+
`pom.xml`). Java package stays `net.ladenthin.llama.langchain4j` (package name need not track
1246+
the artifactId).
1247+
2. **`.github/workflows/publish.yml`** — the `test-java-llama-langchain4j` job installs the
1248+
core Java jar, runs a **version-lockstep guard** (module version must equal core version,
1249+
else the build fails — the standalone module can't inherit `${project.version}` from a
1250+
reactor), then `mvn -f llama-langchain4j/pom.xml verify` (mapping unit tests run; the
1251+
model-backed `JllamaChatModelIntegrationTest` self-skips without a GGUF; `verify` also
1252+
builds the javadoc jar so a release-time javadoc break is caught in PR CI). The
1253+
`publish-snapshot`/`publish-release` jobs `needs:` this job and, after the core `deploy`
1254+
(which installs the core jar locally), run a second `deploy` of the module at the same
1255+
version.
1256+
3. **Version bumps** — when the root `pom.xml` `<version>` changes, bump
1257+
`llama-langchain4j/pom.xml` `<version>` to match in the same commit, or the lockstep guard
1258+
reds CI.
1259+
1260+
**Open follow-ups** (documented in `llama-langchain4j/README.md`): tool calling
1261+
(`ToolSpecification` ↔ jllama `ToolDefinition`), `response_format`/JSON mode, and multimodal
1262+
user input (currently flattened to text).
1263+
12221264
## Open TODOs
12231265
12241266
Open TODOs for this repo live in [`TODO.md`](TODO.md). Cross-repo status

REUSE.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ path = [
2424
".github/ISSUE_TEMPLATE/bug_report.md",
2525
".github/ISSUE_TEMPLATE/feature_request.md",
2626
".claude/commands/find-cpp-duplication.md",
27-
"langchain4j-jllama/README.md",
27+
"llama-langchain4j/README.md",
2828
]
2929
SPDX-FileCopyrightText = [
3030
"2023-2025 Konstantin Herud",

langchain4j-jllama/pom.xml

Lines changed: 0 additions & 94 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# langchain4j-jllama
1+
# llama-langchain4j
22

33
[LangChain4j](https://github.com/langchain4j/langchain4j) adapters backed by an **in-process**
44
[java-llama.cpp](https://github.com/bernardladenthin/java-llama.cpp) model over JNI — no HTTP server,
@@ -61,7 +61,7 @@ ScoringModel reranker = new JllamaScoringModel(rerankLlama);
6161
```xml
6262
<dependency>
6363
<groupId>net.ladenthin</groupId>
64-
<artifactId>langchain4j-jllama</artifactId>
64+
<artifactId>llama-langchain4j</artifactId>
6565
<version>5.0.4-SNAPSHOT</version>
6666
</dependency>
6767
```
@@ -79,7 +79,7 @@ build here:
7979
mvn -DskipTests install
8080

8181
# then build/test this module
82-
cd langchain4j-jllama
82+
cd llama-langchain4j
8383
mvn test
8484
```
8585

0 commit comments

Comments
 (0)