From 8546f59b12a58775e6bf7fa1852204cfcfdb9f8e Mon Sep 17 00:00:00 2001
From: Chris Beams <chris@beams.io>
Date: Mon, 15 Nov 2021 16:22:07 +0100
Subject: [PATCH 1/2] Support building and running on Apple M1 Silicon

Problem: Prior to this commit, it was not possible to build or run the
desktop app on Apple's M1 (macos aarch64) architecture.

Solution: This commit makes all the changes necessary to successfully
build and run on M1, but some of these changes require depending on
snapshots and forks of certain dependencies, so this commit shouldn't be
merged to master until those fixes are officially released. The changes
made here include:

1. Upgrading from JavaFX 16 to JavaFX 17. JavaFX 17 was the first
   release to support aarch64 binaries, and so it's required.

2. Upgrading to a version of the openjfx-gradle-plugin that contains the
   fix at openjfx/javafx-gradle-plugin#113 to download the correct
   aarch64-classified JavaFX 17 jars. NOTE: at the time of this commit,
   the fix has not been released, so we are now depending on a
   locally-built SNAPSHOT resolved from `mavenLocal()`.

3. Upgrading to a version of the JFoenix library that includes a fix for
   the bug documented at sshahine/JFoenix#1187. At the time of this
   commit, this fix has only been publihed in the 'rationalityfrontline'
   fork of JFoenix, and so we've temporarily updated our dependency to
   point to that artifact. It appears that a new version of JFoenix is
   being developed that will contain this fix, but it hasn't shipped
   yet.

Notes:

 - Gradle dependency verification metadata has been updated to reflect
   the changes mentioned above, but will need further updates to capture
   the Linux, Windows and MacOS Intel variants of the JavaFX 17
   binaries.

 - Building and testing has been verified to work on JDKs 11 through 17;

 - Running the desktop app only works on JDKs 11 through 15, however,
   until sshahine/JFoenix#1205 is fixed. Right now, attempting to run on
   JDK 16+ will result in a 'Cannot invoke
   "javafx.scene.Node.getLayoutBounds()" because "this.textNode" is null'
   error. See the above mentioned issue for details.

 - It was necessary to bump the minimum supported source compatibility
   in the Gradle build from Java 10 to Java 11 in order to be able to
   consume the upgraded JFoenix artifact.
---
 build.gradle                     | 10 ++--
 gradle/verification-metadata.xml | 98 ++++++++++++--------------------
 2 files changed, 43 insertions(+), 65 deletions(-)

diff --git a/build.gradle b/build.gradle
index 934e2bfb576..dff43d58ed7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,12 +3,13 @@ buildscript {
         mavenCentral()
         maven { url "https://jitpack.io" }
         maven { url "https://plugins.gradle.org/m2/" }
+        mavenLocal()
     }
     dependencies {
         classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.17'
         classpath 'com.google.gradle:osdetector-gradle-plugin:1.6.0'
         classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0'
-        classpath 'org.openjfx:javafx-plugin:0.0.10'
+        classpath 'org.openjfx:javafx-plugin:0.0.11-SNAPSHOT'
         classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.5.6'
     }
 }
