forked from DynamicTreesTeam/DynamicTrees-PHC2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
278 lines (225 loc) · 8.8 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
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
import com.google.gson.Gson
import com.google.gson.JsonObject
import com.matthewprenger.cursegradle.*
import java.io.InputStreamReader
import java.time.Instant
import java.time.format.DateTimeFormatter
fun property(key: String) = project.findProperty(key).toString()
plugins {
id("java")
id("net.minecraftforge.gradle")
id("org.parchmentmc.librarian.forgegradle")
id("idea")
id("maven-publish")
id("com.matthewprenger.cursegradle") version "1.4.0"
}
repositories {
maven("https://ldtteam.jfrog.io/ldtteam/modding/")
// TEMP FIX: TEHNUT MAVEN IS DOWN
//maven("https://maven.tehnut.info")
maven("https://www.cursemaven.com") {
content {
includeGroup("curse.maven")
}
}
maven("https://harleyoconnor.com/maven")
maven("https://squiddev.cc/maven/")
}
val modName = property("modName")
val modId = property("modId")
val modVersion = property("modVersion")
val mcVersion = property("mcVersion")
version = "$mcVersion-$modVersion"
group = property("group")
minecraft {
mappings("parchment", "${property("mappingsVersion")}-$mcVersion")
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))
runs {
create("client") {
applyDefaultConfiguration()
if (project.hasProperty("mcUuid")) {
args("--uuid", property("mcUuid"))
}
if (project.hasProperty("mcUsername")) {
args("--username", property("mcUsername"))
}
if (project.hasProperty("mcAccessToken")) {
args("--accessToken", property("mcAccessToken"))
}
}
create("server") {
applyDefaultConfiguration()
}
create("data") {
applyDefaultConfiguration()
args(
"--mod", modId,
"--all",
"--output", file("src/generated/resources/"),
"--existing", file("src/main/resources"),
"--existing-mod", "dynamictrees",
"--existing-mod", "pamhc2trees"
)
}
}
}
fun net.minecraftforge.gradle.common.util.RunConfig.applyDefaultConfiguration(runDirectory: String = "run") {
workingDirectory = file(runDirectory).absolutePath
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
property("forge.logging.console.level", "debug")
property("mixin.env.remapRefMap", "true")
property("mixin.env.refMapRemappingFile", "${buildDir}/createSrgToMcp/output.srg")
mods {
create(modId) {
source(sourceSets.main.get())
}
}
}
sourceSets.main.get().resources {
srcDir("src/generated/resources")
}
dependencies {
// Not sure if we need this one, what is a "forge" anyway?
minecraft("net.minecraftforge:forge:${mcVersion}-${property("forgeVersion")}")
// Compile PHC and DT, of course.
implementation(fg.deobf("curse.maven:pams-harvestcraft-2-trees-365460:4360314"))
implementation(fg.deobf("com.ferreusveritas.dynamictrees:DynamicTrees-$mcVersion:${property("dynamicTreesVersion")}"))
// Compile Jade, but don't include in runtime.
compileOnly(fg.deobf("curse.maven:Jade-324717:4082408"))
// DT+ is optional, but it's implemented as there is access to its classes and needs to be compiled.
implementation(fg.deobf("com.ferreusveritas.dynamictreesplus:DynamicTreesPlus-$mcVersion:${property("dynamicTreesPlusVersion")}"))
/////////////////////////////////////////
/// Runtime Dependencies (optional)
/////////////////////////////////////////
// At runtime, use the full Jade mod.
runtimeOnly(fg.deobf("curse.maven:Jade-324717:4082408"))
// At runtime, use the full JEI mod.
// TEMP FIX: TEHNUT MAVEN IS DOWN
runtimeOnly(fg.deobf("curse.maven:jei-238222:4434393"))
//runtimeOnly(fg.deobf("mezz.jei:jei-$mcVersion:${property("jeiVersion")}"))
// At runtime, use CC for creating growth chambers.
runtimeOnly(fg.deobf("org.squiddev:cc-tweaked-$mcVersion:${property("ccVersion")}"))
// At runtime, get rid of experimental settings warning screen.
runtimeOnly(fg.deobf("curse.maven:ShutUpExperimentalSettings-407174:3544525"))
// At runtime use serene seasons to test seasonal mechanics
runtimeOnly(fg.deobf("curse.maven:SereneSeasons-291874:3693807"))
// At runtime, use suggestion provider fix mod.
runtimeOnly(fg.deobf("com.harleyoconnor.suggestionproviderfix:SuggestionProviderFix-1.18.1:${property("suggestionProviderFixVersion")}"))
// If needed, include Cyanide mod to get more info about datapack errors
runtimeOnly(fg.deobf("curse.maven:Cyanide-541676:3811793"))
}
tasks.jar {
manifest.attributes(
"Specification-Title" to project.name,
"Specification-Vendor" to "Max Hyper",
"Specification-Version" to "1",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "Max Hyper",
"Implementation-Timestamp" to DateTimeFormatter.ISO_INSTANT.format(Instant.now())
)
archiveBaseName.set(modName)
finalizedBy("reobfJar")
}
java {
withSourcesJar()
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
fun readChangelog(): String? {
val versionInfoFile = file("version_info.json")
val jsonObject = Gson().fromJson(InputStreamReader(versionInfoFile.inputStream()), JsonObject::class.java)
return jsonObject
.get(mcVersion)?.asJsonObject
?.get(project.version.toString())?.asString
}
fun enablePublishing() =
project.hasProperty("curseApiKey") && project.hasProperty("curseFileType") && project.hasProperty("projectId")
tasks.withType(CurseUploadTask::class.java) {
onlyIf {
enablePublishing()
}
}
curseforge {
if (project.hasProperty("curseApiKey") && project.hasProperty("curseFileType")) {
apiKey = property("curseApiKey")
project {
id = property("curseProjectId")
addGameVersion(mcVersion)
changelog = file("build/changelog.txt")
changelogType = "markdown"
releaseType = property("curseFileType")
addArtifact(tasks.findByName("sourcesJar"))
mainArtifact(tasks.findByName("jar")) {
relations {
requiredDependency("dynamictrees")
requiredDependency("pams-harvestcraft-2-trees")
}
}
}
} else {
project.logger.log(LogLevel.WARN, "API Key and file type for CurseForge not detected; uploading will be disabled.")
}
}
tasks.withType<GenerateModuleMetadata> {
enabled = false
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = "$modName-$mcVersion"
version = modVersion
from(components["java"])
pom {
name.set(modName)
url.set("https://github.com/supermassimo/$modName")
licenses {
license {
name.set("MIT")
url.set("https://mit-license.org")
}
}
scm {
connection.set("scm:git:git://github.com/supermassimo/$modName.git")
developerConnection.set("scm:git:ssh://github.com/supermassimo/$modName.git")
url.set("https://github.com/supermassimo/$modName")
}
}
pom.withXml {
val element = asElement()
// Clear dependencies.
for (i in 0 until element.childNodes.length) {
val node = element.childNodes.item(i)
if (node?.nodeName == "dependencies") {
element.removeChild(node)
}
}
}
}
}
repositories {
maven("file:///${project.projectDir}/mcmodsrepo")
if (hasProperty("harleyOConnorMavenUsername") && hasProperty("harleyOConnorMavenPassword")) {
maven("https://harleyoconnor.com/maven") {
name = "HarleyOConnor"
credentials {
username = property("harleyOConnorMavenUsername")
password = property("harleyOConnorMavenPassword")
}
}
} else {
logger.log(LogLevel.WARN, "Credentials for maven not detected; it will be disabled.")
}
}
}
// Extensions to make CurseGradle extension slightly neater.
fun CurseExtension.project(action: CurseProject.() -> Unit) {
this.project(closureOf(action))
}
fun CurseProject.mainArtifact(artifact: Task?, action: CurseArtifact.() -> Unit) {
this.mainArtifact(artifact, closureOf(action))
}
fun CurseArtifact.relations(action: CurseRelation.() -> Unit) {
this.relations(closureOf(action))
}