From 4a0454d1f5331719ce00fcab106782b25fef5b2f Mon Sep 17 00:00:00 2001 From: Ed Burns Date: Tue, 25 Aug 2026 15:11:08 -0700 Subject: [PATCH] feat(java): add darwin-arm64 native runtime Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> GUTDODP GUTDODP GUTDOP Remove prompts --- .github/workflows/java-publish-maven.yml | 93 ++++++++++++- .github/workflows/java-publish-snapshot.yml | 105 ++++++++++++++- .github/workflows/java-sdk-tests.yml | 87 ++++++++++++- java/README.md | 17 ++- java/copilot-native/pom.xml | 122 +++++++++++++++++- .../scripts/fetch-native.test.mjs | 2 +- .../scripts/validate-local-publication.mjs | 3 +- .../scripts/validate-native-artifact.mjs | 5 +- .../scripts/validate-native-artifact.test.mjs | 55 ++++++++ .../scripts/validate-native-host.mjs | 9 ++ .../scripts/validate-native-host.test.mjs | 35 +++++ .../adr/adr-007-native-bundling-strategy.md | 6 +- java/sdk/pom.xml | 12 ++ 13 files changed, 527 insertions(+), 24 deletions(-) diff --git a/.github/workflows/java-publish-maven.yml b/.github/workflows/java-publish-maven.yml index 609e7a468..ff5de9e11 100644 --- a/.github/workflows/java-publish-maven.yml +++ b/.github/workflows/java-publish-maven.yml @@ -241,9 +241,68 @@ jobs: if-no-files-found: error retention-days: 1 + build-darwin-classifier: + name: Build Darwin native classifier + needs: prepare-release + runs-on: macos-26 + permissions: + contents: read + defaults: + run: + shell: bash + working-directory: ./java + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ needs.prepare-release.outputs.release_tag }} + fetch-depth: 1 + persist-credentials: false + + - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 + with: + java-version: "25" + distribution: "microsoft" + cache: "maven" + + - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 + with: + node-version: 22 + + - name: Build and validate darwin-arm64 classifier + run: | + set -euo pipefail + SOURCE_COMMIT=$(git rev-parse HEAD) + if [ "$SOURCE_COMMIT" != "${{ needs.prepare-release.outputs.tag_commit }}" ]; then + echo "::error::Checked out $SOURCE_COMMIT instead of the prepared tag commit." + exit 1 + fi + node copilot-native/scripts/validate-native-host.mjs darwin-arm64 + mvn -B -pl copilot-native package -DskipTests + VERSION="${{ needs.prepare-release.outputs.release_version }}" + JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION-darwin-arm64.jar" + PRIMARY_JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION.jar" + test -f "$JAR" + node copilot-native/scripts/validate-native-artifact.mjs \ + classifier darwin-arm64 "$JAR" "$(basename "$JAR")" .. + node copilot-native/scripts/validate-native-artifact.mjs placeholder "$PRIMARY_JAR" + MANIFEST="copilot-native/target/darwin-arm64-$VERSION.sha256" + HASH=$(shasum -a 256 "$JAR" | cut -d ' ' -f 1) + printf '%s %s' "$HASH" "$(basename "$JAR")" > "$MANIFEST" + node copilot-native/scripts/validate-native-artifact.mjs \ + checksum "$JAR" "$MANIFEST" "$(basename "$JAR")" + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: java-native-darwin-arm64-release-${{ github.run_id }}-${{ github.run_attempt }} + path: | + java/copilot-native/target/copilot-sdk-java-runtime-${{ needs.prepare-release.outputs.release_version }}-darwin-arm64.jar + java/copilot-native/target/darwin-arm64-${{ needs.prepare-release.outputs.release_version }}.sha256 + if-no-files-found: error + retention-days: 1 + deploy-maven: name: Deploy Java release to Maven Central - needs: [prepare-release, build-windows-classifier] + needs: [prepare-release, build-windows-classifier, build-darwin-classifier] runs-on: ubuntu-latest permissions: contents: read @@ -283,6 +342,11 @@ jobs: name: java-native-win32-x64-release-${{ github.run_id }}-${{ github.run_attempt }} path: ${{ runner.temp }}/java-native-win32-x64 + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + name: java-native-darwin-arm64-release-${{ github.run_id }}-${{ github.run_attempt }} + path: ${{ runner.temp }}/java-native-darwin-arm64 + - name: Verify immutable source and Windows classifier id: windows-artifact run: | @@ -304,12 +368,34 @@ jobs: echo "windows_jar=$JAR" >> "$GITHUB_OUTPUT" echo "windows_sha=$(cut -d ' ' -f 1 "$MANIFEST")" >> "$GITHUB_OUTPUT" + - name: Verify immutable source and Darwin classifier + id: darwin-artifact + run: | + SOURCE_COMMIT=$(git rev-parse HEAD) + if [ "$SOURCE_COMMIT" != "${{ needs.prepare-release.outputs.tag_commit }}" ]; then + echo "::error::Checked out $SOURCE_COMMIT instead of the prepared tag commit." + exit 1 + fi + VERSION="${{ needs.prepare-release.outputs.release_version }}" + ARTIFACT_DIRECTORY="${{ runner.temp }}/java-native-darwin-arm64" + JAR="$ARTIFACT_DIRECTORY/copilot-sdk-java-runtime-$VERSION-darwin-arm64.jar" + MANIFEST="$ARTIFACT_DIRECTORY/darwin-arm64-$VERSION.sha256" + test -f "$JAR" + test -f "$MANIFEST" + node "$GITHUB_WORKSPACE/java/copilot-native/scripts/validate-native-artifact.mjs" \ + checksum "$JAR" "$MANIFEST" "$(basename "$JAR")" + node "$GITHUB_WORKSPACE/java/copilot-native/scripts/validate-native-artifact.mjs" \ + classifier darwin-arm64 "$JAR" "$(basename "$JAR")" "$GITHUB_WORKSPACE" + echo "darwin_jar=$JAR" >> "$GITHUB_OUTPUT" + echo "darwin_sha=$(cut -d ' ' -f 1 "$MANIFEST")" >> "$GITHUB_OUTPUT" + - name: Build Linux classifier and deploy complete release id: publish-maven run: | VERSION="${{ needs.prepare-release.outputs.release_version }}" mvn -B deploy -DskipTests -Prelease -Dcopilot.native.libc=glibc \ - "-Dcopilot.native.external.win32.classifier.path=${{ steps.windows-artifact.outputs.windows_jar }}" + "-Dcopilot.native.external.win32.classifier.path=${{ steps.windows-artifact.outputs.windows_jar }}" \ + "-Dcopilot.native.external.darwin.classifier.path=${{ steps.darwin-artifact.outputs.darwin_jar }}" LINUX_JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION-linux-x64.jar" test -f "$LINUX_JAR" node copilot-native/scripts/validate-native-artifact.mjs \ @@ -329,6 +415,7 @@ jobs: echo "| --- | --- | --- | --- | --- |" echo "| \`linux-x64\` | \`ubuntu-latest\` | \`$(basename "$LINUX_JAR")\` | \`$LINUX_SHA\` | Published |" echo "| \`win32-x64\` | \`windows-latest\` | \`$(basename "${{ steps.windows-artifact.outputs.windows_jar }}")\` | \`${{ steps.windows-artifact.outputs.windows_sha }}\` | Published |" + echo "| \`darwin-arm64\` | \`macos-26\` | \`$(basename "${{ steps.darwin-artifact.outputs.darwin_jar }}")\` | \`${{ steps.darwin-artifact.outputs.darwin_sha }}\` | Published |" } >> "$GITHUB_STEP_SUMMARY" env: MAVEN_USERNAME: ${{ secrets.JAVA_MAVEN_CENTRAL_USERNAME }} @@ -337,7 +424,7 @@ jobs: rollback-release: name: Roll back failed Java release preparation - needs: [prepare-release, build-windows-classifier, deploy-maven] + needs: [prepare-release, build-windows-classifier, build-darwin-classifier, deploy-maven] if: ${{ failure() && needs.prepare-release.outputs.docs_commit != '' }} runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/java-publish-snapshot.yml b/.github/workflows/java-publish-snapshot.yml index 588c565f5..6974deb1c 100644 --- a/.github/workflows/java-publish-snapshot.yml +++ b/.github/workflows/java-publish-snapshot.yml @@ -40,6 +40,8 @@ jobs: runs-on: windows-latest permissions: contents: read + outputs: + version: ${{ steps.build.outputs.version }} defaults: run: shell: pwsh @@ -93,9 +95,72 @@ jobs: if-no-files-found: error retention-days: 1 + build-darwin-classifier: + name: Build Darwin snapshot classifier + needs: resolve-source + runs-on: macos-26 + permissions: + contents: read + outputs: + version: ${{ steps.build.outputs.version }} + defaults: + run: + shell: bash + working-directory: ./java + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ github.sha }} + fetch-depth: 1 + persist-credentials: false + + - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 + with: + java-version: "25" + distribution: "microsoft" + cache: "maven" + + - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 + with: + node-version: 22 + + - name: Build and validate darwin-arm64 classifier + id: build + run: | + set -euo pipefail + SOURCE_COMMIT=$(git rev-parse HEAD) + if [ "$SOURCE_COMMIT" != "${{ needs.resolve-source.outputs.source_sha }}" ]; then + echo "::error::Checked out $SOURCE_COMMIT instead of the resolved snapshot source." + exit 1 + fi + node copilot-native/scripts/validate-native-host.mjs darwin-arm64 + mvn -B -pl copilot-native package -DskipTests + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION-darwin-arm64.jar" + PRIMARY_JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION.jar" + test -f "$JAR" + node copilot-native/scripts/validate-native-artifact.mjs \ + classifier darwin-arm64 "$JAR" "$(basename "$JAR")" .. + node copilot-native/scripts/validate-native-artifact.mjs placeholder "$PRIMARY_JAR" + MANIFEST="copilot-native/target/darwin-arm64-$VERSION.sha256" + HASH=$(shasum -a 256 "$JAR" | cut -d ' ' -f 1) + printf '%s %s' "$HASH" "$(basename "$JAR")" > "$MANIFEST" + node copilot-native/scripts/validate-native-artifact.mjs \ + checksum "$JAR" "$MANIFEST" "$(basename "$JAR")" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: java-native-darwin-arm64-snapshot-${{ github.run_id }}-${{ github.run_attempt }} + path: | + java/copilot-native/target/copilot-sdk-java-runtime-${{ steps.build.outputs.version }}-darwin-arm64.jar + java/copilot-native/target/darwin-arm64-${{ steps.build.outputs.version }}.sha256 + if-no-files-found: error + retention-days: 1 + deploy-snapshot: name: Publish SNAPSHOT to Maven Central - needs: [resolve-source, build-windows-classifier] + needs: [resolve-source, build-windows-classifier, build-darwin-classifier] runs-on: ubuntu-latest defaults: run: @@ -128,6 +193,11 @@ jobs: name: java-native-win32-x64-snapshot-${{ github.run_id }}-${{ github.run_attempt }} path: ${{ runner.temp }}/java-native-win32-x64 + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + name: java-native-darwin-arm64-snapshot-${{ github.run_id }}-${{ github.run_attempt }} + path: ${{ runner.temp }}/java-native-darwin-arm64 + - name: Verify version, source, and Windows classifier id: windows-artifact run: | @@ -141,6 +211,10 @@ jobs: echo "::error::This workflow only publishes SNAPSHOT versions. Current version: $VERSION" exit 1 fi + if [ "$VERSION" != "${{ needs.build-windows-classifier.outputs.version }}" ]; then + echo "::error::Windows classifier version does not match deploy version." + exit 1 + fi ARTIFACT_DIRECTORY="${{ runner.temp }}/java-native-win32-x64" JAR="$ARTIFACT_DIRECTORY/copilot-sdk-java-runtime-$VERSION-win32-x64.jar" MANIFEST="$ARTIFACT_DIRECTORY/win32-x64-$VERSION.sha256" @@ -154,11 +228,37 @@ jobs: echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "windows_sha=$(cut -d ' ' -f 1 "$MANIFEST")" >> "$GITHUB_OUTPUT" + - name: Verify version, source, and Darwin classifier + id: darwin-artifact + run: | + SOURCE_COMMIT=$(git rev-parse HEAD) + if [ "$SOURCE_COMMIT" != "${{ needs.resolve-source.outputs.source_sha }}" ]; then + echo "::error::Checked out $SOURCE_COMMIT instead of the resolved snapshot source." + exit 1 + fi + VERSION="${{ steps.windows-artifact.outputs.version }}" + if [ "$VERSION" != "${{ needs.build-darwin-classifier.outputs.version }}" ]; then + echo "::error::Darwin classifier version does not match deploy version." + exit 1 + fi + ARTIFACT_DIRECTORY="${{ runner.temp }}/java-native-darwin-arm64" + JAR="$ARTIFACT_DIRECTORY/copilot-sdk-java-runtime-$VERSION-darwin-arm64.jar" + MANIFEST="$ARTIFACT_DIRECTORY/darwin-arm64-$VERSION.sha256" + test -f "$JAR" + test -f "$MANIFEST" + node "$GITHUB_WORKSPACE/java/copilot-native/scripts/validate-native-artifact.mjs" \ + checksum "$JAR" "$MANIFEST" "$(basename "$JAR")" + node "$GITHUB_WORKSPACE/java/copilot-native/scripts/validate-native-artifact.mjs" \ + classifier darwin-arm64 "$JAR" "$(basename "$JAR")" "$GITHUB_WORKSPACE" + echo "darwin_jar=$JAR" >> "$GITHUB_OUTPUT" + echo "darwin_sha=$(cut -d ' ' -f 1 "$MANIFEST")" >> "$GITHUB_OUTPUT" + - name: Build Linux classifier and deploy complete snapshot run: | VERSION="${{ steps.windows-artifact.outputs.version }}" mvn -B deploy -DskipTests -Dcopilot.native.libc=glibc \ - "-Dcopilot.native.external.win32.classifier.path=${{ steps.windows-artifact.outputs.windows_jar }}" + "-Dcopilot.native.external.win32.classifier.path=${{ steps.windows-artifact.outputs.windows_jar }}" \ + "-Dcopilot.native.external.darwin.classifier.path=${{ steps.darwin-artifact.outputs.darwin_jar }}" LINUX_JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION-linux-x64.jar" test -f "$LINUX_JAR" node copilot-native/scripts/validate-native-artifact.mjs \ @@ -176,6 +276,7 @@ jobs: echo "| --- | --- | --- | --- | --- |" echo "| \`linux-x64\` | \`ubuntu-latest\` | \`$(basename "$LINUX_JAR")\` | \`$LINUX_SHA\` | Published |" echo "| \`win32-x64\` | \`windows-latest\` | \`$(basename "${{ steps.windows-artifact.outputs.windows_jar }}")\` | \`${{ steps.windows-artifact.outputs.windows_sha }}\` | Published |" + echo "| \`darwin-arm64\` | \`macos-26\` | \`$(basename "${{ steps.darwin-artifact.outputs.darwin_jar }}")\` | \`${{ steps.darwin-artifact.outputs.darwin_sha }}\` | Published |" } >> "$GITHUB_STEP_SUMMARY" env: MAVEN_USERNAME: ${{ secrets.JAVA_MAVEN_CENTRAL_USERNAME }} diff --git a/.github/workflows/java-sdk-tests.yml b/.github/workflows/java-sdk-tests.yml index 3093e2eab..5f3d7377a 100644 --- a/.github/workflows/java-sdk-tests.yml +++ b/.github/workflows/java-sdk-tests.yml @@ -28,6 +28,8 @@ jobs: classifier: linux-x64 - os: windows-latest classifier: win32-x64 + - os: macos-26 + classifier: darwin-arm64 runs-on: ${{ matrix.os }} defaults: run: @@ -129,10 +131,68 @@ jobs: if-no-files-found: error retention-days: 1 + java-native-publication-darwin: + name: "Java Native Publication Input (darwin-arm64)" + if: github.event.repository.fork == false + runs-on: macos-26 + permissions: + contents: read + outputs: + source_sha: ${{ steps.build.outputs.source_sha }} + version: ${{ steps.build.outputs.version }} + defaults: + run: + shell: bash + working-directory: ./java + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5 + with: + java-version: "25" + distribution: "microsoft" + cache: "maven" + + - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 + with: + node-version: 22 + + - name: Build and validate darwin-arm64 classifier + id: build + run: | + set -euo pipefail + node copilot-native/scripts/validate-native-host.mjs darwin-arm64 + mvn -B -pl copilot-native package -DskipTests + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION-darwin-arm64.jar" + PRIMARY_JAR="copilot-native/target/copilot-sdk-java-runtime-$VERSION.jar" + test -f "$JAR" + node copilot-native/scripts/validate-native-artifact.mjs \ + classifier darwin-arm64 "$JAR" "$(basename "$JAR")" .. + node copilot-native/scripts/validate-native-artifact.mjs placeholder "$PRIMARY_JAR" + MANIFEST="copilot-native/target/darwin-arm64-$VERSION.sha256" + HASH=$(shasum -a 256 "$JAR" | cut -d ' ' -f 1) + printf '%s %s' "$HASH" "$(basename "$JAR")" > "$MANIFEST" + node copilot-native/scripts/validate-native-artifact.mjs \ + checksum "$JAR" "$MANIFEST" "$(basename "$JAR")" + echo "source_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: java-native-publication-darwin-arm64-${{ github.run_id }}-${{ github.run_attempt }} + path: | + java/copilot-native/target/copilot-sdk-java-runtime-${{ steps.build.outputs.version }}-darwin-arm64.jar + java/copilot-native/target/darwin-arm64-${{ steps.build.outputs.version }}.sha256 + if-no-files-found: error + retention-days: 1 + java-native-publication-assembly: name: "Java Native Publication Assembly" if: github.event.repository.fork == false - needs: java-native-publication-windows + needs: [java-native-publication-windows, java-native-publication-darwin] runs-on: ubuntu-latest defaults: run: @@ -157,20 +217,34 @@ jobs: - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: name: java-native-publication-win32-x64-${{ github.run_id }}-${{ github.run_attempt }} - path: ${{ github.workspace }}/java/native-publication-input + path: ${{ github.workspace }}/java/native-publication-input/windows - - name: Verify Windows input and deploy the complete local release + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + name: java-native-publication-darwin-arm64-${{ github.run_id }}-${{ github.run_attempt }} + path: ${{ github.workspace }}/java/native-publication-input/darwin + + - name: Verify native inputs and deploy the complete local release run: | set -euo pipefail test "$(git rev-parse HEAD)" = "${{ needs.java-native-publication-windows.outputs.source_sha }}" + test "$(git rev-parse HEAD)" = "${{ needs.java-native-publication-darwin.outputs.source_sha }}" VERSION="${{ needs.java-native-publication-windows.outputs.version }}" - INPUT_DIRECTORY="$GITHUB_WORKSPACE/java/native-publication-input" - WINDOWS_JAR="$INPUT_DIRECTORY/copilot-sdk-java-runtime-$VERSION-win32-x64.jar" - WINDOWS_MANIFEST="$INPUT_DIRECTORY/win32-x64-$VERSION.sha256" + test "$VERSION" = "${{ needs.java-native-publication-darwin.outputs.version }}" + WINDOWS_DIRECTORY="$GITHUB_WORKSPACE/java/native-publication-input/windows" + DARWIN_DIRECTORY="$GITHUB_WORKSPACE/java/native-publication-input/darwin" + WINDOWS_JAR="$WINDOWS_DIRECTORY/copilot-sdk-java-runtime-$VERSION-win32-x64.jar" + WINDOWS_MANIFEST="$WINDOWS_DIRECTORY/win32-x64-$VERSION.sha256" + DARWIN_JAR="$DARWIN_DIRECTORY/copilot-sdk-java-runtime-$VERSION-darwin-arm64.jar" + DARWIN_MANIFEST="$DARWIN_DIRECTORY/darwin-arm64-$VERSION.sha256" node copilot-native/scripts/validate-native-artifact.mjs \ checksum "$WINDOWS_JAR" "$WINDOWS_MANIFEST" "$(basename "$WINDOWS_JAR")" node copilot-native/scripts/validate-native-artifact.mjs \ classifier win32-x64 "$WINDOWS_JAR" "$(basename "$WINDOWS_JAR")" .. + node copilot-native/scripts/validate-native-artifact.mjs \ + checksum "$DARWIN_JAR" "$DARWIN_MANIFEST" "$(basename "$DARWIN_JAR")" + node copilot-native/scripts/validate-native-artifact.mjs \ + classifier darwin-arm64 "$DARWIN_JAR" "$(basename "$DARWIN_JAR")" .. export GNUPGHOME="$GITHUB_WORKSPACE/java/copilot-native/target/local-publication-gpg" rm -rf "$GNUPGHOME" mkdir -p "$GNUPGHOME" @@ -183,6 +257,7 @@ jobs: -Dcopilot.native.libc=glibc \ -Dcopilot.native.test.local.publication=true \ "-Dcopilot.native.external.win32.classifier.path=$WINDOWS_JAR" \ + "-Dcopilot.native.external.darwin.classifier.path=$DARWIN_JAR" \ "-Dmaven.repo.local=$LOCAL_REPOSITORY" node copilot-native/scripts/validate-local-publication.mjs \ "$LOCAL_REPOSITORY" copilot-sdk-java-runtime "$VERSION" .. --signatures diff --git a/java/README.md b/java/README.md index 71126045a..820377653 100644 --- a/java/README.md +++ b/java/README.md @@ -72,7 +72,7 @@ implementation 'com.github:copilot-sdk-java:1.0.13-preview.0-SNAPSHOT' ## In-process mode (experimental) -The SDK supports running the Copilot runtime **in-process** as a native library instead of spawning a separate CLI process. This eliminates process management overhead and simplifies deployment. In-process mode is currently experimental and supported on **linux-x64** (glibc) and **win32-x64**. +The SDK supports running the Copilot runtime **in-process** as a native library instead of spawning a separate CLI process. This eliminates process management overhead and simplifies deployment. In-process mode is currently experimental and supported on **linux-x64** (glibc), **win32-x64**, and **darwin-arm64**. Because in-process mode is experimental, see the [Using experimental APIs](#using-experimental-apis) section for how to opt in. @@ -95,7 +95,7 @@ Add both the SDK and the platform-specific native runtime to your project: ${copilot.version} linux-x64 - + net.java.dev.jna @@ -492,7 +492,7 @@ mvn jacoco:prepare-agent@wire-up-coverage-instrumentation antrun:run@print-test- Run native-runtime Maven commands from the `java` directory. Native packaging requires Node.js and npm in addition to JDK 25 and Maven because `copilot-native/scripts/fetch-native.mjs` retrieves the pinned npm runtime package. -On a native Linux x64 glibc host, Maven activates the `native-linux-x64` profile when `copilot.native.libc=glibc` is set. On Windows x64, Maven activates `native-win32-x64` automatically. The matching profile validates the host, runs the native script tests, fetches the pinned `@github/copilot-` package during `generate-resources`, packages the classifier JAR during `package`, and verifies its native contents. Ensure npm can authenticate to the package registry before running the build. +On a native Linux x64 glibc host, Maven activates the `native-linux-x64` profile when `copilot.native.libc=glibc` is set. On Windows x64, Maven activates `native-win32-x64` automatically. On Apple Silicon macOS, Maven activates `native-darwin-arm64` automatically. The matching profile validates the host, runs the native script tests, fetches the pinned `@github/copilot-` package during `generate-resources`, packages the classifier JAR during `package`, and verifies its native contents. Ensure npm can authenticate to the package registry before running the build. Before opting in, validate that Node.js reports glibc for the build host: @@ -513,7 +513,14 @@ On Windows PowerShell, initialize Java and run the same profile: mvn -Pinprocess clean verify ``` -On macOS, Linux ARM64, Linux x64 musl, and other unsupported hosts, do not set `copilot.native.libc=glibc`. A normal build produces only the OS-neutral primary, sources, and Javadoc JARs; it does not run native script tests, download or stage native files, or produce a platform classifier JAR. +The same command validates in-process mode on Apple Silicon macOS: + +```bash +node copilot-native/scripts/validate-native-host.mjs darwin-arm64 +mvn -Pinprocess clean verify +``` + +On Intel macOS, Linux ARM64, Linux x64 musl, and other unsupported hosts, do not set `copilot.native.libc=glibc`. A normal build produces only the OS-neutral primary, sources, and Javadoc JARs; it does not run native script tests, download or stage native files, or produce a platform classifier JAR. To build only the OS-neutral artifacts on any host, or override the glibc opt-in, disable native download and packaging: @@ -531,7 +538,7 @@ mvn clean verify -Dcopilot.native.libc=glibc mvn clean package -pl copilot-native -DskipTests -Dcopilot.native.libc=glibc -Dcopilot.native.skip.download=true ``` -On Linux x64, the classifier JAR contains `native/linux-x64/runtime.node`, `native/linux-x64/platform.properties`, and `native/linux-x64/copilot`. On Windows x64, it contains `native/win32-x64/runtime.node`, `native/win32-x64/platform.properties`, and `native/win32-x64/copilot.exe`. The placeholder JAR remains OS-neutral and contains no native binaries. Unsupported hosts retain the placeholder-only behavior. +On Linux x64, the classifier JAR contains `native/linux-x64/runtime.node`, `native/linux-x64/platform.properties`, and `native/linux-x64/copilot`. On Windows x64, it contains `native/win32-x64/runtime.node`, `native/win32-x64/platform.properties`, and `native/win32-x64/copilot.exe`. On Apple Silicon macOS, it contains `native/darwin-arm64/runtime.node`, `native/darwin-arm64/platform.properties`, and `native/darwin-arm64/copilot`. The placeholder JAR remains OS-neutral and contains no native binaries. Unsupported hosts retain the placeholder-only behavior. ## License diff --git a/java/copilot-native/pom.xml b/java/copilot-native/pom.xml index 15f52ea85..145c4d587 100644 --- a/java/copilot-native/pom.xml +++ b/java/copilot-native/pom.xml @@ -235,8 +235,9 @@ inprocess @@ -405,6 +406,61 @@ + + native-darwin-arm64 + + + mac + aarch64 + + + + darwin-arm64 + copilot + + + + + org.codehaus.mojo + exec-maven-plugin + + + validate-native-host + validate + + + fetch-native + generate-resources + + + test-fetch-native + test + + + + + org.apache.maven.plugins + maven-jar-plugin + + + jar-native + package + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + verify-native-jars + package + + + + + + + + attach-external-darwin-classifier + + + copilot.native.external.darwin.classifier.path + + + + + + org.codehaus.mojo + exec-maven-plugin + + + validate-external-darwin-classifier + validate + + exec + + + node + + ${project.basedir}/scripts/validate-native-artifact.mjs + classifier + darwin-arm64 + ${copilot.native.external.darwin.classifier.path} + ${project.build.finalName}-darwin-arm64.jar + ${copilot.sdk.root} + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-external-darwin-classifier + package + + attach-artifact + + + + + ${copilot.native.external.darwin.classifier.path} + jar + darwin-arm64 + + + + + + + + +