Skip to content

Commit 20500cf

Browse files
committed
Use jpackage on Windows and Linux
1 parent af80691 commit 20500cf

File tree

7 files changed

+46
-83
lines changed

7 files changed

+46
-83
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ jobs:
1919
- name: Install Linux dependencies
2020
run: sudo apt install libcurl4-openssl-dev libzip-dev && git clone --depth=1 https://github.com/tihmstar/libgeneral.git && cd libgeneral && ./autogen.sh && make && sudo make install && git clone --depth=1 https://github.com/tihmstar/libfragmentzip.git && cd libfragmentzip && sed -i '/LIBGENERAL_REQUIRES_STR/d' ./configure.ac && ./autogen.sh && make && sudo make install && sudo ln -s /usr/local/lib/libfragmentzip.so /usr/lib/
2121
if: runner.os == 'Linux'
22-
- name: Fix macOS AppleScript permissions
23-
run: sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db "insert into access (service, client, client_type, allowed, prompt_count, indirect_object_identifier_type, indirect_object_identifier) values ('kTCCServiceAppleEvents', '`which java`', 1, 1, 1, 0, 'com.apple.finder')"
24-
if: runner.os == 'macOS'
2522
- name: gradle build
2623
uses: eskatos/gradle-command-action@v1
2724
with:
28-
arguments: build
25+
arguments: build --no-daemon
2926
wrapper-cache-enabled: true
3027
dependencies-cache-enabled: true
3128
- uses: actions/upload-artifact@v2

.idea/modules/blobsaver.main.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ String appIdentifier = "airsquared.blobsaver.app"
3838
String copyright = "Copyright (c) 2020 airsquared"
3939
def os = DefaultNativePlatform.currentOperatingSystem
4040

41-
startScripts.enabled = false
42-
distZip.enabled = false
43-
distTar.enabled = false
44-
assemble.dependsOn jpackage
41+
startScripts.enabled = distZip.enabled = distTar.enabled = false
4542

4643
repositories {
4744
mavenCentral()
@@ -105,14 +102,21 @@ jlink {
105102
noConsole = true
106103
}
107104
jpackage {
105+
icon = "${projectDir}/${icon}"
106+
imageOptions = [ '--copyright', copyright, '--vendor', 'airsquared']
107+
108108
if (os.isMacOsX()) {
109109
installerType = "dmg"
110+
imageOptions.addAll '--mac-package-identifier', appIdentifier
110111
icon = "dist/macos/Contents/Resources/blob.icns"
111-
} else if (os.isWindows()) icon = "dist/windows/blob.ico"
112-
else icon = "src/main/resources/airsquared/blobsaver/app/blob_emoji.png"
113-
114-
icon = "${projectDir}/${icon}"
115-
imageOptions = [ '--copyright', copyright]
112+
} else if (os.isWindows()) {
113+
installerOptions.addAll '--win-dir-chooser', '--win-menu', '--win-shortcut'
114+
icon = "dist/windows/blob.ico"
115+
} else {
116+
installerOptions.addAll '--linux-shortcut', '--linux-menu-group', 'Utility;Archiving;Java',
117+
'--linux-rpm-license-type', 'GPLv3'
118+
icon = "src/main/resources/airsquared/blobsaver/app/blob_emoji.png"
119+
}
116120
}
117121
if (os.isMacOsX()) jpackageImage.doLast {
118122
copy {
@@ -125,44 +129,32 @@ jlink {
125129
from "${projectDir}/LICENSE", "${projectDir}/libraries_used.txt"
126130
into "${buildDir}/jpackage/blobsaver.app/Contents/Resources"
127131
}
128-
}
129-
130-
/* Need to figure out how to exclude the following unnecessary files/directories: "about.fxml", "about.css",
131-
"aix-ppc/*", "aix-ppc64/*", "linux-ppc/*", "linux-ppc64le/*", "linux-s390x/*", "linux-mips64el/*",
132-
"darwin/*", "win32-x86/*", "win32-x86-64/*", "openbsd-x86/*", "openbsd-x86-64/*", "freebsd-x86/*",
133-
"freebsd-x86-64/*", "sunos-sparc/*", "sunos-sparcv9/*", "sunos-x86/*", "sunos-x86-64/*"
134-
*/
135-
}
136-
137-
// if your platform isn't Windows, wine is required to run this task
138-
task createWindowsInstaller() {
139-
inputs.dir("${projectDir}/dist/windows/")
140-
inputs.file("${buildDir}/launch4j/blobsaver.exe")
141-
outputs.file("${buildDir}/distributions/blobsaver-windows.exe")
142-
143-
doFirst {
144-
delete "${buildDir}/tmp/innosetup"
132+
} else if (os.isWindows()) jpackageImage.doLast {
145133
copy {
146-
from "${projectDir}/dist/windows" into "${buildDir}/tmp/innosetup"
134+
from "${projectDir}/dist/windows/files" from "${buildDir}/jpackage/blobsaver/runtime/bin/zip.dll"
147135
rename "LICENSE_windows", "LICENSE"
148136
rename "libraries_used_windows.txt", "libraries_used.txt"
137+
into "${buildDir}/jpackage/blobsaver"
149138
}
139+
} else jpackageImage.doLast {
150140
copy {
151-
from "${projectDir}/dist/windows/blobsaver.iss" into "${buildDir}/tmp/innosetup"
152-
filter(ReplaceTokens, tokens: [AppName: project.name, AppVersion: version, AppCopyright: copyright, AppMutex: appIdentifier])
141+
from "${projectDir}/dist/linux" into "${buildDir}/jpackage/blobsaver/lib"
153142
}
143+
}
144+
145+
}
146+
147+
task windowsInstaller(dependsOn: jpackageImage) { // requires inno setup to be installed
148+
doFirst {
154149
copy {
155-
from "${buildDir}/launch4j/blobsaver.exe" into "${buildDir}/tmp/innosetup/files"
150+
from "${projectDir}/dist/windows/blobsaver.iss" into "${buildDir}/jpackage"
151+
filter(ReplaceTokens, tokens: [AppName: project.name, AppVersion: version, AppCopyright: copyright, AppMutex: appIdentifier])
156152
}
157-
mkdir "${buildDir}/distributions/"
158-
println "running Inno Setup Compiler"
159153
exec {
160-
workingDir = projectDir
161-
if (os.isWindows()) {
162-
commandLine "gradle\\InnoSetup6\\ISCC.exe", "/Qp", "${buildDir}\\tmp\\innosetup\\blobsaver.iss"
163-
} else {
164-
commandLine "wine", "gradle/InnoSetup6/ISCC.exe", "/Qp", "${buildDir}/tmp/innosetup/blobsaver.iss"
165-
}
154+
commandLine "iscc", "/Qp", "${buildDir}\\jpackage\\blobsaver.iss"
166155
}
156+
delete "${buildDir}/jpackage/blobsaver.iss"
167157
}
168158
}
159+
160+
assemble.dependsOn os.isWindows() ? windowsInstaller : jpackage

