This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
forked from quanticc/lawena-recording-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
313 lines (275 loc) · 9.85 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
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'distribution'
sourceCompatibility = 1.7
targetCompatibility = 1.7
def mainClassName = 'com.github.lawena.app.Main'
def buildtime = new Date().format("yyyyMMddHHmmss")
defaultTasks 'clean', 'run'
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7'
}
}
repositories {
jcenter()
}
dependencies {
compile 'com.threerings:getdown:1.4'
compile 'net.lingala.zip4j:zip4j:1.3.2'
compile 'net.sf.jopt-simple:jopt-simple:4.7'
compile 'com.google.code.gson:gson:2.3'
compile 'org.slf4j:slf4j-api:1.7.7'
compile 'org.slf4j:jul-to-slf4j:1.7.7'
compile 'ch.qos.logback:logback-core:1.1.2'
compile 'ch.qos.logback:logback-classic:1.1.2'
testCompile 'junit:junit:4.10'
}
test {
testLogging.showStandardStreams = true
}
sourceSets {
main {
resources {
exclude '**/*.db'
}
}
}
try {
new ByteArrayOutputStream().withStream { execOS ->
exec {
executable = 'git'
args = [ 'describe', '--tags', '--always' ]
standardOutput = execOS
}
def describe = execOS.toString().trim()
version describe
}
} catch (Exception e) {
println "Could not retrieve version number"
}
jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
archiveName = 'lawena.jar'
destinationDir = null
def implVersion = (version == null ? "v4" : version)
manifest {
attributes (
'Main-Class': mainClassName,
'Implementation-Title': 'Lawena Recording Tool',
'Implementation-Version': implVersion,
'Implementation-Build': buildtime,
'SplashScreen-Image': 'splash.png'
)
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
}
task run(type: JavaExec, dependsOn: 'classes') {
description "Runs this project as a JVM application"
main mainClassName
classpath project.sourceSets.main.runtimeClasspath
}
// Deployment tasks
// 1. Configure distributions
distributions {
main {}
stable {
contents {
from { ['src/main/dist', 'build/getdown/stable', 'build/gradlew'] }
exclude "**/getdown.*.txt"
duplicatesStrategy = 'exclude'
}
}
snapshot {
contents {
from { ['src/main/dist', 'build/getdown/snapshot', 'build/gradlew'] }
exclude "**/getdown.*.txt"
duplicatesStrategy = 'exclude'
}
}
}
// 2. Prepare executables and classpath related files
task buildLauncher {
inputs.file 'launcher/lawena-launcher.xml'
outputs.file 'launcher/lawena.exe'
doLast {
exec {
workingDir 'launcher'
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'cmd', '/c', launch4jPath, 'lawena-launcher.xml'
} else {
commandLine launch4jPath, 'lawena-launcher.xml'
}
}
}
}
task copyLauncher(type: Copy, dependsOn: 'buildLauncher') {
from 'launcher/lawena.exe'
into 'src/main/dist'
}
task copyLauncherNew(type: Copy, dependsOn: 'copyLauncher') {
from 'launcher/lawena.exe'
into 'src/main/dist/lawena/code'
rename 'lawena.exe', 'lawena-new.exe'
}
task buildExecutable {
inputs.file 'launcher/lawena-start.xml'
outputs.file 'launcher/lawena-start.exe'
doLast {
exec {
workingDir 'launcher'
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'cmd', '/c', launch4jPath, 'lawena-start.xml'
} else {
commandLine launch4jPath, 'lawena-start.xml'
}
}
}
}
task copyGetdownClient(type: Copy, dependsOn: 'copyLauncherNew') {
from 'launcher/getdown-client.jar'
into 'src/main/dist/lawena'
}
task copyGetdownClientNew(type: Copy, dependsOn: 'copyGetdownClient') {
from 'launcher/getdown-client.jar'
into 'src/main/dist/lawena/code'
rename 'getdown-client.jar', 'getdown-client-new.jar'
}
task copyMainJar(type: Copy, dependsOn: 'jar') {
from 'lawena.jar'
into 'src/main/dist/lawena'
}
task copyGradleLauncher(type: Copy) {
from(projectDir) {
include 'gradlew'
include 'gradlew.bat'
}
from 'gradle'
into 'build/gradlew/lawena'
}
task copyLibs(dependsOn: ['copyGetdownClientNew', 'copyMainJar', 'copyGradleLauncher']) {
description "Copy all required executable and build files"
}
// 3. Pack additional resources into jar files
task packResources(type: Zip) {
archiveName = 'lwrtresources.jar'
destinationDir = file('src/main/dist/lawena')
from projectDir
includes = ['lwrt/tf/config/cfg/**', 'lwrt/tf/hud/**', 'lwrt/csgo/config/cfg/**', 'lwrt/tf/default.json', 'lwrt/csgo/default.json']
}
task packVpks(type: Zip) {
archiveName = 'lwrtvpks.jar'
destinationDir = file('src/main/dist/lawena')
from projectDir
includes = ['lwrt/tf/default/**', 'lwrt/tf/custom/**']
}
task packWinBatches(type: Zip) {
archiveName = 'lwrtwinstuff.jar'
destinationDir = file('src/main/dist/lawena')
from projectDir
includes = ['lwrt/tools/**', '*.dll']
}
task packSkyboxes(type: Zip) {
archiveName = 'skybox.jar'
destinationDir = file('src/main/dist/lawena')
from projectDir
includes = ['lwrt/tf/skybox/**']
excludes = ['**/*.db']
}
task pack(dependsOn: ['packResources', 'packVpks', 'packWinBatches', 'packSkyboxes']) {
description "Create packages of application resources"
}
// 4. Create deployment-ready archives for each distribution and deploy them
['stable', 'snapshot'].each { def distName ->
def DistName = distName.substring(0, 1).toUpperCase() + distName.substring(1)
def latestFolder = 'latest'
tasks.create(name: "setup${DistName}Dist", dependsOn: ['copyLibs', 'pack']) {
description "Prepares deployment descriptor for packaging ${distName} distribution"
def min = file("src/${distName}/dist/lawena/getdown.min.txt")
def getdown = file("build/getdown/${distName}/lawena/getdown.txt")
inputs.file min
outputs.file getdown
getdown.getParentFile().mkdirs()
getdown.withWriter { w ->
min.eachLine { line ->
w << line.replaceAll('<version>', buildtime).replaceAll('<channel>', distName) + System.getProperty("line.separator")
}
}
}
tasks.create(name: "build${DistName}Dist", dependsOn: ["setup${DistName}Dist", "${distName}DistZip"]) {}
tasks.create(name: "setup${DistName}Deploy", dependsOn: ["build${DistName}Dist", "cleanInstall${DistName}Dist", "install${DistName}Dist"]) {
description "Prepares deployment descriptor for deploying ${distName} distribution"
def base = file("src/${distName}/dist/lawena/getdown.base.txt")
def getdown = file("build/getdown/${distName}/lawena/getdown.full.txt")
inputs.file base
outputs.file getdown
getdown.getParentFile().mkdirs()
getdown.withWriter { w ->
base.eachLine { line ->
w << line.replaceAll('<version>', buildtime).replaceAll('<channel>', distName) + System.getProperty("line.separator")
}
}
}
tasks.create(name: "deploy${DistName}", dependsOn: "setup${DistName}Deploy") {
description "Deploys ${distName} distribution to a local directory"
doLast {
def sourceTree = fileTree("build/install/lawena-${distName}/lawena")
def stampDestFile = file("${deployDir}/${distName}/${buildtime}")
def latestDestFile = file("${deployDir}/${distName}/${latestFolder}")
copy {
from sourceTree
into stampDestFile
}
copy {
from file("build/getdown/${distName}/lawena/getdown.full.txt")
into file("${deployDir}/${distName}/${buildtime}")
rename "getdown.full.txt", "getdown.txt"
}
javaexec {
main 'com.threerings.getdown.tools.Digester'
classpath 'launcher/getdown-client.jar'
args = [stampDestFile]
}
copy {
from sourceTree
into latestDestFile
}
copy {
from file("build/getdown/${distName}/lawena/getdown.full.txt")
into file("${deployDir}/${distName}/${latestFolder}")
rename "getdown.full.txt", "getdown.txt"
}
javaexec {
main 'com.threerings.getdown.tools.Digester'
classpath 'launcher/getdown-client.jar'
args = [latestDestFile]
}
def output = file("${deployDir}/${distName}/buildlist.txt")
output.append "${buildtime};${version}\n"
}
}
tasks.create(name: "diffDeploy${DistName}", dependsOn: "deploy${DistName}") {
description "Deploys and creates diff patch files for ${distName} distribution"
doLast {
def buildlist = []
file("${deployDir}/${distName}").eachDirMatch(~/^[0-9]+$/) { dir ->
buildlist.add dir.name
}
buildlist.sort(java.text.Collator.instance)
def latest = buildlist[buildlist.size() - 1]
buildlist = buildlist - latest
buildlist.each { s ->
println "Creating diff between ${s} and latest build ${latest}"
javaexec {
main 'com.threerings.getdown.tools.Differ'
classpath 'launcher/getdown-client.jar'
args = ['-verbose', file("${deployDir}/${distName}/${latestFolder}"), file("${deployDir}/${distName}/${s}")]
}
}
}
}
}