-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.gradle
More file actions
205 lines (170 loc) · 5.81 KB
/
Copy pathbuild.gradle
File metadata and controls
205 lines (170 loc) · 5.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
id 'java'
id 'application'
id 'org.javamodularity.moduleplugin' version '1.8.12'
id 'org.openjfx.javafxplugin' version '0.1.0'
id 'org.beryx.jlink' version '3.0.1'
}
group 'io.infinitytools'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
String appName
String projectUrl
// Defines whether the resulting binary should include debugging symbols
boolean debugBuild = true
ext {
junitVersion = '5.10.0'
// App version is stored in a global properties file
Properties _props = new Properties()
_props.load(file("src/main/resources/globals.properties").newDataInputStream())
project.version = _props.getProperty("version")
appName = _props.getProperty("name", "WeiduInstallTool")
projectUrl = _props.getProperty("project", "https://github.com/InfinityTools/WeiduInstallTool")
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
// Workaround for accessing GitHub API
final String TLS_PROTOCOL = "-Djdk.tls.client.protocols=TLSv1.2"
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.debugOptions.setDebugLevel("source,lines,vars")
options.debug = debugBuild
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
jvmArgs += TLS_PROTOCOL
}
tasks.withType(JavaExec).configureEach {
jvmArgs += TLS_PROTOCOL
enableAssertions = true
}
application {
mainModule = 'io.infinitytools.wit'
mainClass = 'io.infinitytools.wit.WeiduInstallTool'
}
javafx {
version = "21.+"
modules = ['javafx.controls', 'javafx.fxml']
}
dependencies {
// https://mvnrepository.com/artifact/org.json/json
implementation group: 'org.json', name: 'json', version: '20231013'
// https://tinylog.org/v2/download/
implementation group: 'org.tinylog', name: 'tinylog-api', version: '2.6.2'
implementation group: 'org.tinylog', name: 'tinylog-impl', version: '2.6.2'
// https://mvnrepository.com/artifact/org.apache.commons/commons-text
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.11.0'
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}
test {
useJUnitPlatform()
}
String distFolder = "distribution"
jlink {
imageZip.fileValue(project.file("${layout.buildDirectory}/distributions/app-${javafx.platform.classifier}.zip"))
addOptions('--compress', 'zip-6', '--no-header-files', '--no-man-pages')
if (!debugBuild) {
addOptions('--strip-debug')
}
addExtraDependencies("javafx")
launcher {
name = "${appName}"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
noConsole = true
}
}
jpackage {
outputDir = distFolder
resourceDir = file("${projectDir}/buildres/${getOsName()}")
jvmArgs = [
TLS_PROTOCOL
]
installerOptions = [
"--verbose",
"--copyright", "Copyright © 2023 Argent77",
"--description", "A graphical front end for WeiDU.",
]
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
installerType = "exe"
icon = "${resourceDir}/WeiduInstallTool.ico"
installerOptions.addAll([
"--file-associations", "${resourceDir}/open_with.properties",
"--win-dir-chooser",
"--win-per-user-install",
"--win-shortcut",
"--win-shortcut-prompt",
"--win-menu",
"--about-url", "${projectUrl}"
])
} else if (Os.isFamily(Os.FAMILY_MAC)) {
// macOS installer requires a version number >= 1.0.0
appVersion = project.version.toString().startsWith("0.") ? "1.0.0" : project.version
installerType = "pkg"
icon = "${resourceDir}/wit.icns"
installerOptions.addAll([
"--mac-package-name", "${appName}",
"--file-associations", "${resourceDir}/open_with.properties"
])
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
// Unix check must be performed AFTER macOS check since it includes macOS check as well
icon = "${projectDir}/src/main/resources/io/infinitytools/wit/icons/icon/256x256.png"
// Build both deb and rpm packages
// installerType = "rpm"
installerOptions.addAll([
"--file-associations", "${resourceDir}/open_with.properties",
"--linux-rpm-license-type", "Apache-2.0",
"--linux-menu-group", "Games",
"--linux-app-category", "games",
"--linux-shortcut",
])
}
}
}
// Creates a portable zip archive from the jpackage image resources.
tasks.register('portableZip', Zip) {
dependsOn ':jpackageImage'
archiveFileName = "${appName}-${version}-portable-${getOsName()}.zip"
destinationDirectory = layout.buildDirectory.dir(distFolder)
String appFolderName = appName
if (Os.isFamily(Os.FAMILY_MAC)) {
appFolderName += ".app"
}
from(layout.buildDirectory.dir("${distFolder}/${appName}")) {
into appFolderName
}
}
// Creates a portable gzip-compressed tar archive from the jpackage image resources.
tasks.register('portableTar', Tar) {
dependsOn ':jpackageImage'
archiveFileName = "${appName}-${version}-portable-${getOsName()}.tar.gz"
destinationDirectory = layout.buildDirectory.dir(distFolder)
compression = Compression.GZIP
String appFolderName = appName
if (Os.isFamily(Os.FAMILY_MAC)) {
appFolderName += ".app"
}
from(layout.buildDirectory.dir("${distFolder}/${appFolderName}")) {
into appFolderName
}
}
// Returns a short identifier string for the current operating system that is used throughout the project.
static String getOsName() {
String platform
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
platform = "windows"
} else if (Os.isFamily(Os.FAMILY_MAC)) {
platform = "macos"
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
platform = "linux"
} else {
platform = "unknown"
}
return platform
}