From abc3cadf5374e5a656715cbccf1c1bb704ef8df0 Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Wed, 15 Mar 2023 13:50:54 +0800 Subject: [PATCH] Optimize Distribution --- build.gradle | 4 +-- desktop/build.gradle | 38 ++++++++++++++++++-------- docs/dist/ChineseSimplified.isl | 2 +- docs/dist/ExePacking.iss | 47 ++++++++++++++++++--------------- 4 files changed, 55 insertions(+), 36 deletions(-) diff --git a/build.gradle b/build.gradle index 6cd66135..852e4f54 100644 --- a/build.gradle +++ b/build.gradle @@ -17,12 +17,12 @@ allprojects { apply plugin: "java-library" apply plugin: "org.openjfx.javafxplugin" - version = '2.0' + version = '2.0.0' ext { // App Metadata appName = "ArkPets" appAuthor = "Harry Huang" - appCopyright = "漏 ${new Date().format('yyyy', TimeZone.getTimeZone('GMT+0:00'))} ${appAuthor}" + appCopyright = "Copyright (c) 2022-${new Date().format('yyyy', TimeZone.getTimeZone('GMT+0:00'))} ${appAuthor}" // Dependencies Version gdxVersion = '1.11.0' jnaVersion = '5.12.1' diff --git a/desktop/build.gradle b/desktop/build.gradle index b5084433..58923fcf 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -42,15 +42,14 @@ ext { osPathSep = File.pathSeparatorChar // Distribution related vars jarLibDir = "${buildDir}/libs" - jarLibName = "${project.ext.appName}-${project.version}" + jarLibName = "${project.name}-${project.version}" jlinkRuntimeDir = "${buildDir}/jlink" jlinkRuntimeImg = "${jlinkRuntimeDir}/runtime" jlinkModuleList = "java.base,java.desktop,java.management,java.scripting,jdk.unsupported,jdk.localedata,jdk.crypto.ec" jlinkLocalesList = "en-US,zh-CN" jpackageDir = "${buildDir}/jpackage" - issFile = "${project.rootDir}/doc/dist/ExePacking.iss" + issFileRel = "docs/dist/ExePacking.iss" distDir = "${buildDir}/dist" - distDirRel = "${project.name}/build/dist" distName = "${project.ext.appName}-v${project.version}" } @@ -64,12 +63,14 @@ task distJar(dependsOn: classes, type: Jar, group: 'dist') { from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } - copy { - from "${jarLibDir}/${jarLibName}.jar" - into distDir - rename "${jarLibName}.jar", "${distName}.jar" - } with jar + doLast() { + copy { + from "${jarLibDir}/${jarLibName}.jar" + into distDir + rename "${jarLibName}.jar", "${distName}.jar" + } + } } // Creates a customized Java Runtime Environment for the app. @@ -136,13 +137,28 @@ task distZip(dependsOn: jpackage, type: Zip, group: 'dist') { destinationDir file(distDir) } +// Generates a distributable EXE file for the app, using Inno Setup. +// Note that you must install Inno Setup in your environment and add it to PATH before running this task. task distExe(dependsOn: jpackage, type: Exec, group: 'dist') { workingDir project.rootDir def commands = [ "iscc", - "/O${distDirRel}", - "/F${distName}.exe", - issFile + "/Q", + issFileRel ] commandLine = commands } + +// Generates ALL kinds of distributing files. +task distAll(dependsOn: [distJar, distZip, distExe], group: 'dist') { + doLast() { + print("\tAll files were successfully generated.") + try { + delete "${buildDir}/tmp" + delete jpackageDir + delete jarLibDir + } catch (IOException e) { + print("\tUnable to delete temp files.") + } + } +} diff --git a/docs/dist/ChineseSimplified.isl b/docs/dist/ChineseSimplified.isl index 0c21ff3a..7c40848b 100644 --- a/docs/dist/ChineseSimplified.isl +++ b/docs/dist/ChineseSimplified.isl @@ -255,7 +255,7 @@ InstallingLabel= FinishedHeadingLabel=[name] 安装完成 FinishedLabelNoIcons=已在您的电脑中成功安装了 [name]。 FinishedLabel=已在您的电脑中安装了 [name],此应用程序可以通过点击快捷方式运行。 -ClickFinish=点击“完成”以退出安装向导。 +ClickFinish=点击“完成”以退出安装向导。祝您使用愉快! FinishedRestartLabel=要完成 [name] 的安装,我们必须重新启动您的电脑。您想要立即重新启动吗? FinishedRestartMessage=要完成 [name] 的安装,我们必须重新启动您的电脑。%n%n您想要立即重新启动吗? ShowReadmeCheck=是,我想查阅自述文件 diff --git a/docs/dist/ExePacking.iss b/docs/dist/ExePacking.iss index c8f92773..5f11951b 100644 --- a/docs/dist/ExePacking.iss +++ b/docs/dist/ExePacking.iss @@ -1,5 +1,6 @@ ; *** Inno Setup Script for ArkPets *** ; Documentation: https://jrsoftware.org/ishelp.php +; Download Inno Setup: https://jrsoftware.org/isdl.php #define MyAppName "ArkPets" #define MyAppVersion "2.0.0" @@ -7,27 +8,28 @@ #define MyAppURL "https://arkpets.harryh.cn/" [Setup] -; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. -; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) -AppId ={{213DB689-8F8A-4DEA-BE79-545FAD7769A6} -AppName ={#MyAppName} -AppVersion={#MyAppVersion} -AppVerName="{#MyAppName} v{#MyAppVersion}" -AppPublisher ={#MyAppPublisher} -AppPublisherURL ={#MyAppURL} -AppSupportURL ={#MyAppURL} -AppUpdatesURL ={#MyAppURL} -Compression =lzma/ultra -DefaultDirName =/{#MyAppName} -DefaultGroupName={#MyAppName} -AllowNoIcons =yes +; WARN: The value of AppId uniquely identifies this app. Do not use the same AppId value in installers for other apps. +; (To generate a new GUID, click Tools | Generate GUID inside the Inno Setup IDE.) +AppCopyright = Copyright (C) 2022-2023 {#MyAppPublisher} +AppId ={{213DB689-8F8A-4DEA-BE79-545FAD7769A6} +AppName ={#MyAppName} +AppVersion ={#MyAppVersion} +AppVerName ="{#MyAppName} v{#MyAppVersion}" +AppPublisher ={#MyAppPublisher} +AppPublisherURL ={#MyAppURL} +AppSupportURL ={#MyAppURL} +AppUpdatesURL ={#MyAppURL} +Compression =lzma/max +DefaultDirName =/{#MyAppName} +DefaultGroupName ={#MyAppName} +AllowNoIcons =yes ; Remove the following line to run in administrative install mode (install for all users.) -PrivilegesRequired=lowest -OutputBaseFilename={#MyAppName}-Setup -OutputDir =..\..\desktop\build\dist -SetupIconFile =..\..\assets\icon.ico -SolidCompression =yes -WizardStyle =modern +PrivilegesRequired =lowest +OutputBaseFilename ={#MyAppName}-v{#MyAppVersion}-Setup +OutputDir =..\..\desktop\build\dist +SetupIconFile =..\..\assets\icon.ico +SolidCompression =yes +WizardStyle =modern [Languages] Name: "chinese"; MessagesFile: "ChineseSimplified.isl" @@ -35,7 +37,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl" Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl" [Tasks] -Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}" [Files] Source: "..\..\desktop\build\jpackage\{#MyAppName}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs @@ -46,13 +48,14 @@ Source: "..\..\desktop\build\jpackage\LICENSE"; DestDir: "{app}"; Flags: ignorev Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppName}.exe"; WorkingDir: "{app}" Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}" Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" -;Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppName}.exe"; Tasks: desktopicon +Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppName}.exe"; Tasks: desktopicon; WorkingDir: "{app}" [Run] Filename: "{app}\{#MyAppName}.exe"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent [UninstallDelete] Type: files; Name: "{app}\ArkPetsCustom.config" +Type: files; Name: "{app}\models_data.json" Type: filesandordirs; Name: "{app}\temp" Type: filesandordirs; Name: "{app}\models" Type: filesandordirs; Name: "{app}\models_enemies"