From 3ea887862a9699efded3c30b088dfbb6d76b34e9 Mon Sep 17 00:00:00 2001 From: Jago de Vreede Date: Fri, 1 Nov 2024 14:35:00 +0100 Subject: [PATCH] feat: osx native build --- .github/workflows/assemble-native.yml | 88 +++++++++++++++++++ .github/workflows/early-access.yml | 19 +--- .github/workflows/osx-assemble.yml | 68 -------------- .github/workflows/windows-assemble.yml | 31 ++++--- pom.xml | 2 +- sdkman-api/pom.xml | 2 +- sdkman-bundled-software/pom.xml | 4 +- sdkman-ui/pom.xml | 74 +++++++++------- .../{zip-osx.xml => zip-osx-x86_64.xml} | 0 ...zip-windows.xml => zip-windows-x86_64.xml} | 0 .../META-INF/native-image-mac/jni-config.json | 5 +- .../native-image-mac/reflect-config.json | 2 +- 12 files changed, 160 insertions(+), 135 deletions(-) create mode 100644 .github/workflows/assemble-native.yml delete mode 100644 .github/workflows/osx-assemble.yml rename sdkman-ui/src/main/assembly/{zip-osx.xml => zip-osx-x86_64.xml} (100%) rename sdkman-ui/src/main/assembly/{zip-windows.xml => zip-windows-x86_64.xml} (100%) diff --git a/.github/workflows/assemble-native.yml b/.github/workflows/assemble-native.yml new file mode 100644 index 0000000..014ebe7 --- /dev/null +++ b/.github/workflows/assemble-native.yml @@ -0,0 +1,88 @@ +name: Assemble + +on: + workflow_call: + inputs: + project-version: + required: true + type: string + +env: + gluon_version: 22.1.0.1-Final + +jobs: + assemble: + name: 'Assemble ${{ matrix.os }} ${{ matrix.jdk_arch }}' + strategy: + fail-fast: false + matrix: + os: [ macos-13, windows-latest ] + jdk_arch: [ x86_64, aarch64 ] + exclude: + - os: macos-13 + jdk_arch: aarch64 + - os: windows-latest + jdk_arch: aarch64 + # https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories + runs-on: ${{ matrix.os }} + steps: + - name: "[Windows only] Add msbuild to PATH" + if: startsWith(matrix.os, 'windows') + uses: microsoft/setup-msbuild@v1.0.2 + - name: "[Windows only] Visual Studio shell" + if: startsWith(matrix.os, 'windows') + uses: egor-tensin/vs-shell@v1 + - name: "[macOS only] Setup Xcode" + uses: maxim-lobanov/setup-xcode@v1 + if: startsWith(matrix.os, 'macos') + with: + xcode-version: 'latest-stable' + - name: "Setup Gluon's GraalVM" + uses: gluonhq/setup-graalvm@master + with: + graalvm: ${{ env.gluon_version }} + jdk: 'java17' + arch: ${{ matrix.jdk_arch }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Checkout + uses: actions/checkout@v4 + + - name: Cache local Maven repository + uses: actions/cache@v4 + with: + path: | + ~/.m2/repository + ~/.gluon + ~/.openjfx + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + + - name: Build with Maven + run: ./mvnw -B clean install -DskipTests + - name: Compile native + run: ./mvnw -B gluonfx:compile -f sdkman-ui + - name: Remove windows lib + if: startsWith(matrix.os, 'windows') != true + # TODO remove this for oll other os as well + run: rm sdkman-ui/target/gluonfx/x86_64-darwin/gvm/lib/libjnidispatch.a + - name: Link native + run: ./mvnw -B gluonfx:link -f sdkman-ui + - name: Assemble zip + run: ./mvnw -B org.apache.maven.plugins:maven-assembly-plugin:single@make-zip-${{ matrix.jdk_arch }} -f sdkman-ui + + - name: Upload workspace on failure only + if: failure() + uses: actions/upload-artifact@v4 + with: + retention-days: 1 + name: workspace-files-${{ matrix.os }}-${{ matrix.jdk_arch }} + path: "**/*" + + - name: Upload package + uses: actions/upload-artifact@v4 + with: + retention-days: 1 + name: artifacts-${{ runner.os }}-${{ matrix.jdk_arch }} + path: | + sdkman-ui/target/sdkman-ui-*.zip \ No newline at end of file diff --git a/.github/workflows/early-access.yml b/.github/workflows/early-access.yml index 0c26aa9..1b17362 100644 --- a/.github/workflows/early-access.yml +++ b/.github/workflows/early-access.yml @@ -33,7 +33,6 @@ jobs: uses: actions/cache@v4 with: path: ~/.m2/repository - save-always: true key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - name: Version @@ -43,31 +42,21 @@ jobs: VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) echo "VERSION=$(echo $VERSION)" >> $GITHUB_OUTPUT -# assemble-windows: -# needs: [ precheck ] -# if: endsWith(${{ needs.precheck.outputs.VERSION }}, '-SNAPSHOT REMOVEME') -# #todo switch to main -# uses: jagodevreede/sdkman-ui/.github/workflows/windows-assemble.yml@osx-build -# with: -# project-version: ${{ needs.precheck.outputs.VERSION }} - - assemble-osx: + assemble: needs: [ precheck ] if: endsWith(${{ needs.precheck.outputs.VERSION }}, '-SNAPSHOT') #todo switch to main - uses: jagodevreede/sdkman-ui/.github/workflows/osx-assemble.yml@osx-build + uses: jagodevreede/sdkman-ui/.github/workflows/assemble-native.yml@osx-build with: project-version: ${{ needs.precheck.outputs.VERSION }} - release: - needs: [ precheck, assemble-osx ] + release-early-access: + needs: [ precheck, assemble ] if: endsWith(${{ needs.precheck.outputs.VERSION }}, '-SNAPSHOT') runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Download artifacts uses: actions/download-artifact@v4 diff --git a/.github/workflows/osx-assemble.yml b/.github/workflows/osx-assemble.yml deleted file mode 100644 index 7f9ca60..0000000 --- a/.github/workflows/osx-assemble.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Assemble - -on: - workflow_call: - inputs: - project-version: - required: true - type: string - -env: - gluon_version: 22.1.0.1-Final - -jobs: - assemble: - name: 'Assemble ${{ matrix.os }}' - strategy: - fail-fast: false - matrix: - os: [ macos-13 ] - runs-on: ${{ matrix.os }} - steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: '12.4' - - name: Checkout - uses: actions/checkout@v4 - with: - ref: main - fetch-depth: 0 - - - name: Cache local Maven repository - uses: actions/cache@v4 - with: - path: | - ~/.m2/repository - ~/.gluon - save-always: true - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - - - uses: robinraju/release-downloader@v1.10 - with: - repository: "gluonhq/graal" - tag: "gluon-${{ env.gluon_version }}" - fileName: "*java17-darwin-gluon-*.tar.gz" - - name: Extract JDK - run: | - tar -xf graalvm-svm-java17-darwin-gluon-${{ env.gluon_version }}.tar.gz - mv "graalvm-svm-java17-darwin-gluon-${{ env.gluon_version }}/Contents/Home" jdk - - name: Set env for JAVA_HOME - run: echo "JAVA_HOME=`pwd`/jdk" >> $GITHUB_ENV - - name: Set env for GRAALVM_HOME - run: echo "GRAALVM_HOME=`pwd`/jdk" >> $GITHUB_ENV - - - name: Build with Maven - run: ./mvnw -B clean install -DskipTests - - name: Build native - run: ./mvnw gluonfx:build -f sdkman-ui - - name: Assamble zip - run: | - ./mvnw org.apache.maven.plugins:maven-assembly-plugin:single@assemble-osx -f sdkman-ui - - - name: Upload package - uses: actions/upload-artifact@v4 - with: - retention-days: 1 - name: artifacts-${{ runner.os }}-${{ runner.arch }} - path: | - sdkman-ui/target/sdkman-ui-*.zip \ No newline at end of file diff --git a/.github/workflows/windows-assemble.yml b/.github/workflows/windows-assemble.yml index 4f38ffb..0f9a2ce 100644 --- a/.github/workflows/windows-assemble.yml +++ b/.github/workflows/windows-assemble.yml @@ -27,34 +27,33 @@ jobs: path: | ~/.m2/repository ~/.gluon - save-always: true + ~/.openjfx key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - name: Add msbuild to PATH + if: matrix.os == 'windows-latest' uses: microsoft/setup-msbuild@v1.0.2 - name: Visual Studio shell + if: matrix.os == 'windows-latest' uses: egor-tensin/vs-shell@v1 - - uses: robinraju/release-downloader@v1.10 + - name: Setup Gluon's GraalVM + uses: gluonhq/setup-graalvm@master with: - repository: "gluonhq/graal" - tag: "gluon-${{ env.gluon_version }}" - fileName: "*java17-windows-gluon-*.zip" - - name: Extract JDK - run: | - unzip graalvm-svm-java17-windows-gluon-${{ env.gluon_version }}.zip - Rename-Item -path "graalvm-svm-java17-windows-gluon-${{ env.gluon_version }}" jdk - - name: Set env for JAVA_HOME - run: echo "JAVA_HOME=D:\a\sdkman-ui\sdkman-ui\jdk" | Out-File -FilePath $env:GITHUB_ENV -Append - - name: Set env for GRAALVM_HOME - run: echo "GRAALVM_HOME=D:\a\sdkman-ui\sdkman-ui\jdk" | Out-File -FilePath $env:GITHUB_ENV -Append + graalvm: '22.1.0.1-Final' + jdk: 'java17' + arch: 'x86_64' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Build with Maven run: ./mvnw -B clean install -DskipTests - - name: Build native - run: ./mvnw gluonfx:build -f sdkman-ui + - name: Compile native + run: ./mvnw -B gluonfx:compile -f sdkman-ui + - name: Link native + run: ./mvnw -B gluonfx:link -f sdkman-ui - name: Assamble zip run: | - ./mvnw org.apache.maven.plugins:maven-assembly-plugin:single@assemble-windows -f sdkman-ui + ./mvnw -B org.apache.maven.plugins:maven-assembly-plugin:single@assemble-windows -f sdkman-ui - name: Upload package uses: actions/upload-artifact@v4 diff --git a/pom.xml b/pom.xml index 58cbc9c..522c01b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.github.jagodevreede sdkman-ui-root - 0.1.1 + 0.1.2-SNAPSHOT pom diff --git a/sdkman-api/pom.xml b/sdkman-api/pom.xml index 6a3b88e..741fd47 100644 --- a/sdkman-api/pom.xml +++ b/sdkman-api/pom.xml @@ -6,7 +6,7 @@ io.github.jagodevreede sdkman-ui-root - 0.1.1 + 0.1.2-SNAPSHOT sdkman-api diff --git a/sdkman-bundled-software/pom.xml b/sdkman-bundled-software/pom.xml index 3f65789..3113132 100644 --- a/sdkman-bundled-software/pom.xml +++ b/sdkman-bundled-software/pom.xml @@ -4,13 +4,13 @@ 4.0.0 sdkman-bundled-software - 0.1.1 + 0.1.2-SNAPSHOT jar io.github.jagodevreede sdkman-ui-root - 0.1.1 + 0.1.2-SNAPSHOT sdkman-bundled-software diff --git a/sdkman-ui/pom.xml b/sdkman-ui/pom.xml index b27e584..c7be415 100644 --- a/sdkman-ui/pom.xml +++ b/sdkman-ui/pom.xml @@ -4,13 +4,13 @@ 4.0.0 sdkman-ui - 0.1.1 + 0.1.2-SNAPSHOT jar io.github.jagodevreede sdkman-ui-root - 0.1.1 + 0.1.2-SNAPSHOT sdkman-ui @@ -149,36 +149,8 @@ gluonfx-maven-plugin ${main.class} - ${env.JAVA_HOME} - - org.apache.maven.plugins - maven-assembly-plugin - ${maven-assembly-plugin.version} - - - assemble-windows - - sdkman-ui-windows_x86_64-${project.version} - false - - src/main/assembly/zip-windows.xml - - - - - assemble-osx - - sdkman-ui-osx_x86_64-${project.version} - false - - src/main/assembly/zip-osx.xml - - - - - @@ -193,6 +165,27 @@ native-image-mac + + + + org.apache.maven.plugins + maven-assembly-plugin + ${maven-assembly-plugin.version} + + + make-zip-x86_64 + + sdkman-ui-osx_x86_64-${project.version} + false + + src/main/assembly/zip-osx-x86_64.xml + + + + + + + windows @@ -204,6 +197,27 @@ native-image-windows + + + + org.apache.maven.plugins + maven-assembly-plugin + ${maven-assembly-plugin.version} + + + make-zip-x86_64 + + sdkman-ui-windows_x86_64-${project.version} + false + + src/main/assembly/zip-windows-x86_64.xml + + + + + + + diff --git a/sdkman-ui/src/main/assembly/zip-osx.xml b/sdkman-ui/src/main/assembly/zip-osx-x86_64.xml similarity index 100% rename from sdkman-ui/src/main/assembly/zip-osx.xml rename to sdkman-ui/src/main/assembly/zip-osx-x86_64.xml diff --git a/sdkman-ui/src/main/assembly/zip-windows.xml b/sdkman-ui/src/main/assembly/zip-windows-x86_64.xml similarity index 100% rename from sdkman-ui/src/main/assembly/zip-windows.xml rename to sdkman-ui/src/main/assembly/zip-windows-x86_64.xml diff --git a/sdkman-ui/src/main/resources/META-INF/native-image-mac/jni-config.json b/sdkman-ui/src/main/resources/META-INF/native-image-mac/jni-config.json index bea9dcc..26dc1a6 100644 --- a/sdkman-ui/src/main/resources/META-INF/native-image-mac/jni-config.json +++ b/sdkman-ui/src/main/resources/META-INF/native-image-mac/jni-config.json @@ -56,7 +56,10 @@ }, { "name":"com.sun.glass.ui.Screen", - "methods":[{"name":"","parameterTypes":["long","int","int","int","int","int","int","int","int","int","int","int","int","int","int","int","float","float","float","float"] }] + "methods":[ + {"name":"","parameterTypes":["long","int","int","int","int","int","int","int","int","int","int","int","int","int","int","int","float","float","float","float"] }, + {"name":"notifySettingsChanged","parameterTypes":[] } + ] }, { "name":"com.sun.glass.ui.Size", diff --git a/sdkman-ui/src/main/resources/META-INF/native-image-mac/reflect-config.json b/sdkman-ui/src/main/resources/META-INF/native-image-mac/reflect-config.json index 9b48666..93a4db0 100644 --- a/sdkman-ui/src/main/resources/META-INF/native-image-mac/reflect-config.json +++ b/sdkman-ui/src/main/resources/META-INF/native-image-mac/reflect-config.json @@ -173,7 +173,7 @@ "queryAllDeclaredMethods":true, "methods":[ {"name":"","parameterTypes":[] }, - {"name":"openConfig","parameterTypes":[] }, + {"name":"openConfig","parameterTypes":[] }, {"name":"startUpdate","parameterTypes":[] } ] },