Skip to content

Commit 50553f0

Browse files
committed
Bugfix & build.gradle changes
+ now uses the previous build.gradle, creating a fat jar -- Bugfix + filetransfer is working again
1 parent 4e673f8 commit 50553f0

File tree

4 files changed

+83
-143
lines changed

4 files changed

+83
-143
lines changed

build.gradle

+10-98
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
buildscript {
2-
dependencies {
3-
classpath group: 'de.dynamicfiles.projects.gradle.plugins', name: 'javafx-gradle-plugin', version: '8.8.2'
4-
}
5-
6-
repositories {
7-
mavenLocal()
8-
mavenCentral()
9-
}
1+
plugins {
2+
id 'application'
103
}
114

12-
apply plugin: 'java'
13-
145
repositories {
15-
mavenLocal()
166
mavenCentral()
177
}
188

@@ -24,91 +14,13 @@ dependencies {
2414
compile group: 'org.json', name: 'json', version: '20090211'
2515
}
2616

27-
apply plugin: 'javafx-gradle-plugin'
28-
29-
jfx {
30-
verbose = true
31-
mainClass = "com.github.dunklemango.starboundmodmanager.MainFrame"
32-
jfxAppOutputDir = "build/jfx/app"
33-
jfxMainAppJarName = "StarboundModManager.jar"
34-
deployDir = "src/main/deploy"
35-
useEnvironmentRelativeExecutables = true
36-
libFolderName = "lib"
37-
38-
// gradle jfxJar
39-
css2bin = false
40-
preLoader = null // String
41-
updateExistingJar = false
42-
allPermissions = false
43-
manifestAttributes = null // Map<String, String>
44-
addPackagerJar = true
45-
copyAdditionalAppResourcesToJar = false
46-
skipCopyingDependencies = false
47-
useLibFolderContentForManifestClasspath = false
48-
fixedManifestClasspath = null
49-
50-
// gradle jfxNative
51-
identifier = null // String - setting this for windows-bundlers makes it possible to generate upgradeable installers (using same GUID)
52-
vendor = "DunkleMango @ github.com"
53-
nativeOutputDir = "build/jfx/native"
54-
bundler = "ALL" // set this to some specific, if your don't want all bundlers running, examples "windows.app", "jnlp", ...
55-
jvmProperties = null // Map<String, String>
56-
jvmArgs = null // List<String>
57-
userJvmArgs = null // Map<String, String>
58-
launcherArguments = null // List<String>
59-
nativeReleaseVersion = "1.0"
60-
needShortcut = false
61-
needMenu = false
62-
bundleArguments = [
63-
// dont bundle JRE (not recommended, but increases build-size/-speed)
64-
runtime: null
65-
]
66-
appName = "project" // this is used for files below "src/main/deploy", e.g. "src/main/deploy/package/windows/project.ico"
67-
additionalBundlerResources = null // path to some additional resources for the bundlers when creating application-bundle
68-
additionalAppResources = null // path to some additional resources when creating application-bundle
69-
secondaryLaunchers = [[appName:"somethingDifferent"], [appName:"somethingDifferent2"]]
70-
fileAssociations = null // List<Map<String, Object>>
71-
noBlobSigning = false // when using bundler "jnlp", you can choose to NOT use blob signing
72-
customBundlers = null // List<String>
73-
failOnError = false
74-
onlyCustomBundlers = false
75-
skipJNLP = false
76-
skipNativeVersionNumberSanitizing = false // anything than numbers or dots are removed
77-
additionalJarsignerParameters = null // List<String>
78-
skipMainClassScanning = false // set to true might increase build-speed
79-
80-
skipNativeLauncherWorkaround124 = false
81-
skipNativeLauncherWorkaround167 = false
82-
skipNativeLauncherWorkaround205 = false
83-
skipJNLPRessourcePathWorkaround182 = false
84-
skipSigningJarFilesJNLP185 = false
85-
skipSizeRecalculationForJNLP185 = false
86-
skipMacBundlerWorkaround = false
17+
mainClassName = 'com.github.dunklemango.starboundmodmanager.MainFrame'
8718

88-
// gradle jfxRun
89-
runJavaParameter = null // String
90-
runAppParameter = null // String
91-
92-
// per default the outcome of the gradle "jarTask" will be used, set this to specify otherwise (like proguard-output)
93-
alternativePathToJarFile = null // String
94-
95-
// to disable patching of ant-javafx.jar, set this to false
96-
usePatchedJFXAntLib = true
97-
98-
// making it able to support absolute paths, defaults to "false" for maintaining old behaviour
99-
checkForAbsolutePaths = false
100-
101-
// gradle jfxGenerateKeyStore
102-
keyStore = "src/main/deploy/keystore.jks"
103-
keyStoreAlias = "myalias"
104-
keyStorePassword = "password"
105-
keyPassword = null // will default to keyStorePassword
106-
keyStoreType = "jks"
107-
overwriteKeyStore = false
108-
109-
certDomain = null // required
110-
certOrgUnit = null // defaults to "none"
111-
certOrg = null // required
112-
certState = null // required
113-
certCountry = null // required
19+
jar {
20+
manifest {
21+
attributes 'Main-Class': mainClassName
22+
}
23+
from {
24+
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
25+
}
11426
}

src/main/java/com/github/dunklemango/starboundmodmanager/MainFrame.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.github.dunklemango.starboundmodmanager.storage.SettingsManager;
1212
import com.github.dunklemango.starboundmodmanager.storage.WorkshopCacheManager;
1313
import com.github.dunklemango.starboundmodmanager.transfer.FileTransferTask;
14+
import com.github.dunklemango.starboundmodmanager.transfer.TransferTaskInformation;
1415
import com.github.dunklemango.starboundmodmanager.workshop.WorkshopItem;
1516
import com.github.dunklemango.starboundmodmanager.workshop.WorkshopItemManager;
1617
import javafx.application.Application;
@@ -36,9 +37,12 @@
3637
import org.apache.logging.log4j.Logger;
3738

3839
import java.io.File;
40+
import java.io.IOException;
41+
import java.nio.file.Files;
3942
import java.nio.file.Path;
4043
import java.nio.file.Paths;
4144
import java.util.*;
45+
import java.util.concurrent.ExecutionException;
4246

4347
public class MainFrame extends Application {
4448
private static final Logger logger = LogManager.getLogger("Application");
@@ -306,7 +310,7 @@ private void transferFiles(List<Integer> idsOfFilesToTransfer, Stage primaryStag
306310
File inputFile = subFiles[0];
307311
File outputFile = this.getOutputPath().resolve(id + ModFile.MOD_FILE_EXTENSION).toFile();
308312
logger.debug("writing modFile: {}", outputFile);
309-
if (inputFile.exists() && outputFile.exists()) {
313+
if (inputFile.exists()) {
310314
logger.debug("input file \"{}\" and output path \"{}\" exists", inputFile,
311315
outputFile.getAbsolutePath());
312316
inputFiles.add(inputFile);
@@ -315,8 +319,8 @@ private void transferFiles(List<Integer> idsOfFilesToTransfer, Stage primaryStag
315319
}
316320
}
317321
}
318-
319-
322+
logger.debug("inputFiles: {}", inputFiles);
323+
logger.debug("outputFiles: {}", outputFiles);
320324
FileTransferTask fileTransferTask = new FileTransferTask(inputFiles, outputFiles);
321325

322326
progressBar.progressProperty().addListener((obs, ov, nv) -> {
@@ -326,10 +330,16 @@ private void transferFiles(List<Integer> idsOfFilesToTransfer, Stage primaryStag
326330
});
327331
fileTransferTask.transferFiles(progressBar);
328332
grid.add(progressBar, 0, 1);
329-
fileTransferTask.getTask().setOnSucceeded(event -> {
333+
fileTransferTask.setOnSucceeded(event -> {
330334
resetCheckboxes();
331335
updateOutputTable();
332336
});
337+
try {
338+
TransferTaskInformation info = fileTransferTask.get();
339+
info.print();
340+
} catch (InterruptedException | ExecutionException e) {
341+
logger.error("Unable to print faulting files of transfer task.", e);
342+
}
333343

334344
Scene dialogScene = new Scene(grid, 300, 100);
335345
dialog.setScene(dialogScene);
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.github.dunklemango.starboundmodmanager.transfer;
22

3-
import com.github.dunklemango.starboundmodmanager.MainFrame;
43
import javafx.concurrent.Task;
54
import javafx.scene.control.ProgressBar;
65
import org.apache.logging.log4j.LogManager;
@@ -12,20 +11,17 @@
1211
import java.util.ArrayList;
1312
import java.util.List;
1413

15-
public class FileTransferTask {
14+
public class FileTransferTask extends Task<TransferTaskInformation> {
1615
private static final Logger logger = LogManager.getLogger("FileTransferTask");
1716
private final List<File> inputFiles;
1817
private final List<File> outputFiles;
1918
private final double progressPerStep;
20-
private List <File> faultingFiles = new ArrayList<>();
21-
private volatile Task<Void> task;
2219

2320
public FileTransferTask(List<File> inputFiles, List<File> outputFiles) {
2421
if (inputFiles.size() != outputFiles.size()) throw new IllegalArgumentException("Size of inputFiles must match that of outputFiles!");
2522
this.inputFiles = inputFiles;
2623
this.outputFiles = outputFiles;
2724
this.progressPerStep = 1.0 / inputFiles.size();
28-
init();
2925
}
3026

3127
public FileTransferTask(File inputFile, File outputFile) {
@@ -34,49 +30,38 @@ public FileTransferTask(File inputFile, File outputFile) {
3430
this.inputFiles.add(inputFile);
3531
this.outputFiles.add(outputFile);
3632
this.progressPerStep = 1.0;
37-
init();
38-
}
39-
40-
private void init() {
41-
this.task = new Task<Void>() {
42-
@Override
43-
protected Void call() {
44-
double progress = 0.0;
45-
for (int i = 0; i < inputFiles.size(); i++) {
46-
File inputFile = inputFiles.get(i);
47-
File outputFile = outputFiles.get(i);
48-
if (inputFile.exists() && inputFile.isFile() && outputFile.getName().endsWith(".pak")) {
49-
try {
50-
Files.deleteIfExists(outputFile.toPath());
51-
Files.copy(inputFile.toPath(), outputFile.toPath());
52-
} catch (IOException e) {
53-
faultingFiles.add(inputFile);
54-
}
55-
}
56-
progress += progressPerStep;
57-
updateProgress(progress, 1.0);
58-
}
59-
progress = 1.0;
60-
updateProgress(progress, 1.0);
61-
return null;
62-
}
63-
};
64-
65-
this.task.setOnSucceeded(workerStateEvent -> {
66-
if (!faultingFiles.isEmpty()) logger.error("Following files could not be copied: {}", faultingFiles);
67-
});
6833
}
6934

7035
public void transferFiles(ProgressBar progressBar) {
71-
progressBar.progressProperty().bind(this.task.progressProperty());
36+
progressBar.progressProperty().bind(this.progressProperty());
7237

73-
Thread thread = new Thread(this.task);
38+
Thread thread = new Thread(this);
7439
thread.setDaemon(true);
7540
thread.start();
7641
}
7742

78-
public Task<Void> getTask() {
79-
return this.task;
43+
@Override
44+
protected TransferTaskInformation call() throws Exception {
45+
TransferTaskInformation info = new TransferTaskInformation();
46+
double progress = 0.0;
47+
for (int i = 0; i < inputFiles.size(); i++) {
48+
File inputFile = inputFiles.get(i);
49+
File outputFile = outputFiles.get(i);
50+
if (inputFile.exists() && inputFile.isFile() && outputFile.getName().endsWith(".pak")) {
51+
try {
52+
logger.debug("outputFile {}.", (outputFile.exists()) ? "exists" : "does not exist");
53+
Files.deleteIfExists(outputFile.toPath());
54+
logger.debug("copying file from \"{}\" to \"{}\".", inputFile, outputFile);
55+
Files.copy(inputFile.toPath(), outputFile.toPath());
56+
} catch (IOException e) {
57+
info.put(inputFile, e);
58+
}
59+
}
60+
progress += progressPerStep;
61+
updateProgress(progress, 1.0);
62+
}
63+
progress = 1.0;
64+
updateProgress(progress, 1.0);
65+
return info;
8066
}
81-
8267
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.github.dunklemango.starboundmodmanager.transfer;
2+
3+
import org.apache.logging.log4j.LogManager;
4+
import org.apache.logging.log4j.Logger;
5+
6+
import java.io.File;
7+
import java.util.HashMap;
8+
import java.util.Map;
9+
10+
public class TransferTaskInformation {
11+
private static final Logger logger = LogManager.getLogger("TransferTaskInformation");
12+
private Map<File, Exception> faultingFiles;
13+
14+
public TransferTaskInformation() {
15+
faultingFiles = new HashMap<>();
16+
}
17+
18+
public void put(File key, Exception value) {
19+
if (value == null) return;
20+
this.faultingFiles.put(key, value);
21+
}
22+
23+
public void print() {
24+
if (faultingFiles.isEmpty()) {
25+
logger.debug("All files were transferred successfully.");
26+
return;
27+
}
28+
logger.error("Printing files that could not be copied to the desired location. Labeled FTTI.");
29+
faultingFiles.forEach((file, exception) -> {
30+
logger.error("[FTTI] File \"{}\" caused an error:", file, exception);
31+
});
32+
}
33+
}

0 commit comments

Comments
 (0)