dist/linux/README-linux.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
blobsaver has two required dependencies and two optional.
1+
blobsaver has one required dependency and two optional.
22
Make sure to install these on your system before continuing.
33

44
Required:
5-
- Java 8 with JavaFX or OpenJFX
6-
Please see https://github.com/airsquared/blobsaver/wiki/Installing-Java
7-
and https://github.com/airsquared/blobsaver/wiki/Making-sure-you-have-the-right-Java-version
8-
if you need help making sure you have the right Java version
9-
105
- libfragmentzip (https://github.com/tihmstar/libfragmentzip)
116

127
Optional (for reading information from connected devices):

dist/linux/blobsaver

Lines changed: 0 additions & 29 deletions
This file was deleted.

dist/windows/blobsaver.iss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ ArchitecturesInstallIn64BitMode=x64 arm64
2828
Uninstallable=not IsTaskSelected('portableMode')
2929
DefaultDirName={pf}\{#MyAppName}
3030
DisableProgramGroupPage=yes
31-
LicenseFile=files\LICENSE
32-
OutputDir=..\..\distributions
31+
OutputDir=.
3332
OutputBaseFilename=blobsaver-windows
34-
SetupIconFile=blob.ico
33+
SetupIconFile=blobsaver\blobsaver.ico
3534
Compression=lzma
3635
SolidCompression=yes
3736

@@ -43,7 +42,7 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{
4342
Name: "portableMode"; Description: "Portable Installation Mode"; Flags: unchecked
4443

4544
[Files]
46-
Source: "files\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
45+
Source: "blobsaver\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
4746
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
4847

4948
[Icons]

src/main/java/airsquared/blobsaver/app/Main.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import java.io.File;
3030
import java.io.IOException;
31+
import java.io.UncheckedIOException;
3132

3233
import static com.sun.jna.Platform.isMac;
3334
import static com.sun.jna.Platform.isWindows;
@@ -37,7 +38,15 @@ public class Main {
3738
static final String appVersion = "v3.0b0";
3839
static Stage primaryStage;
3940
// make sure to set system property before running (automatically set if running from gradle)
40-
static final File jarDirectory = new File(System.getProperty("jar.directory")).getAbsoluteFile(); //TODO do correct parent file stuff
41+
static final File jarDirectory;
42+
43+
static {
44+
try {
45+
jarDirectory = new File(System.getProperty("jar.directory")).getCanonicalFile();
46+
} catch (IOException e) {
47+
throw new UncheckedIOException(e);
48+
}
49+
}
4150

4251
/**
4352
* Enables a menu item in the system tray to activate a breakpoint when in background and

0 commit comments

Comments
 (0)