Repository navigation
cn1lib: a library can carry a server half - #6139
shai-almog wants to merge 3 commits into
Conversation
A jar marked with META-INF/codenameone/backend-library is a backend library: a server that depends on one wires its controllers, beans, entities, repositories and migrations as its own, on the JVM (Maven process-annotations, Gradle compileJava) and in the native backend build. The library itself is never processed. A .cn1lib carries the server half as backend.zip; the cn1lib archetype gains a backend module and Gradle cn1libs publish <name>-backend. The merge records what it copied, with each file's size and CRC, so a library upgraded or dropped leaves nothing stale, and a class the module compiled over a merged one stays the module's. The record is restamped after processing, failed or not, because weaving rewrites merged classes in place. Tested by BackendLibrariesTest, backend-cn1lib-test.sh (archetype-smoke, JVM and native) and gradle-cn1lib-test.sh; documented in the developer guide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guide's snippet gate requires every source block to come from docs/demos. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cloudflare Preview
|
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
ProcessAnnotationsMojoTest runs the mojo with no project; every other helper there allows for that, and the backend-library check did not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Flutter vs Codename OneSame application, built both ways: Flutter's AOT compile of the gallery, and the identical Dart source transpiled to Java on Codename One. Lower is better for every metric, so a ratio above 1.00x means Codename One is ahead by that factor. android9 interleaved rounds; host load 0.63, 1.86, 1.66
Compute -- the VM workloads (
Gate: within tolerance against
ios9 interleaved rounds; host load 16.45, 28.5, 27.34
Compute -- the VM workloads ( Not measured: iOS compute is not measured: a device build needs signed hardware, and on the simulator Flutter runs its JIT debug engine rather than AOT code. The macOS row runs the same ParparVM and Dart AOT compilers on the same Apple silicon. Gate: within tolerance against
javascript9 interleaved rounds; host load 2.68, 1.59, 0.71
Compute -- the VM workloads (
Gate: within tolerance against
linux9 interleaved rounds; host load 0.35, 3.06, 2.64
Compute -- the VM workloads (
Gate: OUTSIDE THE BASELINE against
macos9 interleaved rounds; host load 2.5, 17.22, 21.04
Compute -- the VM workloads (
Gate: within tolerance against
windows9 interleaved rounds
Compute -- the VM workloads (
Gate: within tolerance against
Codename One wins 26 of 26 measured metrics across 6 platform(s). |
|
Developer Guide build artifacts are available for download from this workflow run:
Developer Guide quality checks: |
|
Compared 195 screenshots: 195 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
|
Compared 231 screenshots: 231 matched. |
|
Compared 192 screenshots: 192 matched. Benchmark Results
Detailed Performance Metrics
|
|
Compared 196 screenshots: 196 matched. Benchmark Results
Detailed Performance Metrics
ParparVM vs HotSpot (JDK 25): macOS arm64Runner CPU: Apple M1 (Virtual) (baseline Ratios are ParparVM / JDK 25: below 1.00x ParparVM is faster (time) or smaller (RAM). Median of 5 interleaved, paired rounds; every run's output was verified. A ratio more than 20% (time) / 25% (RAM) above its baseline in
Result: no regression |























A cn1lib can now ship server code. Its controllers, beans, entities, repositories and migrations are wired into any server that depends on it, as if that server had compiled them.
How
META-INF/codenameone/backend-libraryis a backend library.BackendLibraries.mergecopies it into the server module's classes before annotation processing: Mavenprocess-annotations, GradlecompileJava, and the nativeBackendPackager. The library itself is never processed, so its generated wiring can't collide with the server's..cn1libgainsbackend.zip(Cn1libMojopacks it,Cn1libInstallerunpacks it to thebackendclassifier). The cn1lib archetype gets abackendmodule, and Gradle cn1libs publish<name>-backendfromsrc/backend/{java,resources}.compileJava. Without that, compile avoidance would skip the merge when a library changes a method body or a migration.cn1-nativefrom a library (jar or directory), so no class is translated twice.Tests
BackendLibrariesTest: 7 tests, including the module-class-wins and rewritten-class cases.maven/integration-tests/backend-cn1lib-test.sh: new, runs in archetype-smoke. A generated cn1lib with an endpoint, service, entity, repository and migration is consumed by a generated server, and checked with@BackendTestand natively compiled tests.gradle-cn1lib-test.shchecks the<name>-backendartifact.Docs: Backend-Beans ("Controllers and beans from a library"), Backend-Data, Advanced Topics (cn1lib contents) and Gradle-Project-Workflow.
🤖 Generated with Claude Code