From aa0fa843b8d7729befbb9068b323fc13deb446a9 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Wed, 10 Apr 2024 23:50:12 +0200 Subject: [PATCH] Include JavaFX jmods (and remove forceMerge javaFX) (#11170) * Switch from temurin to adoptium * Try zulu * Upload to artifact store * Set vendor to zulu (AKA AZUL) * Fix rsync step condition * Replace "Setup" by "Set up" * Reorder - and try to download jmods * Try to fix extract * Try to fix remove * Fix quotes * Fix build.gradle * Maybe JavaFX is now modular? * Try to find where this library comes from * Purge old JavaFX versions * Add missing condition * Some more debug * Fix debug * Disable caching * Try other requires (instead of forcing merge) * Try to shrink build cache * Revert "Try other requires (instead of forcing merge)" This reverts commit 8e6c7d59a61a3b81b6f5db1fdf4f82a44466df1e. * Revert "Maybe JavaFX is now modular?" This reverts commit 79dc5b374ddc822b9c84ca09e1aa3e4b9db149aa. * Make name more clear * Switch to Adoptium * Some debug * Switch back to liberica * Remove cache cleanup (maybe this causes issues?) * More debug * Let's see where the JavaFX20 comes from * Fix find output * Exclude other JavaFX versions from dependencies * Reenable cache (but with cleanup) * Revert "Reenable cache (but with cleanup)" This reverts commit 40fb2521be7301ee3b04b0c02397377c7450d99e. * More debug * Remove find and re-enable cache * Revert changes for arm64 workflow * Revert changes at other workflows * Use BELLSOFT instead of AZUL * Exclude javafx globally * Revert globally exclude jfx * Try remove javafx from gradle * Revert "Try remove javafx from gradle" This reverts commit fcd35b5320a64c774f8c83a324e38445601d3c33. * Remove forceMerge of JavaFX * Switch back to default JDK * Add requires statements * Revert "Switch back to default JDK" This reverts commit f2d18cd62c99b21353567259c762e3de645a455d. * Add comment on JDK * Use Amazon's JDK * Add jmods dir to .gitignore * Remove "|| true" in pipeline (for gradle) * Add "addExtraDependencies("javafx")" * Tabs -> Spaces * Switch back to default JDK * Revert liberica -> temurin --------- Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> --- .github/workflows/deployment-jdk-ea.yml | 124 ++++++++++++++---------- .gitignore | 1 + build.gradle | 21 +++- 3 files changed, 93 insertions(+), 53 deletions(-) diff --git a/.github/workflows/deployment-jdk-ea.yml b/.github/workflows/deployment-jdk-ea.yml index 6f72a96b42e..48b760cdcfe 100644 --- a/.github/workflows/deployment-jdk-ea.yml +++ b/.github/workflows/deployment-jdk-ea.yml @@ -64,8 +64,10 @@ jobs: run: | if [ "$BUILDJABREFPRIVATEKEY" == "" ]; then echo "secretspresent=NO" >> $GITHUB_OUTPUT + echo "❌ Secret BUILDJABREFPRIVATEKEY not present" else echo "secretspresent=YES" >> $GITHUB_OUTPUT + echo "✔️ Secret BUILDJABREFPRIVATEKEY present" fi env: BUILDJABREFPRIVATEKEY: ${{ secrets.buildJabRefPrivateKey }} @@ -75,6 +77,43 @@ jobs: fetch-depth: 0 submodules: 'true' show-progress: 'false' + - name: Install pigz and cache (linux) + if: (matrix.os == 'ubuntu-latest') || (matrix.os == 'buildjet-4vcpu-ubuntu-2204-arm') + uses: awalsh128/cache-apt-pkgs-action@master + with: + packages: pigz + version: 1.0 + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v1.1.1 + with: + versionSpec: "5.x" + - name: Run GitVersion + id: gitversion + uses: gittools/actions/gitversion/execute@v1.1.1 + + # JDK + - name: 'Set up JDK ${{ matrix.jdk }}' + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.jdk }} + distribution: 'liberica' + - name: 'Set JDK${{ matrix.jdk }} env var' + shell: bash + run: echo "JDK${{ matrix.jdk }}=$JAVA_HOME" >> $GITHUB_ENV + - name: 'Set JDK${{ matrix.jdk }} in toolchain (linux, Windows)' + if: (matrix.os != 'macos-latest') + shell: bash + run: | + sed -i 's/JavaLanguageVersion.of(.*)/JavaLanguageVersion.of(${{ matrix.jdk }})/' build.gradle + sed -i 's/JavaVersion.VERSION_(.*)/JavaVersion.VERSION_(${{ matrix.jdk }})/' build.gradle + - name: 'Set JDK${{ matrix.jdk }} in toolchain (macOS)' + if: (matrix.os == 'macos-latest') + shell: bash + run: | + sed -i'.bak' 's/JavaLanguageVersion.of(.*)/JavaLanguageVersion.of(${{ matrix.jdk }})/' build.gradle + sed -i'.bak' 's/JavaVersion.VERSION_(.*)/JavaVersion.VERSION_(${{ matrix.jdk }})/' build.gradle + + # JavaFX - name: Download and extract JavaFX ${{ matrix.javafx }} if: (matrix.os != 'buildjet-4vcpu-ubuntu-2204-arm') shell: bash @@ -111,46 +150,30 @@ jobs: ;; esac echo "OS set to $OS" - URL=$(grep -o "https://download.java.net/java/.*/javafx.*${OS}-x64_bin-sdk.${EXT}" javafx.html | head -n 1) - echo "Downloading $URL..." - curl -OJ --no-progress-meter $URL + + URL_SDK=$(grep -o "https://download.java.net/java/.*/javafx.*${OS}-x64_bin-sdk.${EXT}" javafx.html | head -n 1) + echo "Downloading $URL_SDK..." + curl -OJ --no-progress-meter $URL_SDK $EXTRACT - - name: Install pigz and cache (linux) - if: (matrix.os == 'ubuntu-latest') || (matrix.os == 'buildjet-4vcpu-ubuntu-2204-arm') - uses: awalsh128/cache-apt-pkgs-action@master - with: - packages: pigz - version: 1.0 - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v1.1.1 - with: - versionSpec: "5.x" - - name: Run GitVersion - id: gitversion - uses: gittools/actions/gitversion/execute@v1.1.1 - - name: 'Set up JDK ${{ matrix.jdk }}' - uses: actions/setup-java@v4 - with: - java-version: ${{ matrix.jdk }} - distribution: 'temurin' - - name: 'Set JDK${{ matrix.jdk }} env var' - shell: bash - run: echo "JDK${{ matrix.jdk }}=$JAVA_HOME" >> $GITHUB_ENV - - name: 'Set JDK${{ matrix.jdk }} in toolchain (linux, Windows)' - if: (matrix.os != 'macos-latest') - shell: bash - run: | - sed -i 's/JavaLanguageVersion.of(.*)/JavaLanguageVersion.of(${{ matrix.jdk }})/' build.gradle - sed -i 's/JavaVersion.VERSION_(.*)/JavaVersion.VERSION_(${{ matrix.jdk }})/' build.gradle - - name: 'Set JDK${{ matrix.jdk }} in toolchain (macOS)' - if: (matrix.os == 'macos-latest') - shell: bash - run: | - sed -i'.bak' 's/JavaLanguageVersion.of(.*)/JavaLanguageVersion.of(${{ matrix.jdk }})/' build.gradle - sed -i'.bak' 's/JavaVersion.VERSION_(.*)/JavaVersion.VERSION_(${{ matrix.jdk }})/' build.gradle + rm *.$EXT + + URL_JMODS=$(grep -o "https://download.java.net/java/.*/javafx.*${OS}-x64_bin-jmods.${EXT}" javafx.html | head -n 1) + echo "Downloading $URL_JMODS..." + curl -OJ --no-progress-meter $URL_JMODS + $EXTRACT + rm *.$EXT - name: 'Set JavaFX ${{ matrix.javafx }} (linux, Windows)' if: (matrix.os != 'macos-latest') && (matrix.os != 'buildjet-4vcpu-ubuntu-2204-arm') - run: sed -i '/javafx {/{n;s#version = ".*"#sdk = "javafx/javafx-sdk-${{ matrix.javafx }}"#}' build.gradle + run: | + sed -i '/javafx {/{n;s#version = ".*"#sdk = "javafx/javafx-sdk-${{ matrix.javafx }}"#}' build.gradle + sed -i "s#jlink {#jlink { addExtraModulePath 'javafx/javafx-jmods-${{ matrix.javafx }}'#" build.gradle + cat build.gradle + - name: 'Set JavaFX ${{ matrix.javafx }} (macOS)' + if: (matrix.os == 'macos-latest') && (matrix.os != 'buildjet-4vcpu-ubuntu-2204-arm') + run: | + sed -i '.bak' -e '/javafx {/{n' -e 's#version = ".*"#sdk = "javafx/javafx-sdk-${{ matrix.javafx }}"#;}' build.gradle + sed -i '.bak' -e "s#jlink {#jlink { addExtraModulePath 'javafx/javafx-jmods-${{ matrix.javafx }}'#" build.gradle + cat build.gradle - name: 'Set JavaFX ${{ matrix.javafx }} (linux-arm)' if: (matrix.os == 'buildjet-4vcpu-ubuntu-2204-arm') # No JavaFX EA build for ARM at https://jdk.java.net/javafx23/, therefore using Maven Central artifact @@ -160,28 +183,27 @@ jobs: JAVAFX=$(jq -r '.[-1].version' /tmp/versions-latest.json) echo "Using JavaFX ${JAVAFX}" sed -i "/javafx {/{n;s#version = \".*\"#version = \"${JAVAFX}\"#}" build.gradle && cat build.gradle - - name: 'Set JavaFX ${{ matrix.javafx }} (macOS)' - if: (matrix.os == 'macos-latest') && (matrix.os != 'buildjet-4vcpu-ubuntu-2204-arm') - run: sed -i '.bak' -e '/javafx {/{n' -e 's#version = ".*"#sdk = "javafx/javafx-sdk-${{ matrix.javafx }}"#;}' build.gradle - - name: Setup JDK + + # Gradle + - name: Set up JDK uses: actions/setup-java@v4 with: java-version: 21 distribution: 'temurin' - - name: Setup Gradle + - name: Set up Gradle uses: gradle/actions/setup-gradle@v3 - name: Prepare merged jars and modules dir # prepareModulesDir is executing a build, which should run through even if no upload to builds.jabref.org is made if: (steps.checksecrets.outputs.secretspresent == 'NO') run: ./gradlew -i -PprojVersion="${{ steps.gitversion.outputs.AssemblySemVer }}" -PprojVersionInfo="${{ steps.gitversion.outputs.InformationalVersion }}" prepareModulesDir - - name: Setup macOS key chain + - name: Set up macOS key chain if: (matrix.os == 'macos-latest') && (steps.checksecrets.outputs.secretspresent == 'YES') uses: apple-actions/import-codesign-certs@v2 with: p12-file-base64: ${{ secrets.OSX_SIGNING_CERT }} p12-password: ${{ secrets.OSX_CERT_PWD }} keychain-password: jabref - - name: Setup macOS key chain for app id cert + - name: Set up macOS key chain for app id cert if: (matrix.os == 'macos-latest') && (steps.checksecrets.outputs.secretspresent == 'YES') uses: apple-actions/import-codesign-certs@v2 with: @@ -223,17 +245,19 @@ jobs: ext=${file##*.} mv "$file" "${base}-jdk${{ matrix.jdk }}-javafx${{ matrix.javafx }}.${ext}" done - - name: Setup rsync (macOS) - if: (matrix.os == 'macos-latest') && (steps.checksecrets.outputs.secretspresent == 'YES') && (!startsWith(github.ref, 'refs/heads/gh-readonly-queue')) + + # Upload + - name: Set up rsync (macOS) + if: (matrix.os == 'macos-latest') && (steps.checksecrets.outputs.secretspresent == 'YES') && (github.ref == 'refs/heads/main') run: brew install rsync - - name: Setup rsync (Windows) - if: (matrix.os == 'windows-latest') && (steps.checksecrets.outputs.secretspresent == 'YES') && (!startsWith(github.ref, 'refs/heads/gh-readonly-queue')) + - name: Set up rsync (Windows) + if: (matrix.os == 'windows-latest') && (steps.checksecrets.outputs.secretspresent == 'YES') && (github.ref == 'refs/heads/main') # We want to have rsync available at this place to avoid uploading and downloading from GitHub artifact store (taking > 5 minutes in total) # We cannot use "action-rsyncer", because that requires Docker which is unavailable on Windows # We cannot use "setup-rsync", because that does not work on Windows # We do not use egor-tensin/setup-cygwin@v4, because it replaces the default shell run: choco install --no-progress rsync - - name: Setup SSH key + - name: Set up SSH key if: (steps.checksecrets.outputs.secretspresent == 'YES') && (github.ref == 'refs/heads/main') run: | echo "${{ secrets.buildJabRefPrivateKey }}" > sshkey @@ -250,7 +274,7 @@ jobs: run: | rsync -rt --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --itemize-changes --stats --rsync-path="mkdir -p /var/www/builds.jabref.org/www/jdk-ea && rsync" -e 'ssh -p 9922 -i sshkey -o StrictHostKeyChecking=no' build/distribution/ jrrsync@build-upload.jabref.org:/var/www/builds.jabref.org/www/jdk-ea/ - name: Upload to GitHub workflow artifacts store - if: (steps.checksecrets.outputs.secretspresent != 'YES') + if: (steps.checksecrets.outputs.secretspresent != 'YES') || (github.ref != 'refs/heads/main') uses: actions/upload-artifact@v4 with: name: JabRef-${{ matrix.os }} diff --git a/.gitignore b/.gitignore index ce4ac4f2c73..2e33739ec64 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ src-gen/ .lycheecache javafx/javafx-sdk-* +javafx/javafx-jmods-* javafx/javafx.html javafx/*.tar.gz javafx/*.zip diff --git a/build.gradle b/build.gradle index 1005627eac7..2a2df14ce9f 100644 --- a/build.gradle +++ b/build.gradle @@ -53,6 +53,8 @@ java { // - .devcontainer/devcontainer.json#L34 and // - .github/workflows/deployment-jdk-ea.yml#L53 languageVersion = JavaLanguageVersion.of(21) + // See https://docs.gradle.org/current/javadoc/org/gradle/jvm/toolchain/JvmVendorSpec.html for a full list + // vendor = JvmVendorSpec.AMAZON } } @@ -177,12 +179,16 @@ dependencies { implementation 'jakarta.annotation:jakarta.annotation-api:2.1.1' implementation 'jakarta.inject:jakarta.inject-api:2.0.1' - implementation('org.jabref:afterburner.fx:2.0.0') + implementation('org.jabref:afterburner.fx:2.0.0') { + exclude group: 'org.openjfx' + } implementation 'org.kordamp.ikonli:ikonli-javafx:12.3.1' implementation 'org.kordamp.ikonli:ikonli-materialdesign2-pack:12.3.1' implementation 'com.github.sialcasa.mvvmFX:mvvmfx-validation:f195849ca9' //jitpack implementation 'de.saxsys:mvvmfx:1.8.0' - implementation('com.tobiasdiez:easybind:2.2.1-SNAPSHOT') + implementation('com.tobiasdiez:easybind:2.2.1-SNAPSHOT') { + exclude group: 'org.openjfx' + } implementation 'org.fxmisc.flowless:flowless:0.7.2' implementation 'org.fxmisc.richtext:richtextfx:0.11.2' implementation (group: 'com.dlsc.gemsfx', name: 'gemsfx', version: '2.7.4') { @@ -572,6 +578,9 @@ tasks.register('deleteInstallerTemp', Delete) { jpackage.dependsOn deleteInstallerTemp jlinkZip.dependsOn jpackage jlink { + // https://github.com/beryx/badass-jlink-plugin/issues/61#issuecomment-504640018 + addExtraDependencies("javafx") + addOptions('--strip-debug', '--compress', 'zip-6', '--no-header-files', '--no-man-pages') launcher { name = 'JabRef' @@ -584,7 +593,6 @@ jlink { // but it was removed in the newer releases. // The pom.xml associated with such a non-modular artifact does not mention that the artifact depends on the removed code // (because the artifact was published when this code was still available in the JDK). - forceMerge "javafx" forceMerge "controlsfx", "bcprov", "jaxb", "istack", "stax", "log4j" // TODO: Remove the following correction to the merged module @@ -592,6 +600,13 @@ jlink { // This is based on ./gradlew suggestMergedModuleInfo, sort, strip ";"", comment non-used modules, and include the suggested directives here. // However, we need to fine-tune this manually (non-alphabetic order) mergedModule { + requires 'javafx.base' + requires 'javafx.controls' + requires 'javafx.fxml' + requires 'javafx.graphics' + requires 'javafx.media' + requires 'javafx.swing' + requires 'java.compiler' requires 'java.datatransfer' requires 'java.desktop'