diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 000000000..2a7fea0f6 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,55 @@ +name: maven + +on: + push: + release: + types: [published] + workflow_dispatch: + inputs: + version: + description: version to publish (e.g. 5.5.0-test1) + required: true + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + packages: write + +jobs: + build: + runs-on: ubuntu-24.04 + steps: + - name: checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + + - name: setup java + uses: actions/setup-java@f4f1212c880fdec8162ea9a6493f4495191887b4 # v5 + with: + distribution: temurin + java-version: 21 + cache: maven + server-id: github + + - name: get version + if: github.event_name != 'push' + env: + INPUT_VERSION: ${{ inputs.version }} + run: | + if [ "${{ github.event_name }}" = release ]; then + echo "REVISION=${GITHUB_REF_NAME:1}" >> $GITHUB_ENV + else + echo "REVISION=${INPUT_VERSION}" >> $GITHUB_ENV + fi + + - name: build + if: github.event_name == 'push' + run: mvn --batch-mode --no-transfer-progress --file jni/pom.xml verify + + - name: publish + if: github.event_name != 'push' + run: mvn --batch-mode --no-transfer-progress --file jni/pom.xml deploy -Drevision="${REVISION}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index c61b656e1..662417869 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,8 @@ ## OpenDocument.core build/ cmake-build-*/ +jni/target/ +jni/.flattened-pom.xml .clangd CMakeUserPresets.json # machine-specific Conan cache paths, generated by scripts/gen-vscode-env.py diff --git a/jni/AGENTS.md b/jni/AGENTS.md index 0399b557d..182be13a2 100644 --- a/jni/AGENTS.md +++ b/jni/AGENTS.md @@ -9,6 +9,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`. | +| `pom.xml` | Maven distribution of the Java classes only (`app.opendocument:odr-core-java`); published to 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`. | | `tests/` | JUnit 5 suite, run via ctest (`odr_jni_junit`); inputs are generated inline (tmp files, zip-built minimal ODT) — no fixture files. | diff --git a/jni/README.md b/jni/README.md index a8571f4bc..0a93fc773 100644 --- a/jni/README.md +++ b/jni/README.md @@ -22,6 +22,36 @@ The native library is loaded from `java.library.path` as `odr_jni` (`libodr_jni.so`/`libodr_jni.dylib`); the system property `app.opendocument.core.library` overrides it with an absolute path. +## Maven distribution + +The Java classes are published as `app.opendocument:odr-core-java` to +[GitHub Packages](https://github.com/orgs/opendocument-app/packages?repo_name=OpenDocument.core) +on release (`.github/workflows/maven.yml`, built from `pom.xml`). The artifact +contains **only the Java API** — consumers build the native `odr_jni` library +themselves for their target platform (see below) and provide it at runtime. + +```gradle +repositories { + maven { + url = uri("https://maven.pkg.github.com/opendocument-app/OpenDocument.core") + credentials { + username = providers.gradleProperty("gpr.user").orNull ?: System.getenv("GITHUB_ACTOR") + password = providers.gradleProperty("gpr.key").orNull ?: System.getenv("GITHUB_TOKEN") + } + } +} + +dependencies { + implementation "app.opendocument:odr-core-java:" +} +``` + +Note: GitHub Packages requires authentication (a token with `read:packages`) +even for public packages. + +Local build: `mvn --file jni/pom.xml verify` (produces the jar plus sources +and javadoc jars in `jni/target/`). + ## Building The bindings are part of the main CMake build, toggled by `ODR_JNI` (requires diff --git a/jni/pom.xml b/jni/pom.xml new file mode 100644 index 000000000..4bbdad46c --- /dev/null +++ b/jni/pom.xml @@ -0,0 +1,121 @@ + + + + 4.0.0 + + app.opendocument + odr-core-java + ${revision} + jar + + odr-core-java + Java bindings for OpenDocument.core — decode office documents (ODF, OOXML, legacy MS binary, PDF, CSV, ...) and render them to HTML + https://github.com/opendocument-app/OpenDocument.core + + + + MPL-2.0 + https://www.mozilla.org/en-US/MPL/2.0/ + + + + + scm:git:https://github.com/opendocument-app/OpenDocument.core.git + scm:git:git@github.com:opendocument-app/OpenDocument.core.git + https://github.com/opendocument-app/OpenDocument.core + + + + 0.0.0-SNAPSHOT + UTF-8 + + 17 + + + + java + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + + -Xlint:all + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.11.2 + + all,-missing + + + + attach-javadocs + + jar + + + + + + + + org.codehaus.mojo + flatten-maven-plugin + 1.6.0 + + ossrh + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + + + + + + + + github + GitHub Packages + https://maven.pkg.github.com/opendocument-app/OpenDocument.core + + +