diff --git a/CHANGELOG.md b/CHANGELOG.md index 0294b38e..7f71ef07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ The release run heads these entries with the version and opens a fresh - A pdf that nests parentheses inside a string opens, and keeps its document metadata — `cairo` and `pdfTeX` write their `/Producer` that way. +- A jni build without a JDK fails instead of shipping a package missing + `odr-core-java.jar`. `ODR_JNI_JAR=OFF` is how the AAR build asks for the + native half alone. ## v6.9.0 - 2026-08-18 diff --git a/android/build_native.py b/android/build_native.py index 2df19b23..e77bb0e8 100644 --- a/android/build_native.py +++ b/android/build_native.py @@ -93,6 +93,8 @@ def build(architecture: str, conan: str, build_profile: str, output: Path) -> No # rather than shipped as a second .so the app would have to load "-DBUILD_SHARED_LIBS=OFF", "-DODR_JNI=ON", + # the AAR compiles `jni/java/` itself, so no jar and no JDK here + "-DODR_JNI_JAR=OFF", "-DODR_CLI=OFF", "-DODR_TEST=OFF", "-DODR_WITH_HTTP_SERVER=ON"]) diff --git a/jni/AGENTS.md b/jni/AGENTS.md index de5111f4..b86f92de 100644 --- a/jni/AGENTS.md +++ b/jni/AGENTS.md @@ -8,7 +8,7 @@ package `app.opendocument.core`. Mirrors the surface of the python bindings | Path | What | |------|------| -| `CMakeLists.txt` | Builds `libodr_jni` + `odr-core-java.jar`; included from the root build via `ODR_JNI`, or standalone against an installed `odrcore`. | +| `CMakeLists.txt` | Builds `libodr_jni` + `odr-core-java.jar`; included from the root build via `ODR_JNI`, or standalone against an installed `odrcore`. `ODR_JNI_JAR=OFF` builds the native half alone — what `../android` does, and the only build needing no JDK. | | `pom.xml` | Maven distribution of the Java classes only (`app.opendocument:odr-core-java`); published to Maven Central (the `central` profile) and GitHub Packages on release via `.github/workflows/maven.yml`. Keep `--release`/`-Xlint` in sync with `CMAKE_JAVA_COMPILE_FLAGS`. | | `src/` | JNI sources, one `jni_*` unit per public-API area; `odr_jni.hpp` (strings, exceptions, handles) and `jni_convert.hpp` (struct/POJO marshalling) are the helpers. | | `java/app/opendocument/core/` | Java API: enums, POJOs (styles, metas, `HtmlConfig`), and handle-backed wrappers extending `NativeResource`. Also compiled as-is into the AAR (`../android`) — which is kotlin, but this stays java: `add_jar` below has no kotlin toolchain. | diff --git a/jni/CMakeLists.txt b/jni/CMakeLists.txt index e5ced466..7a4474a1 100644 --- a/jni/CMakeLists.txt +++ b/jni/CMakeLists.txt @@ -21,18 +21,18 @@ else () endif () # On android the NDK sysroot ships `jni.h` and the JNI symbols come from the -# runtime, so there is nothing to find or link against. A JDK stays optional -# there rather than unused: the android odrcore package ships -# `odr-core-java.jar` next to `libodr_jni.so` and OpenDocument.droid takes both -# out of it, while `android/` (the AAR) builds the native half alone, with the -# android toolchain compiling `java/` itself. -if (ANDROID) - find_package(Java 11 COMPONENTS Development) -else () - find_package(Java 11 REQUIRED COMPONENTS Development) +# runtime, so there is nothing to find or link against. +if (NOT ANDROID) find_package(JNI REQUIRED) endif () -if (Java_FOUND) + +# Android is no reason to skip the jar — the android odrcore package ships it +# next to `libodr_jni.so` for OpenDocument.droid. Only the AAR build wants the +# native half alone, and asks for it, so a missing JDK fails rather than +# quietly shipping half a package. +option(ODR_JNI_JAR "Build the java half, `odr-core-java.jar`" ON) +if (ODR_JNI_JAR) + find_package(Java 11 REQUIRED COMPONENTS Development) include(UseJava) endif () @@ -56,7 +56,7 @@ endif () install(TARGETS odr_jni LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT jni) -if (NOT Java_FOUND) +if (NOT ODR_JNI_JAR) return() endif () diff --git a/jni/README.md b/jni/README.md index 43129171..0ec0c609 100644 --- a/jni/README.md +++ b/jni/README.md @@ -71,6 +71,12 @@ This produces `build/jni/libodr_jni.dylib` (or `.so`) and `build/jni/odr-core-java.jar`. `jni/CMakeLists.txt` can also be configured standalone against an installed `odrcore` package. +`ODR_JNI_JAR=OFF` builds the native library alone. That is what the AAR build +(`android/build_native.py`) asks for, since it compiles `jni/java/` with the +android toolchain instead, and it is the only build needing no JDK — on android +the headers come from the NDK sysroot. Otherwise a missing JDK fails the +configure step rather than producing a package without the jar in it. + ## Runtime data There is none. The renderer's CSS/JS are part of the library and detection needs