From 5b69435e8910b8775216a8b9f1e7271a968d1ece Mon Sep 17 00:00:00 2001
From: Dmitry Isaenko <developer.su@gmail.com>
Date: Fri, 10 Feb 2023 21:09:26 +0300
Subject: [PATCH] Setup builds for M1

---
 .drone.yml | 11 +++++++++++
 .make_m1   |  5 +++++
 README.md  |  8 ++++----
 pom.xml    | 22 ----------------------
 4 files changed, 20 insertions(+), 26 deletions(-)
 create mode 100644 .make_m1

diff --git a/.drone.yml b/.drone.yml
index 82244f6..364d391 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -57,12 +57,23 @@ steps:
     - cd misc/windows/NSIS
     - makensis -V4 ./installer.nsi
     - cp Installer-*.exe /builds/ns-usbloader/
+    - cd ../../../
     volumes:
     - name: builds
       path: /builds
     - name: jdk
       path: /drone/src/misc/windows/NSIS/jdk
 
+  - name: emerge-mac-m1-artifact
+    image: alpine:latest
+    commands:
+      - . ./.make_m1
+      - mvn -B -DskipTests clean package
+      - cp target/ns-usbloader-*jar /builds/ns-usbloader/
+    volumes:
+      - name: builds
+        path: /builds
+
 volumes:
   - name: m2
     host:
diff --git a/.make_m1 b/.make_m1
new file mode 100644
index 0000000..5ac4f07
--- /dev/null
+++ b/.make_m1
@@ -0,0 +1,5 @@
+sed -z -i -e 's/<groupId>org.usb4java<\/groupId>\n<artifactId>usb4java<\/artifactId>\n<version>1.2.0<\/version>/<groupId>org.usb4java<\/groupId>\n<artifactId>usb4java<\/artifactId>\n<version>1.3.0<\/version>/g' pom.xml
+sed -z -i -e 's/<classifier>mac<\/classifier>/<classifier>mac-aarch64<\/classifier>/g' pom.xml
+sed -z -i -e 's/<finalName>${project.artifactId}-${project.version}-legacy-${maven.build.timestamp}<\/finalName>/<finalName>${project.artifactId}-${project.version}-m1-${maven.build.timestamp}<\/finalName>/g' pom.xml
+sed -i -e '/<groupId>com.akathist.maven.plugins.launch4j/,/<\/executions>/d' pom.xml
+sed -z -i -e 's/<plugin>\n\s*<\/plugin>//g' pom.xml
\ No newline at end of file
diff --git a/README.md b/README.md
index 1b1d899..a2670d4 100644
--- a/README.md
+++ b/README.md
@@ -61,6 +61,7 @@ Sometimes I add new posts about this project [on my blog page](https://developer
 * Ryukyuan languages by [kuragehime](https://github.com/kuragehimekurara1)
 
 * Angelo Elias Dalzotto makes packages in AUR
+* Phoenix[Msc] provides his shiny Mac M1 for debug
 
 ### System requirements
 
@@ -120,12 +121,11 @@ Double-click on downloaded .jar file. Follow instructions. Or see 'Linux' sectio
 
 Set 'Security & Privacy' settings if needed.
 
-*Please note: JDK 11 is recommended for using on MacOS (EXCEPT APPLE SILICON). There are few really weird issues already reported from JDK 14 users on Mac.*
+*Please note: JDK 19 is recommended for using on macOS. There are issues already reported from users on Mac with JDK 14.*
 
 ##### macOS on Apple Silicon (ARM)
 
-* Some users [tested](https://github.com/developersu/ns-usbloader/issues/91) this application with [Zulu-JDK with FX support](https://www.azul.com/downloads/zulu-community/?version=java-11-lts&os=macos&architecture=arm-64-bit&package=jdk-fx). Try it!
-* OpenJDK 17 also should be a working solution. [Tell us if it works for you!]((https://github.com/developersu/ns-usbloader/issues/91))
+Download application with `-m1.jar` postfix.
 
 ##### Windows: 
 
@@ -153,7 +153,7 @@ Table.
 
 There you can select checkbox for files that will be sent to application (AW/GL). ~~Since Goldleaf v0.5 allow you only one file transmission per time, only one file is available for selection.~~ 
 
-Also you can use space to select/un-select files and 'delete' button for deleting. By right-mouse-click you can see context menu where you can delete one OR all items from the table.
+Also, you can use space to select/un-select files and 'delete' button for deleting. By right-mouse-click you can see context menu where you can delete one OR all items from the table.
 
 For Goldleaf v0.6.1 and NS-USBloader v0.6 (and higher) you will have to use 'Explore content' -> 'Remote PC (via USB)' You will see two drives HOME:/ and VIRT:/. First drive is pointing to your home directory. Second one is reflection of what you've added to table (first application tab). Also VIRT:/ drive have limited functionality in comparison to HOME:/. E.g. you can't write files to this drive since it's not a drive. But don't worry, it won't make any impact on Goldleaf or your NS if you try.
 
diff --git a/pom.xml b/pom.xml
index 5233e04..21352e0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -131,28 +131,6 @@
             <classifier>mac</classifier>
             <scope>compile</scope>
         </dependency>
-        <!-- openJFX MAC aarch64 -->
-        <dependency>
-            <groupId>org.openjfx</groupId>
-            <artifactId>javafx-graphics</artifactId>
-            <version>${javafx.version}</version>
-            <classifier>mac-aarch64</classifier>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.openjfx</groupId>
-            <artifactId>javafx-controls</artifactId>
-            <version>${javafx.version}</version>
-            <classifier>mac-aarch64</classifier>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.openjfx</groupId>
-            <artifactId>javafx-fxml</artifactId>
-            <version>${javafx.version}</version>
-            <classifier>mac-aarch64</classifier>
-            <scope>compile</scope>
-        </dependency>
         <!-- https://mvnrepository.com/artifact/org.usb4java/usb4java -->
         <dependency>
             <groupId>org.usb4java</groupId>