diff --git a/.github/consumers/check.sh b/.github/consumers/check.sh new file mode 100644 index 000000000..b875fcd16 --- /dev/null +++ b/.github/consumers/check.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Run from the repository root after packaging the Java jars and unpacking natives. +set -euo pipefail +version=${1:?Usage: check.sh PROJECT_VERSION} +output="$PWD/target/consumers" +mkdir -p "$output/classpath" "$output/modulepath" + +jars=("$PWD/webrtc/target/webrtc-java-$version.jar" + "$PWD/webrtc-media/target/webrtc-java-media-$version.jar" + "$PWD/webrtc-javafx/target/webrtc-java-javafx-$version.jar") +# These checks run on Linux. Use the real JavaFX modules, not its empty +# platform-neutral jars (which would introduce duplicate automatic modules). +for component in base graphics; do + matches=(webrtc-javafx/target/dependency/javafx-"$component"-*-linux.jar) + if [[ ${#matches[@]} != 1 || ! -f ${matches[0]} ]]; then + echo "Expected one Linux JavaFX $component jar" >&2 + exit 1 + fi + jars+=("$PWD/${matches[0]}") +done +for jar in "${jars[@]}"; do test -f "$jar"; done +libraries=$(IFS=:; echo "${jars[*]}") +natives="$PWD/webrtc-media/target/natives" +source=.github/consumers/src/consumer/Smoke.java + +javac --release 11 -cp "$libraries" -d "$output/classpath" "$source" +java -cp "$output/classpath:$libraries:$natives" consumer.Smoke + +javac --release 11 --module-path "$libraries" -d "$output/modulepath" \ + .github/consumers/modulepath/module-info.java "$source" +java --module-path "$output/modulepath:$libraries" -cp "$natives" \ + --module webrtc.consumer/consumer.Smoke diff --git a/.github/consumers/modulepath/module-info.java b/.github/consumers/modulepath/module-info.java new file mode 100644 index 000000000..bb7c967ec --- /dev/null +++ b/.github/consumers/modulepath/module-info.java @@ -0,0 +1,5 @@ +module webrtc.consumer { + requires webrtc.java; + requires webrtc.java.media; + requires webrtc.java.javafx; +} diff --git a/.github/consumers/src/consumer/Smoke.java b/.github/consumers/src/consumer/Smoke.java new file mode 100644 index 000000000..4f647eeeb --- /dev/null +++ b/.github/consumers/src/consumer/Smoke.java @@ -0,0 +1,40 @@ +package consumer; + +import dev.onvoid.webrtc.PeerConnectionFactory; +import dev.onvoid.webrtc.client.WebRtc; +import dev.onvoid.webrtc.client.javafx.VideoView; +import dev.onvoid.webrtc.media.audio.AudioDeviceModule; +import dev.onvoid.webrtc.media.audio.AudioLayer; +import dev.onvoid.webrtc.media.player.FFmpeg; +import dev.onvoid.webrtc.media.player.MediaPlayer; +import dev.onvoid.webrtc.media.recorder.MediaRecorderState; + +/** A real consumer: compiled and run without test dependencies or add-exports. */ +public final class Smoke { + public static void main(String[] args) { + // Resolve all three public modules, including JavaFX, without opening a UI. + System.out.println(MediaPlayer.class.getName()); + System.out.println(VideoView.class.getName()); + System.out.println(MediaRecorderState.values().length); + WebRtc.builder(); + + // Exercise JNI on the minimum supported runtime without audio hardware. + AudioDeviceModule audio = new AudioDeviceModule(AudioLayer.kDummyAudio); + try { + PeerConnectionFactory factory = new PeerConnectionFactory(audio); + try { + String version = FFmpeg.version(); + if (version == null || version.isEmpty()) { + throw new AssertionError("FFmpeg did not report its version"); + } + System.out.println("FFmpeg " + version); + } + finally { + factory.dispose(); + } + } + finally { + audio.dispose(); + } + } +} diff --git a/.github/workflows/platforms.yml b/.github/workflows/platforms.yml index 259cb3ddd..290b8b464 100644 --- a/.github/workflows/platforms.yml +++ b/.github/workflows/platforms.yml @@ -157,3 +157,42 @@ jobs: java-distribution: ${{ matrix.platform.java-distribution }} java-architecture: ${{ matrix.platform.java-architecture }} version: ${{ inputs.version }} + + # JUnit 6 needs Java 17. Compile and run independent consumers on Java 11 + # instead, using the same Linux natives the suite has just tested. + - name: Set up minimum runtime JDK 11 + if: matrix.platform.name == 'linux_x86-64' + uses: actions/setup-java@v6 + with: + java-version: '11' + distribution: temurin + + - name: Check API compatibility and package Java artifacts + if: matrix.platform.name == 'linux_x86-64' + run: | + rm -rf webrtc/target/classes webrtc-media/target/classes webrtc-javafx/target/classes + mvn -B -pl webrtc,webrtc-media,webrtc-javafx -am verify \ + -Papi-compatibility -DskipNativeBuild -Dmaven.test.skip=true \ + -Dmaven.antrun.skip=true + + - name: Resolve JavaFX for consumer compilation + if: matrix.platform.name == 'linux_x86-64' + run: >- + mvn -B -pl webrtc-javafx -am + org.apache.maven.plugins:maven-dependency-plugin:3.7.0:copy-dependencies + -DincludeGroupIds=org.openjfx -DincludeScope=compile + + - name: Compile and run classpath and modulepath consumers on Java 11 + if: matrix.platform.name == 'linux_x86-64' + shell: bash + run: | + VERSION=$(sed -n 's|.*\([^<]*\).*|\1|p' pom.xml | head -n 1) + bash .github/consumers/check.sh "$VERSION" + + - name: Upload API compatibility reports + if: failure() && matrix.platform.name == 'linux_x86-64' + uses: actions/upload-artifact@v7 + with: + name: api-compatibility-reports + path: '**/target/japicmp/' + if-no-files-found: ignore diff --git a/docs/guide/build.md b/docs/guide/build.md index 48382c814..709cf3066 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -95,6 +95,36 @@ mvn install On the first run, the WebRTC source tree is loaded into the `//webrtc` directory, and FFmpeg and dav1d are built into `//ffmpeg`. This takes a long time. Later builds reuse both as long as their configuration is unchanged. To build the native libraries without running the tests, use `mvn package -DskipTests`, as CI does. +## Java artifact reproducibility and compatibility + +Java archives use the version-controlled `project.build.outputTimestamp` in the +parent pom instead of the current build time. Keep the JDK and Maven versions +fixed when comparing hashes. A source archive needs no Git metadata to reproduce +this timestamp; it can also be overridden with +`-Dproject.build.outputTimestamp=`. Native binaries require +additional measures before their builds can be considered reproducible. + +After building or installing the host native artifact, compare the public core +and media APIs against the pinned previous release: + +```shell +mvn -pl webrtc,webrtc-media -am verify -Papi-compatibility -DskipNativeBuild +``` + +The baseline is `api.compatibility.version` in the parent pom. Advance it after a +release. The two member-level exceptions record breaks already made since +0.20.0 (#395 and #421); remove them when advancing that baseline. Internal +packages are excluded. Reports are written to each module's `target/japicmp/`. +JavaFX is new since that release and has no published baseline yet; enable the +same profile there once its first release is available. + +CI additionally packages all three Java libraries on JDK 11 with tests skipped +(JUnit 6 itself requires 17), then compiles and runs the consumers under +`.github/consumers/` separately on the classpath and modulepath. They resolve the +public client, media and JavaFX APIs and exercise native factory creation and +FFmpeg loading without hardware or a display. They use the Linux native jars +from the platform build, without `--add-exports` or `--add-opens`. + ## Build Parameters | Parameter | Description | Default Value | diff --git a/pom.xml b/pom.xml index c628056c7..f2a284b13 100644 --- a/pom.xml +++ b/pom.xml @@ -44,9 +44,10 @@ - ${maven.build.timestamp} + + 2026-10-31T23:43:19Z + 0.20.0 UTF-8 - yyyy-MM-dd HH:mm @@ -61,6 +62,47 @@ + + com.github.siom79.japicmp + japicmp-maven-plugin + 0.26.3 + + + + ${project.groupId} + ${project.artifactId} + ${api.compatibility.version} + + + + + ${project.build.directory}/${project.build.finalName}.jar + + + + protected + true + true + true + + + dev.onvoid.webrtc.logging.Logging#logThreads(boolean) + dev.onvoid.webrtc.media.audio.AudioConverter#convertInternal(byte[],int,byte[],int) + dev.onvoid.webrtc.internal + dev.onvoid.webrtc.client.internal + + + + + + api-compatibility + verify + cmp + + + org.apache.maven.plugins maven-antrun-plugin @@ -145,7 +187,6 @@ true ${project.version} - ${maven.build.timestamp} true diff --git a/webrtc-media/pom.xml b/webrtc-media/pom.xml index cd9f8983f..654e5aced 100644 --- a/webrtc-media/pom.xml +++ b/webrtc-media/pom.xml @@ -187,6 +187,18 @@ + + + api-compatibility + + + + com.github.siom79.japicmp + japicmp-maven-plugin + + + + diff --git a/webrtc/pom.xml b/webrtc/pom.xml index 5c6de9328..4a37d6b9a 100644 --- a/webrtc/pom.xml +++ b/webrtc/pom.xml @@ -35,6 +35,18 @@ + + + api-compatibility + + + + com.github.siom79.japicmp + japicmp-maven-plugin + + + +