Browse Source

:hammer: Added a script to automatically package the JLink generated images (since for some reason using targetPlatform doesn't build the archives duh)

Signed-off-by: palexdev <alessandro.parisi406@gmail.com>
palexdev 3 years ago
parent
commit
6cb51b82d1
2 changed files with 56 additions and 10 deletions
  1. 24 10
      demo/build.gradle
  2. 32 0
      demo/scripts/JLinkPackage.sh

+ 24 - 10
demo/build.gradle

@@ -1,3 +1,5 @@
+import org.apache.tools.ant.taskdefs.condition.Os
+
 plugins {
     id 'application'
     id 'org.beryx.jlink' version '2.25.0'
@@ -28,6 +30,20 @@ dependencies {
     implementation project(':materialfx')
 }
 
+compileTestJava {
+    moduleOptions {
+        compileOnClasspath = true
+    }
+}
+
+test {
+    useJUnitPlatform()
+
+    moduleOptions {
+        runOnClasspath = true
+    }
+}
+
 application {
     setMainModule("MaterialFX.Demo")
     String main = project.findProperty("chooseMain").toString()
@@ -66,17 +82,15 @@ jlink {
     addExtraDependencies('javafx')
 }
 
-
-compileTestJava {
-    moduleOptions {
-        compileOnClasspath = true
+task doPackageAll {
+    if (Os.isFamily(Os.FAMILY_UNIX)) {
+        exec {
+            executable "$projectDir/scripts/JLinkPackage.sh"
+            args = ["$buildDir"]
+        }
     }
 }
 
-test {
-    useJUnitPlatform()
-
-    moduleOptions {
-        runOnClasspath = true
-    }
+jlinkZip.doLast {
+    doPackageAll
 }

+ 32 - 0
demo/scripts/JLinkPackage.sh

@@ -0,0 +1,32 @@
+#!/bin/sh
+
+#
+# Copyright (C) 2022 Parisi Alessandro
+# This file is part of MaterialFX (https://github.com/palexdev/MaterialFX).
+#
+# MaterialFX is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# MaterialFX is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with MaterialFX.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+# This only works on Linux and specifically my system since tar2zip is a npm module I installed to convert the tar archive
+# to zip easily.
+# I was tired of Gradle shit and also tired of learning about boring Linux commands stuff (the tar command is quantum physic
+# and the zip command on the other hand is very limited) so this is the quickest solution I came up with
+
+BASE_DIR=$1
+IMG_DIR="${BASE_DIR}/image"
+OUT_DIR="${BASE_DIR}/distributions"
+
+tar -C "${IMG_DIR}/MaterialFX Demo-linux-x64" --transform 'flags=r;s|.|MFXDemo_Linux|' -c . | xz -4 > "${OUT_DIR}/materialfx_demo_linux64.tar.xz"
+tar -C "${IMG_DIR}/MaterialFX Demo-mac" --transform 'flags=r;s|.|MFXDemo_Mac|' -c . | xz -4 > "${OUT_DIR}/materialfx_demo_mac64.tar.xz"
+tar -C "${IMG_DIR}/MaterialFX Demo-win" --transform 'flags=r;s|.|MFXDemo_Win|' -c . | tar2zip > "${OUT_DIR}/materialfx_demo_win64.zip"