Skip to content

Commit

Permalink
Include JavaFX jmods (and remove forceMerge javaFX) (JabRef#11170)
Browse files Browse the repository at this point in the history
* 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 8e6c7d5.

* Revert "Maybe JavaFX is now modular?"

This reverts commit 79dc5b3.

* 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 40fb252.

* 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 fcd35b5.

* Remove forceMerge of JavaFX

* Switch back to default JDK

* Add requires statements

* Revert "Switch back to default JDK"

This reverts commit f2d18cd.

* 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 <[email protected]>
  • Loading branch information
koppor and calixtus authored Apr 10, 2024
1 parent 90e99fe commit aa0fa84
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 53 deletions.
124 changes: 74 additions & 50 deletions .github/workflows/deployment-jdk-ea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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/[email protected]
with:
versionSpec: "5.x"
- name: Run GitVersion
id: gitversion
uses: gittools/actions/gitversion/[email protected]

# 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
Expand Down Expand Up @@ -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/[email protected]
with:
versionSpec: "5.x"
- name: Run GitVersion
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- 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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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/ [email protected]:/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 }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ src-gen/
.lycheecache

javafx/javafx-sdk-*
javafx/javafx-jmods-*
javafx/javafx.html
javafx/*.tar.gz
javafx/*.zip
Expand Down
21 changes: 18 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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'
Expand All @@ -584,14 +593,20 @@ 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
// The module descriptor automatically generated by the plugin for the merged module contained some invalid entries.
// 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'
Expand Down

0 comments on commit aa0fa84

Please sign in to comment.