-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle.kts
164 lines (135 loc) · 4.63 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
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
import org.jetbrains.kotlin.com.google.gson.Gson
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
val modID = "MarisaContinued"
val jarFile = "$buildDir/libs/${modID}.jar"
val changelog = File("docs/changelog/changelog.md").readText()
val changeBBCode = File("docs/changelog/changelog.bbcode").readText()
val changeSts = File("docs/changelog/changelog.sts.txt").readText()
val userSteamDir = property("userSteamDir") ?: throw error("userSteamDir is not set")
val gameDir = "$userSteamDir/common/SlayTheSpire"
/** [store link](https://store.steampowered.com/app/646570/Slay_the_Spire/) */
val gameSteamId = 646570
/** [workshop link](https://steamcommunity.com/sharedfiles/filedetails?id=1605833019) */
val baseModId = 1605833019
/** [workshop link](https://steamcommunity.com/sharedfiles/filedetails?id=1605060445) */
val modTheSpireId = 1605060445
/** [workshop link](https://steamcommunity.com/sharedfiles/filedetails?id=2902980404) */
val marisaModId = 2902980404
val workShopDir = "$userSteamDir/workshop/content/$gameSteamId"
val modTheSpireDir = "$workShopDir/$modTheSpireId"
val basemodDir = "$workShopDir/$baseModId"
println(
"""
userSteamDir: $userSteamDir
gameDir: $gameDir
basemodDir: $basemodDir
modTheSpireDir: $modTheSpireDir
""".trimIndent()
)
buildscript {
repositories { mavenCentral() }
dependencies {
classpath(kotlin("gradle-plugin", version = "1.3.31"))
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlin {
sourceSets.all {
languageSettings {
languageVersion = "2.0"
}
}
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}
plugins {
application
java
kotlin("jvm") version "2.0.0"
}
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
implementation(kotlin("reflect"))
implementation(kotlin("stdlib-jdk8"))
compileOnly("com.google.code.gson:gson:2.10.1")
compileOnly(files("$gameDir/desktop-1.0.jar"))
compileOnly(fileTree(modTheSpireDir))
compileOnly(fileTree(basemodDir))
}
sourceSets {
main {
kotlin {
srcDir("src/main/kotlin")
}
resources {
srcDir("src/main/resources")
exclude("**/*.ts", "**/deno.*", "schemas/**")
}
}
}
@Suppress("PropertyName", "LongLine")
data class ModTheSpire(
val modid: String,
val name: String = "Marisa: Continued (霧雨 魔理沙)",
val description: String = "Adds Marisa (霧雨 魔理沙) from Touhou Project as a new playable character.",
val version: String,
val sts_version: String = "12-01-2022",
val mts_version: String = "3.30.0",
val author_list: List<String> = listOf("Flynn", "Hell", "Hohner257", "Samsara", "scarf005"),
val credits: String = "Original mod: https://steamcommunity.com/sharedfiles/filedetails/?id=1614104912",
val dependencies: List<String> = listOf("basemod"),
)
data class Config(
val steamPublishedID: Long = 2902980404,
val title: String = "Marisa: Continued",
val description: String = File("docs/workshop.bbcode").readText(),
val visibility: String = "public",
val changeNote: String,
val tags: List<String> = listOf(
"Touhou", "Character", "Marisa", "Kirisame Marisa",
"English", "Simplified Chinese", "Traditional Chinese", "French", "Korean", "Japanese"
),
)
val gson: Gson = Gson().newBuilder().disableHtmlEscaping().setPrettyPrinting().create()
val configFile = file("src/main/resources/ModTheSpire.json")
tasks.processResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.register("modthespire") {
description = "Generates ModTheSpire.json"
val config = ModTheSpire(
modID,
description = """
|Adds Marisa (霧雨 魔理沙) from Touhou Project as a new playable character.
|
|${changeSts}
""".trimMargin(),
version = File("docs/changelog/version.txt").readText().trim()
)
configFile.writeText(gson.toJson(config) + "\n")
}
tasks.jar {
description = "Builds the mod jar file."
dependsOn("modthespire")
from(sourceSets.main.get().output)
println("built jar!")
}
tasks.register("hardlink") {
description = "Creates hard link for release on steam directory."
exec {
commandLine("deno", "task", "--quiet", "link", "--quiet")
}
}
tasks.register("changelog") {
description = "Write changelog to steam workshop description"
dependsOn("hardlink", tasks.jar)
file("$gameDir/${modID}/config.json")
.writeText(gson.toJson(Config(changeNote = changeBBCode)) + "\n")
}