-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle.kts
97 lines (74 loc) · 2.89 KB
/
build.gradle.kts
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
//----------------------------------------------------------------------------------------------------------------------
// Project Setup
//----------------------------------------------------------------------------------------------------------------------
plugins {
java
}
val zomboidjar: String by project
val zomboidjarsources: String by project
val zomboidlua: String by project
val zomboidmedia: String by project
dependencies {
implementation(files(zomboidjar))
implementation(files(zomboidjarsources))
implementation(files(zomboidlua))
implementation(files(zomboidmedia))
}
sourceSets.create("media") {
java.srcDir("media")
compileClasspath += sourceSets.main.get().compileClasspath
}
//----------------------------------------------------------------------------------------------------------------------
// Tasks
//----------------------------------------------------------------------------------------------------------------------
val projectName = if (project.hasProperty("betaBuild")) "${project.name}-beta" else project.name
val buildPath = "$buildDir/workshop/${projectName}"
val modPath = "$buildPath/Contents/mods/${projectName}"
val localPath = "${System.getProperties()["user.home"]}/Zomboid/Workshop"
val localModPath = "$localPath/${projectName}"
val buildWorkshop by tasks.registering {
group = "build"
outputs.dir("$buildDir/workshop")
doLast {
copy {
from(if (project.hasProperty("betaBuild")) "workshop/preview_beta.png" else "workshop/preview.png",
if (project.hasProperty("betaBuild")) "workshop/workshop_beta.txt" else "workshop/workshop.txt")
into(buildPath)
rename("preview_beta.png", "preview.png")
rename("workshop_beta.txt", "workshop.txt")
}
copy {
from(if (project.hasProperty("betaBuild")) "workshop/poster_beta.png" else "workshop/poster.png", "workshop/mod.info")
into(modPath)
rename("poster_beta.png", "poster.png")
}
copy {
from("media")
into("$modPath/media")
}
}
}
val localDeploy by tasks.registering {
group = "build"
outputs.dir("$localPath/${projectName}")
dependsOn(buildWorkshop)
doFirst {
if (project.hasProperty("betaBuild")) {
File("$modPath/mod.info").writeText(File("$modPath/mod.info").readText().replace("(id=.*)".toRegex(), "$1-beta"))
File("$modPath/mod.info").writeText(File("$modPath/mod.info").readText().replaceFirst("(name=.*)".toRegex(), "$1 [Beta]"))
}
}
doLast {
copy {
from(buildWorkshop.get().outputs.files)
into(localPath)
}
}
}
val localUndeploy by tasks.registering {
val localPath = "${System.getProperties()["user.home"]}/Zomboid/Workshop"
group = "build"
doLast {
delete(localDeploy.get().outputs.files)
}
}