Skip to content

Commit

Permalink
Optimize Distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
isHarryh committed Mar 15, 2023
1 parent 093b0cf commit abc3cad
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 36 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
38 changes: 27 additions & 11 deletions desktop/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}

Expand All @@ -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.
Expand Down Expand Up @@ -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.")
}
}
}
2 changes: 1 addition & 1 deletion docs/dist/ChineseSimplified.isl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ InstallingLabel=
FinishedHeadingLabel=[name] 安装完成
FinishedLabelNoIcons=已在您的电脑中成功安装了 [name]。
FinishedLabel=已在您的电脑中安装了 [name],此应用程序可以通过点击快捷方式运行。
ClickFinish=点击“完成”以退出安装向导。
ClickFinish=点击“完成”以退出安装向导。祝您使用愉快!
FinishedRestartLabel=要完成 [name] 的安装,我们必须重新启动您的电脑。您想要立即重新启动吗?
FinishedRestartMessage=要完成 [name] 的安装,我们必须重新启动您的电脑。%n%n您想要立即重新启动吗?
ShowReadmeCheck=是,我想查阅自述文件
Expand Down
47 changes: 25 additions & 22 deletions docs/dist/ExePacking.iss
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
; *** 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"
#define MyAppPublisher "Harry Huang"
#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"
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
Expand All @@ -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"

0 comments on commit abc3cad

Please sign in to comment.