This repository has been archived by the owner on Jul 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
158 lines (125 loc) · 4.39 KB
/
build.gradle
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
plugins {
id "java"
id "application"
}
group "me.tagavari"
version "3.4.1"
repositories {
mavenCentral()
}
dependencies {
//SQLite JDBC - Database library
implementation "org.xerial:sqlite-jdbc:3.36.0.3"
//jOOQ - Database library
implementation "org.jooq:jooq:3.15.2"
//Sentry - Crash reporting library
implementation "io.sentry:sentry:5.1.2"
//SLF4J - Logging library
//implementation "org.slf4j:slf4j-nop:1.7.30"
//Jackson YAML data format - YAML parser
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.12.5"
//Commonmark Java - Markdown parser
implementation "org.commonmark:commonmark:0.18.0"
//JavaWebsocket - WebSocket library
implementation "org.java-websocket:Java-WebSocket:1.5.2"
if(System.getProperty("os.arch") == "aarch64") {
implementation fileTree("lib-applesilicon") { include "*.jar" }
} else {
implementation fileTree("lib-intel") { include "*.jar" }
}
}
task installConnectAuth(type: Exec) {
workingDir "connectauth"
commandLine "npm", "install"
}
task buildConnectAuth(type: Exec) {
dependsOn installConnectAuth
workingDir "connectauth"
commandLine "npm", "run", "build"
}
task copyToLib(type: Copy) {
from configurations.default
into jar.destinationDirectory.asFile.get()
}
/* task jlink(type: Exec) {
final String jDeps = "java.base,java.desktop,java.logging,java.sql,java.xml,java.datatransfer,java.compiler,jdk.unsupported,java.naming,jdk.crypto.ec,jdk.httpserver"
inputs.property("jlink.jdeps", jDeps)
outputs.dir("${buildDir}/java-runtime")
doFirst {
delete "${buildDir}/java-runtime"
}
commandLine "${System.properties."java.home"}/bin/jlink",
"--no-header-files",
"--no-man-pages",
"--strip-debug",
"--compress=2",
"--add-modules", jDeps,
"--output", "${buildDir}/java-runtime"
} */
task jpackage(type: Exec) {
dependsOn ordered("clean", "build", "copyToLib")
final String jDeps = "java.base,java.desktop,java.logging,java.sql,java.xml,java.datatransfer,java.compiler,jdk.unsupported,java.naming,jdk.crypto.ec,jdk.httpserver"
inputs.dir(jar.destinationDirectory.asFile.get())
//inputs.dir("${buildDir}/java-runtime")
outputs.dir("AirMessage.app")
doFirst {
delete "AirMessage.app"
}
commandLine "${System.properties."java.home"}/bin/jpackage",
"--name", "AirMessage",
"--app-version", version,
"--input", jar.destinationDirectory.asFile.get(),
"--main-jar", jar.archiveFileName.get(),
"--main-class", "me.tagavari.airmessageserver.server.Main",
"--type", "app-image",
"--java-options", "-XstartOnFirstThread",
"--add-modules", jDeps,
"--mac-package-identifier", "me.tagavari.airmessageserver",
"--mac-package-name", "AirMessage",
"--mac-package-signing-prefix", "airmessage",
// "--mac-sign",
// "--mac-signing-key-user-name", "Mac Developer: Developer Name (DUCNFCN445)",
"--icon", "AirMessage.icns"
}
task configurePlist(type: Exec) {
mustRunAfter jpackage
inputs.dir("AirMessage.app")
outputs.file("AirMessage.app/Contents/Info.plist")
commandLine "plutil", "-insert", "LSUIElement", "-string", "True", "AirMessage.app/Contents/Info.plist"
doLast {
exec {
commandLine "plutil", "-insert", "NSAppTransportSecurity", "-xml", "<dict><key>NSAllowsLocalNetworking</key><true/><key>NSAllowsArbitraryLoads</key><true/></dict>", "AirMessage.app/Contents/Info.plist"
}
}
}
task publish {
dependsOn ordered("jpackage", "configurePlist")
}
task buildAndRun(type: Exec) {
dependsOn publish
commandLine "AirMessage.app/Contents/MacOS/AirMessage"
}
application {
mainClassName = "me.tagavari.airmessageserver.server.Main"
applicationDefaultJvmArgs = ["-XstartOnFirstThread"]
}
run {
args = ["-debug"]
}
def ordered(String... dependencyPaths) {
def dependencies = dependencyPaths.collect{ tasks.getByPath(it) }
for(int i = 0; i < dependencies.size() - 1; i++) {
dependencies[i + 1].mustRunAfter(dependencies[i])
}
return dependencies
}
task printVersionName {
doLast {
println version
}
}
task printJarName {
doLast {
println jar.archiveFileName.get()
}
}