Skip to content

Commit 8475cbc

Browse files
committed
Upgrade to Java 16, add more tests
1 parent cb16ab4 commit 8475cbc

File tree

14 files changed

+198
-151
lines changed

14 files changed

+198
-151
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
os: [ubuntu-latest, windows-latest, macOS-latest]
1313
steps:
1414
- uses: actions/checkout@v2
15-
- name: Set up JDK 15
15+
- name: Set up JDK 16
1616
uses: actions/setup-java@v1
1717
with:
18-
java-version: '15'
18+
java-version: '16'
1919
- name: gradle build
2020
uses: eskatos/gradle-command-action@v1
2121
with:

.idea/compiler.xml

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

.idea/misc.xml

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

.idea/runConfigurations/Main__Linux_.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Main__Windows_.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Main__macOS_.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ plugins {
2323
id 'java'
2424
id 'application'
2525
id 'com.github.ben-manes.versions' version '0.38.0'
26-
id 'org.beryx.jlink' version '2.23.3'
26+
id 'org.beryx.jlink' version '2.23.5'
27+
id 'com.dua3.javafxgradle7plugin' version '0.0.9'
2728

2829
id 'idea'
2930
}
@@ -36,43 +37,30 @@ idea.module.outputDir file("out/production/classes") // fix running via IntelliJ
3637
version = "2.6"
3738
description = "A cross-platform GUI app for saving SHSH blobs"
3839
String appIdentifier = "airsquared.blobsaver.app"
39-
String copyright = "Copyright (c) 2020 airsquared"
40+
String copyright = "Copyright (c) 2021 airsquared"
4041
def os = DefaultNativePlatform.currentOperatingSystem
4142

4243
startScripts.enabled = distZip.enabled = distTar.enabled = false
4344

45+
java.toolchain.languageVersion = JavaLanguageVersion.of(16)
46+
4447
repositories {
4548
mavenCentral()
4649
}
4750

4851
dependencies {
49-
String fxPlatform = ""
50-
if (os.isMacOsX()) fxPlatform = 'mac'
51-
else if (os.isWindows()) fxPlatform = 'win'
52-
else if (os.isLinux()) fxPlatform = 'linux'
53-
54-
implementation "org.openjfx:javafx-base:16:$fxPlatform"
55-
implementation "org.openjfx:javafx-controls:16:$fxPlatform"
56-
implementation "org.openjfx:javafx-graphics:16:$fxPlatform"
57-
implementation "org.openjfx:javafx-fxml:16:$fxPlatform"
58-
5952
implementation group: 'org.json', name: 'json', version: '20210307'
6053
implementation 'de.jangassen:nsmenufx:3.1.0'
61-
// implementation 'net.java.dev.jna:jna:jpms:5.7.0'
54+
implementation 'net.java.dev.jna:jna:5.7.0:jpms'
6255
implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.20'
6356

64-
6557
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1'
58+
testImplementation group: 'org.testfx', name: 'openjfx-monocle', version: 'jdk-12.0.1+2'
6659
}
6760

68-
java {
69-
toolchain {
70-
languageVersion = JavaLanguageVersion.of(15)
71-
}
72-
}
73-
74-
compileJava {
75-
options.compilerArgs = ['--module-path', classpath.asPath]
61+
javafx {
62+
version = '16'
63+
modules = [ 'javafx.controls', 'javafx.fxml' ]
7664
}
7765

7866
application {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-rc-1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,8 @@ private TSS createTSS(String runningAlertTitle) {
625625
}
626626

627627
private void parseException(Throwable t) {
628-
if (t instanceof TSS.TSSException) {
629-
TSS.TSSException e = (TSS.TSSException) t;
630-
String message = t.getMessage();
628+
if (t instanceof TSS.TSSException e) {
629+
String message = e.getMessage();
631630
if (message.contains("not a valid identifier")) {
632631
identifierField.setEffect(Utils.errorBorder);
633632
} else if (message.contains("IPSW URL is not valid")) {

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

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static void export(File file) {
6464
public static void importXML(File file) throws IOException, InvalidPreferencesFormatException {
6565
Preferences.importPreferences(new FileInputStream(file));
6666
if (savedDevicesList != null) {
67-
savedDevicesList.setAll(savedDevices().collect(Collectors.toList()));
67+
savedDevicesList.setAll(savedDevices().toList());
6868
}
6969
}
7070

@@ -112,22 +112,6 @@ public static boolean getShowOldDevices() {
112112
return appPrefs.getBoolean("Show Old Devices", false);
113113
}
114114

115-
public static Optional<SavedDevice> savedDevice(String name) {
116-
if (savedDeviceExists(name)) {
117-
return Optional.of(new SavedDevice(name));
118-
} else {
119-
return Optional.empty();
120-
}
121-
}
122-
123-
private static boolean savedDeviceExists(String name) {
124-
try {
125-
return savedDevicesPrefs.nodeExists(name);
126-
} catch (BackingStoreException e) {
127-
return false;
128-
}
129-
}
130-
131115
private static Stream<SavedDevice> savedDevices() {
132116
try {
133117
return Arrays.stream(savedDevicesPrefs.childrenNames()).map(SavedDevice::new);
@@ -141,7 +125,7 @@ private static Stream<SavedDevice> savedDevices() {
141125
*/
142126
public static ObservableList<SavedDevice> getSavedDevices() {
143127
if (savedDevicesList == null) {
144-
savedDevicesList = FXCollections.observableList(savedDevices().collect(Collectors.toList()));
128+
savedDevicesList = savedDevices().collect(Collectors.toCollection(FXCollections::observableArrayList));
145129
}
146130

147131
return savedDevicesList;
@@ -155,10 +139,6 @@ public static boolean anyBackgroundDevices() {
155139
return savedDevices().anyMatch(SavedDevice::isBackground);
156140
}
157141

158-
public static boolean isDeviceInBackground(String name) {
159-
return savedDevice(name).map(SavedDevice::isBackground).orElse(false);
160-
}
161-
162142
public static void setBackgroundInterval(long interval, TimeUnit timeUnit) {
163143
appPrefs.putLong("Time to run", interval);
164144
appPrefs.put("Time unit for background", timeUnit.toString());
@@ -247,7 +227,7 @@ public String toString() {
247227

248228
@Override
249229
public boolean equals(Object o) {
250-
return o instanceof SavedDevice && this.getName().equals(((SavedDevice) o).getName());
230+
return o instanceof SavedDevice s && this.getName().equals(s.getName());
251231
}
252232

253233
@Override

0 commit comments

Comments
 (0)