@@ -27,7 +28,7 @@ configure(subprojects) {
     apply plugin: 'java'
     apply plugin: 'com.google.osdetector'
 
-    sourceCompatibility = 1.10
+    sourceCompatibility = 1.11
 
     ext { // in alphabetical order
         bcVersion = '1.63'
@@ -50,7 +51,7 @@ configure(subprojects) {
         httpcoreVersion = '4.4.13'
         ioVersion = '2.6'
         jacksonVersion = '2.12.1'
-        javafxVersion = '16'
+        javafxVersion = '17.0.1'
         javaxAnnotationVersion = '1.2'
         jcsvVersion = '1.4.0'
         jetbrainsAnnotationsVersion = '13.0'
@@ -489,7 +490,8 @@ configure(project(':desktop')) {
         implementation "com.google.guava:guava:$guavaVersion"
         implementation "com.google.protobuf:protobuf-java:$protobufVersion"
         implementation "com.googlecode.jcsv:jcsv:$jcsvVersion"
-        implementation "com.jfoenix:jfoenix:$jfoenixVersion"
+        //implementation "com.jfoenix:jfoenix:$jfoenixVersion"               // until sshahine/JFoenix#1187
+        implementation("org.rationalityfrontline.workaround:jfoenix:17.0.1") // is fixed
         implementation "commons-io:commons-io:$ioVersion"
         implementation "de.jensd:fontawesomefx-commons:$fontawesomefxCommonsVersion"
         implementation "de.jensd:fontawesomefx-materialdesignfont:$fontawesomefxMaterialdesignfontVersion"
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml
index d1cef5eae40..2277ede3715 100644
--- a/gradle/verification-metadata.xml
+++ b/gradle/verification-metadata.xml
@@ -964,14 +964,6 @@
             <sha256 value="5788f3fa57cd4cb75db096d5286b948c8a8cb8897875759eda653a29758289d6" origin="Generated by Gradle"/>
          </artifact>
       </component>
-      <component group="com.jfoenix" name="jfoenix" version="9.0.10">
-         <artifact name="jfoenix-9.0.10.jar">
-            <sha256 value="8060235fec5eb49617ec8d81d379e8c945f6cc722d0645e97190045100de2084" origin="Generated by Gradle"/>
-         </artifact>
-         <artifact name="jfoenix-9.0.10.pom">
-            <sha256 value="b24601bd9cc1bad8a9a6ca1586715b488cf2d13ea0fce1acb65dd7c73510176a" origin="Generated by Gradle"/>
-         </artifact>
-      </component>
       <component group="com.natpryce" name="make-it-easy" version="4.0.1">
          <artifact name="make-it-easy-4.0.1.jar">
             <sha256 value="bf28701b65b88532a8bff65a636d7339d6c5db95b2b502799195a15c24fff45b" origin="Generated by Gradle"/>
@@ -2378,74 +2370,50 @@
             <sha256 value="0859ba0d5cfeefb13964e5862c036faa48a0bccff4932638fb13fe3445df33f7" origin="Generated by Gradle"/>
          </artifact>
       </component>
-      <component group="org.openjfx" name="javafx" version="16">
-         <artifact name="javafx-16.pom">
-            <sha256 value="18d9784212d04475bfe4a5f4038e0fc78146f9a721eb6b9a52955d3b4b20d3ca" origin="Generated by Gradle"/>
+      <component group="org.openjfx" name="javafx" version="17.0.1">
+         <artifact name="javafx-17.0.1.pom">
+            <sha256 value="4360be61425322ead03681349d99216b5203342a0a07f7a1c486316926661857" origin="Generated by Gradle"/>
          </artifact>
       </component>
-      <component group="org.openjfx" name="javafx-base" version="16">
-         <artifact name="javafx-base-16-linux.jar">
-            <sha256 value="b825e220d685ecbd77e76f2cd52793132e6c9a10e23ee3361673cb29033413c0" origin="Generated by Gradle"/>
-         </artifact>
-         <artifact name="javafx-base-16-mac.jar">
-            <sha256 value="8cb4a023706d392d0a733aaee41be839e8418448ab0090a8115a9b909d595c77" origin="Generated by Gradle"/>
+      <component group="org.openjfx" name="javafx-base" version="17.0.1">
+         <artifact name="javafx-base-17.0.1-mac-aarch64.jar">
+            <sha256 value="f6bd7eff292ce870ddf446ccd8e1a418b63c993688d2bb91fba083ada7dd7d49" origin="Generated by Gradle"/>
          </artifact>
-         <artifact name="javafx-base-16-win.jar">
-            <sha256 value="23abcdffb6f92d8b37531080682034d01c177f1229118a2f7646331c51c6ed63" origin="Generated by Gradle"/>
+         <artifact name="javafx-base-17.0.1.jar">
+            <sha256 value="045700bcabd5441a50964944f38babbee8fc2e8159179b8cb5e64d18274e3853" origin="Generated by Gradle"/>
          </artifact>
-         <artifact name="javafx-base-16.jar">
-            <sha256 value="036955291b3633b6e11106df315f7a561218d31dcb4280078fe4d2414925f557" origin="Generated by Gradle"/>
-         </artifact>
-         <artifact name="javafx-base-16.pom">
-            <sha256 value="09fe0f2eda8b6f3d4c55b28e32b6b7b2782847add96a686d3048753baa781901" origin="Generated by Gradle"/>
+         <artifact name="javafx-base-17.0.1.pom">
+            <sha256 value="0ffb7659dc3aaa7043baa70566da558736614587d41caa0384fad59d7228b30c" origin="Generated by Gradle"/>
          </artifact>
       </component>
-      <component group="org.openjfx" name="javafx-controls" version="16">
-         <artifact name="javafx-controls-16-linux.jar">
-            <sha256 value="fd0aba38a0dde9836845c6d671501f4c30e6cff6f2d72748f75742dbcfc74df9" origin="Generated by Gradle"/>
-         </artifact>
-         <artifact name="javafx-controls-16-mac.jar">
-            <sha256 value="4add6fdf120ab9c784dc6e700c158d411d9371aaba7bbb61ad9f9d016f2cce44" origin="Generated by Gradle"/>
-         </artifact>
-         <artifact name="javafx-controls-16-win.jar">
-            <sha256 value="a7f6e4757163c38a5e6cf26b426e9daf788ad1b57513111d362b3bbbc298d13b" origin="Generated by Gradle"/>
+      <component group="org.openjfx" name="javafx-controls" version="17.0.1">
+         <artifact name="javafx-controls-17.0.1-mac-aarch64.jar">
+            <sha256 value="6dea8133c070f4e012bf87c090354d5e2fdb3a062489fe5cdc881060da10e682" origin="Generated by Gradle"/>
          </artifact>
-         <artifact name="javafx-controls-16.jar">
-            <sha256 value="dfdbe63f9717b2cd84c9fd34b28a8ddffdbe25cc1e4c2ff9f171f07ca725e0f4" origin="Generated by Gradle"/>
+         <artifact name="javafx-controls-17.0.1.jar">
+            <sha256 value="51d698cac8627e221152b4c421900f73f4af5abcd517008e695e43e22c40ec33" origin="Generated by Gradle"/>
          </artifact>
-         <artifact name="javafx-controls-16.pom">
-            <sha256 value="1769aa2547256cfe316387d78375056587283b63f0614fa6e9b59231ef90edd0" origin="Generated by Gradle"/>
+         <artifact name="javafx-controls-17.0.1.pom">
+            <sha256 value="e0542cc8528fe825402c480da2a7e149401bdb3b943849f4a1f46939ff57bdd9" origin="Generated by Gradle"/>
          </artifact>
       </component>
-      <component group="org.openjfx" name="javafx-fxml" version="16">
-         <artifact name="javafx-fxml-16-linux.jar">
-            <sha256 value="65249a5a47357283f21c5fa85b2e91255f7e5b0b86a2ec3dd2cc220541d7ae0b" origin="Generated by Gradle"/>
+      <component group="org.openjfx" name="javafx-fxml" version="17.0.1">
+         <artifact name="javafx-fxml-17.0.1-mac-aarch64.jar">
+            <sha256 value="cd2cb7de17a79fdcca38c6b75f14cd23c923ede48c2943e87cb2f5f3ec687866" origin="Generated by Gradle"/>
          </artifact>
-         <artifact name="javafx-fxml-16-mac.jar">
-            <sha256 value="b722e590930180ff7c43d34281202251e1fe8d1f81b16098cda78600780b7f46" origin="Generated by Gradle"/>
-         </artifact>
-         <artifact name="javafx-fxml-16-win.jar">
-            <sha256 value="e8313ffb783c26acbbc1267448bbfdf2f05126e5845a06c6f29a43db7483606d" origin="Generated by Gradle"/>
-         </artifact>
-         <artifact name="javafx-fxml-16.pom">
-            <sha256 value="7b3b1a717f5d3a67f1dadcc880de3677a25a5d4e8004b75c61cec8b044b013cd" origin="Generated by Gradle"/>
+         <artifact name="javafx-fxml-17.0.1.pom">
+            <sha256 value="3c9ed8df3409c3ba570cd0879c31eb560bac3fddb9cd191921af0f3a85fa769b" origin="Generated by Gradle"/>
          </artifact>
       </component>
-      <component group="org.openjfx" name="javafx-graphics" version="16">
-         <artifact name="javafx-graphics-16-linux.jar">
-            <sha256 value="a2f5e1ea5aeb3ae57e63a1c853a4edf1e38b6f2fe76997ab864ad8b3c54bed53" origin="Generated by Gradle"/>
-         </artifact>
-         <artifact name="javafx-graphics-16-mac.jar">
-            <sha256 value="23a67ad877f283039a20dd827f68988c1f952fe4958d039c006762883f1f04ab" origin="Generated by Gradle"/>
-         </artifact>
-         <artifact name="javafx-graphics-16-win.jar">
-            <sha256 value="78124668c64db443cf3e105b9c2f6d7061e7c72ad5ad2de63a13adc46ef2ca8c" origin="Generated by Gradle"/>
+      <component group="org.openjfx" name="javafx-graphics" version="17.0.1">
+         <artifact name="javafx-graphics-17.0.1-mac-aarch64.jar">
+            <sha256 value="213a02ad34caacfbda9e53491007353bcd56f22ac30be6473c866dbb69a3243c" origin="Generated by Gradle"/>
          </artifact>
-         <artifact name="javafx-graphics-16.jar">
-            <sha256 value="77533b2922a853a3e1350c8e6650f6cf746000d20efef69119c6324086883b95" origin="Generated by Gradle"/>
+         <artifact name="javafx-graphics-17.0.1.jar">
+            <sha256 value="53d60cef64ab6a1549da4d0239c009f8ef8084b62ecd18c3bda782b4d6520a8f" origin="Generated by Gradle"/>
          </artifact>
-         <artifact name="javafx-graphics-16.pom">
-            <sha256 value="b8fb99688eccae62be724bd72b34dfff1f8e1cddbe44649f5ef9a082e520c47e" origin="Generated by Gradle"/>
+         <artifact name="javafx-graphics-17.0.1.pom">
+            <sha256 value="5b1ed9d6a7dd5dd20103a4a7fd4c52b462c175c44658eb5b8d7fd5bd92c85231" origin="Generated by Gradle"/>
          </artifact>
       </component>
       <component group="org.openjfx" name="javafx-plugin" version="0.0.10">
@@ -2517,6 +2485,14 @@
             <sha256 value="6669bd6674aa9e52a2a97344ab3411b31295b2e64c7881e27c2ed6beb66922c2" origin="Generated by Gradle"/>
          </artifact>
       </component>
+      <component group="org.rationalityfrontline.workaround" name="jfoenix" version="17.0.1">
+         <artifact name="jfoenix-17.0.1.jar">
+            <sha256 value="30cabdf875998d0b107e41b051c867cc275003f326c1795f0256f9a900a6d872" origin="Generated by Gradle"/>
+         </artifact>
+         <artifact name="jfoenix-17.0.1.module">
+            <sha256 value="ad7d70774de3c6866866ae7640a431a9308da32eb347a8cd8246842bedd6658f" origin="Generated by Gradle"/>
+         </artifact>
+      </component>
       <component group="org.slf4j" name="jul-to-slf4j" version="1.7.32">
          <artifact name="jul-to-slf4j-1.7.32.jar">
             <sha256 value="6dee8d85ad6943aff0600f14897c469e64bae0413ee33a15c448af00432c0642" origin="Generated by Gradle"/>

From abf86ac0a072a5131f9be3f872f0f4d8662fe6f1 Mon Sep 17 00:00:00 2001
From: Chris Beams <chris@beams.io>
Date: Mon, 20 Dec 2021 07:49:53 +0100
Subject: [PATCH 2/2] Upgrade to newly published javafx-gradle-plugin snapshot

This removes our dependency on a locally-built javafx-gradle-plugin 0.11
snapshot for the newly-published official snapshot at documented at
https://github.com/openjfx/javafx-gradle-plugin/pull/113#issuecomment-990848432.
---
 build.gradle | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build.gradle b/build.gradle
index dff43d58ed7..035cb9ebfb4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,7 +3,7 @@ buildscript {
         mavenCentral()
         maven { url "https://jitpack.io" }
         maven { url "https://plugins.gradle.org/m2/" }
-        mavenLocal()
+        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
     }
     dependencies {
         classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.17'