-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from edvin/master
pull latest
- Loading branch information
Showing
11 changed files
with
745 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,57 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
|
||
## [Unreleased] | ||
## [10.0.14-SNAPSHOT] | ||
|
||
- `include-extensions` was consulted too early, leaving the matched files out of the manifest | ||
|
||
## [1.0.13] - 2016-09-12 | ||
|
||
- Support for fully customizable update UI, see (https://github.com/edvin/fxlauncher-custom-ui) | ||
- Basic Authentication support for manifest url (via https://user:pass@host/path) | ||
- Added `--include-extensions` as a comma separated list of filename extensions to include of other resources from the build dir. By default it always includes `jar,war`. | ||
- Fixed bug: If updating from a manifest with no timestamp (pre 1.0.11), new version was considered older, so no upgrade was performed | ||
|
||
## [1.0.12] | ||
|
||
### Changed | ||
|
||
- Added `include-extensions` parameter to CreateManaifest. By default only `jar` and `war` files are included, add more extensions via this comma separated list. | ||
- Added --accept-downgrade=<true|false> parameter to CreateManifest. Default is to not accept downgrades (server version is older than local version) | ||
- Artifacts in subfolders gets correct path delimiter in app manifest for Windows | ||
|
||
## [1.0.11] | ||
|
||
### Changed | ||
|
||
- Progress window is now closed after primaryStage is shown instead of right before app.start() is called | ||
|
||
## [1.0.10] - 2016-05-07 | ||
|
||
### Changed | ||
|
||
- Add optional `--cache-dir` program parameter `cacheDir` and manifest entry (https://github.com/edvin/fxlauncher/issues/9) | ||
- Add / if missing from base url (https://github.com/edvin/fxlauncher/issues/6) | ||
|
||
## [1.0.9] - 2016-03-14 | ||
|
||
### Added | ||
|
||
- App manifest location can be given as command line parameter (https://github.com/edvin/fxlauncher/issues/3) | ||
|
||
## [1.0.8] - 2016-03-02 | ||
|
||
### Added | ||
- OS specific resources | ||
|
||
- Support for manifest configurable parameters (https://github.com/edvin/fxlauncher/issues/2) | ||
|
||
## [1.0.7] - 2016-02-20 | ||
|
||
### Added | ||
- Support for platform specific resources | ||
|
||
### Changed | ||
- Parameters are now passed to the Application instance (https://github.com/edvin/fxlauncher/issues/1) | ||
|
||
## [1.0.6] - 2016-02-10 | ||
- First feature complete release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,105 @@ | ||
package fxlauncher; | ||
|
||
import com.sun.javafx.application.ParametersImpl; | ||
|
||
import javax.xml.bind.JAXB; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.nio.file.*; | ||
import java.nio.file.attribute.BasicFileAttributes; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
public class CreateManifest { | ||
private static ArrayList<String> includeExtensions = new ArrayList<>(); | ||
|
||
static { | ||
includeExtensions.addAll(Arrays.asList("jar", "war")); | ||
} | ||
|
||
public static void main(String[] args) throws IOException { | ||
URI baseURI = URI.create(args[0]); | ||
String launchClass = args[1]; | ||
Path appPath = Paths.get(args[2]); | ||
|
||
String cacheDir = null; | ||
Boolean acceptDowngrade = null; | ||
String parameters = null; | ||
|
||
if (args.length > 3) { | ||
// Parse named parameters | ||
List<String> rawParams = new ArrayList<>(); | ||
rawParams.addAll(Arrays.asList(args).subList(3, args.length)); | ||
ParametersImpl params = new ParametersImpl(rawParams); | ||
Map<String, String> named = params.getNamed(); | ||
|
||
if (named != null) { | ||
// Configure cacheDir | ||
if (named.containsKey("cache-dir")) | ||
cacheDir = named.get("cache-dir"); | ||
|
||
// Configure acceptDowngrade | ||
if (named.containsKey("accept-downgrade")) | ||
acceptDowngrade = Boolean.valueOf(named.get("accept-downgrade")); | ||
|
||
// Add additional files with these extensions to manifest | ||
if (named.containsKey("include-extensions")) | ||
includeExtensions.addAll( | ||
Arrays.stream(named.get("include-extensions").split(",")) | ||
.filter(s -> s != null && !s.isEmpty()) | ||
.collect(Collectors.toList()) | ||
); | ||
} | ||
|
||
// Append the rest as manifest parameters | ||
StringBuilder rest = new StringBuilder(); | ||
for (String raw : params.getRaw()) { | ||
if (raw.startsWith("--cache-dir=")) continue; | ||
if (raw.startsWith("--accept-downgrade=")) continue; | ||
if (raw.startsWith("--include-extensions=")) continue; | ||
if (rest.length() > 0) rest.append(" "); | ||
rest.append(raw); | ||
} | ||
|
||
// Add the raw parameter string to the manifest | ||
if (rest.length() > 0) | ||
parameters = rest.toString(); | ||
} | ||
|
||
FXManifest manifest = create(baseURI, launchClass, appPath); | ||
if (cacheDir != null) manifest.cacheDir = cacheDir; | ||
if (acceptDowngrade != null) manifest.acceptDowngrade = acceptDowngrade; | ||
if (parameters != null) manifest.parameters = parameters; | ||
|
||
JAXB.marshal(manifest, appPath.resolve("app.xml").toFile()); | ||
} | ||
|
||
public static FXManifest create(URI baseURI, String launchClass, Path appPath) throws IOException { | ||
FXManifest manifest = new FXManifest(); | ||
manifest.ts = System.currentTimeMillis(); | ||
manifest.uri = baseURI; | ||
manifest.launchClass = launchClass; | ||
|
||
Files.walkFileTree(appPath, new SimpleFileVisitor<Path>() { | ||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { | ||
if (!Files.isDirectory(file) && file.toString().endsWith(".jar") && !file.getFileName().toString().startsWith("fxlauncher")) | ||
if (!Files.isDirectory(file) && shouldIncludeInManifest(file) && !file.getFileName().toString().startsWith("fxlauncher")) | ||
manifest.files.add(new LibraryFile(appPath, file)); | ||
return FileVisitResult.CONTINUE; | ||
} | ||
}); | ||
|
||
return manifest; | ||
} | ||
|
||
|
||
private static boolean shouldIncludeInManifest(Path file) { | ||
String filename = file.getFileName().toString(); | ||
for (String ext : includeExtensions) { | ||
if (filename.toLowerCase().endsWith(String.format(".%s", ext.toLowerCase()))) return true; | ||
} | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package fxlauncher; | ||
|
||
import javafx.geometry.Insets; | ||
import javafx.scene.Parent; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.ProgressBar; | ||
import javafx.scene.control.ProgressIndicator; | ||
import javafx.scene.layout.StackPane; | ||
import javafx.scene.layout.VBox; | ||
import javafx.stage.Stage; | ||
|
||
public class DefaultUIProvider implements UIProvider { | ||
private ProgressBar progressBar; | ||
|
||
public Parent createLoader() { | ||
StackPane root = new StackPane(new ProgressIndicator()); | ||
root.setPrefSize(200, 80); | ||
root.setPadding(new Insets(10)); | ||
return root; | ||
} | ||
|
||
public Parent createUpdater(FXManifest manifest) { | ||
progressBar = new ProgressBar(); | ||
progressBar.setStyle(manifest.progressBarStyle); | ||
|
||
Label label = new Label(manifest.updateText); | ||
label.setStyle(manifest.updateLabelStyle); | ||
|
||
VBox wrapper = new VBox(label, progressBar); | ||
wrapper.setStyle(manifest.wrapperStyle); | ||
|
||
return wrapper; | ||
} | ||
|
||
public void updateProgress(double progress) { | ||
progressBar.setProgress(progress); | ||
} | ||
|
||
public void init(Stage stage) { | ||
|
||
} | ||
} |
Oops, something went wrong.