Skip to content

Commit

Permalink
feat: 版本更新数据
Browse files Browse the repository at this point in the history
  • Loading branch information
unclezs committed Jun 12, 2021
1 parent 2a081f0 commit 017811f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<img src="https://img.shields.io/github/workflow/status/unclezs/jfx-launcher/Java%20CI%20with%20Gradle" alt="gradle build"/>
</a>
<a href="https://openjdk.java.net/">
<img src="https://img.shields.io/badge/version-1.1.6-blue" alt="版本"/>
<img src="https://img.shields.io/badge/version-1.1.7-blue" alt="版本"/>
</a>
<a href="https://github.com/unclezs/jfx-launcher/blob/main/LICENSE">
<img src="https://img.shields.io/github/license/unclezs/jfx-launcher?color=%2340C0D0&label=License" alt="GitHub license"/>
Expand All @@ -30,14 +30,14 @@
<dependency>
<groupId>com.unclezs</groupId>
<artifactId>jfx-launcher</artifactId>
<version>1.1.6</version>
<version>1.1.7</version>
</dependency>
```

### gradle

```groovy
implementation "com.unclezs:jfx-launcher:1.1.6"
implementation "com.unclezs:jfx-launcher:1.1.7"
```

## 原理
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app.version=1.1.6
app.version=1.1.7
org.gradle.jvmargs=-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError
org.gradle.parallel=true
org.gradle.caching=false
Expand Down
23 changes: 11 additions & 12 deletions src/main/java/com/unclezs/jfx/launcher/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class Launcher extends Application {
*/
public static final String CHANGE_LOG_ARG_NAME = "changeLog";
public static final String VERSION_ARG_NAME = "version";
public static final String HAS_NEW = "hasNew";
private Stage launcherStage;
private Manifest manifest;
private LauncherView ui;
Expand Down Expand Up @@ -68,9 +69,7 @@ public void startApplication() throws Exception {
Application app = (Application) appClass.getConstructor().newInstance();
app.init();
Stage appStage = new Stage();
if (newVersion) {
appStage.setUserData(Map.of(CHANGE_LOG_ARG_NAME, manifest.getChangeLog(), VERSION_ARG_NAME, manifest.getVersion()));
}
appStage.setUserData(Map.of(CHANGE_LOG_ARG_NAME, manifest.getChangeLog(), VERSION_ARG_NAME, manifest.getVersion(), HAS_NEW, newVersion));
ui.setPhase("正在启动应用...");
app.start(appStage);
launcherStage.close();
Expand Down Expand Up @@ -169,19 +168,19 @@ private ClassLoader loadLibraries() {
List<Resource> resources = manifest.resolveResources();
// 本地库
resources.stream()
.filter(resource -> Resource.Type.NATIVE == resource.getType())
.map(resource -> Path.of(".", resource.getPath()).toFile().getAbsolutePath())
.forEach(System::load);
.filter(resource -> Resource.Type.NATIVE == resource.getType())
.map(resource -> Path.of(".", resource.getPath()).toFile().getAbsolutePath())
.forEach(System::load);
// 系统库
resources.stream()
.filter(resource -> Resource.Type.NATIVE_SYS == resource.getType())
.map(Resource::getPath)
.forEach(System::loadLibrary);
.filter(resource -> Resource.Type.NATIVE_SYS == resource.getType())
.map(Resource::getPath)
.forEach(System::loadLibrary);
// 加载依赖模块
Path[] modules = resources.stream()
.filter(resource -> Resource.Type.JAR == resource.getType())
.map(Resource::toLocalPath)
.toArray(Path[]::new);
.filter(resource -> Resource.Type.JAR == resource.getType())
.map(Resource::toLocalPath)
.toArray(Path[]::new);
ModuleLoader moduleLoader = new ModuleLoader(modules, manifest.getLaunchModule());
manifest.getModuleOptions().forEach(moduleLoader::add);
ClassLoader classLoader = moduleLoader.getClassLoader();
Expand Down

0 comments on commit 017811f

Please sign in to comment.