-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle.kts
337 lines (287 loc) · 11.5 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
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.matthewprenger.cursegradle.CurseProject
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseRelation
import fr.brouillard.oss.jgitver.GitVersionCalculator
import fr.brouillard.oss.jgitver.Strategies
import net.minecraftforge.gradle.common.util.RunConfig
import wtf.gofancy.fancygradle.script.extensions.curse
import wtf.gofancy.fancygradle.script.extensions.deobf
import java.time.LocalDateTime
buildscript {
dependencies {
classpath(group = "fr.brouillard.oss", name = "jgitver", version = "0.14.0")
}
}
plugins {
java
`maven-publish`
id("net.minecraftforge.gradle") version "5.1.+"
id("com.github.johnrengelman.shadow") version "7.0.0"
id("wtf.gofancy.fancygradle") version "1.1.+"
id("com.matthewprenger.cursegradle") version "1.4.+"
id("com.modrinth.minotaur") version "2.+"
id("wtf.gofancy.git-changelog") version "1.1.+"
}
val versionMc: String by project
val curseForgeId: String by project
val modrinthId: String by project
val modrinthVersionIC2: String by project
val versionIC2: String by project
val versionBuildCraft: String by project
val versionJEI: String by project
val versionCodeChickenLib: String by project
val versionCoFHCore: String by project
val versionCoFHWorld: String by project
val versionRF: String by project
val versionThermalFoundation: String by project
val versionThermalExpansion: String by project
val versionAE2: String by project
val versionMantle: String by project
val versionTConstruct: String by project
val versionEnergyControl: String by project
val versionRailcraft: String by project
val versionThaumcraft: String by project
val versionCraftTweaker: String by project
group = "mods.su5ed"
version = getGitVersion()
setProperty("archivesBaseName", "gregtechmod")
val api: SourceSet by sourceSets.creating
val apiDep: Configuration by configurations.creating
val shade: Configuration by configurations.creating {
configurations.implementation.get().extendsFrom(this)
}
val manifestAttributes = mapOf(
"Specification-Title" to project.name,
"Specification-Vendor" to "Su5eD",
"Specification-Version" to "1",
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "Su5eD",
"Implementation-Timestamp" to LocalDateTime.now()
)
val publishReleaseType = System.getenv("PUBLISH_RELEASE_TYPE") ?: "beta"
val changelogText = changelog.generateChangelog(1, true)
minecraft {
mappings("stable", "39-1.12")
runs {
val config = Action<RunConfig> {
property("forge.logging.console.level", "debug")
workingDirectory = project.file("run").canonicalPath
source(sourceSets.main.get())
forceExit = false
}
create("client", config)
create("server", config)
}
}
fancyGradle {
patches {
resources
coremods
codeChickenLib
asm
mergetool
}
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
withSourcesJar()
}
configurations {
"apiImplementation" {
extendsFrom(apiDep, configurations.minecraft.get())
}
apiElements {
setExtendsFrom(setOf(apiDep, shade))
}
shadowRuntimeElements {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
}
}
val devJar by tasks.registering(ShadowJar::class) {
dependsOn("classes", "apiClasses")
configurations = listOf(shade)
manifest.attributes(manifestAttributes)
from(sourceSets.main.get().output)
from(api.output)
archiveClassifier.set("dev")
}
val apiJar by tasks.registering(Jar::class) {
finalizedBy("reobfApiJar")
from(api.allSource, api.output)
exclude("META-INF/**")
archiveClassifier.set("api")
}
val relocateShadowJar by tasks.registering(ConfigureShadowRelocation::class) {
target = tasks.shadowJar.get()
prefix = "mods.gregtechmod.repack"
}
tasks {
jar {
from(api.output)
manifest.attributes(manifestAttributes)
archiveClassifier.set("slim")
}
shadowJar {
dependsOn(relocateShadowJar)
finalizedBy("reobfShadowJar")
configurations = listOf(shade)
manifest.attributes(manifestAttributes)
from(api.output)
archiveClassifier.set("")
}
named<Jar>("sourcesJar") {
from(api.allSource)
}
processResources {
inputs.properties(
"version" to project.version,
"mcversion" to versionMc
)
filesMatching("mcmod.info") {
expand(
"version" to project.version,
"mcversion" to versionMc
)
}
}
assemble {
dependsOn(shadowJar, devJar, apiJar)
}
}
reobf {
create("shadowJar")
create("apiJar")
}
repositories {
exclusiveRepo("https://maven.ic2.player.to", "net.industrial-craft")
exclusiveRepo("https://maven.covers1624.net", "cofh", "codechicken")
exclusiveRepo("https://mod-buildcraft.com/maven", "com.mod-buildcraft")
exclusiveRepo("https://cursemaven.com", "curse.maven")
exclusiveRepo("https://maven.su5ed.dev/releases", "one.util")
exclusiveRepo("https://maven.blamejared.com", "CraftTweaker2")
exclusiveRepo("https://modmaven.dev", "mezz.jei", "slimeknights", "slimeknights.mantle")
mavenCentral()
}
dependencies {
minecraft(group = "net.minecraftforge", name = "forge", version = "1.12.2-14.23.5.2860")
implementation(api.output)
implementation(fg.deobf(group = "net.industrial-craft", name = "industrialcraft-2", version = versionIC2))
apiDep(group = "net.industrial-craft", name = "industrialcraft-2", version = versionIC2, classifier = "api")
compileOnly(fg.deobf(group = "cofh", name = "RedstoneFlux", version = versionRF, classifier = "universal"))
compileOnly(fg.deobf(group = "cofh", name = "CoFHCore", version = versionCoFHCore, classifier = "universal")) {
exclude(group = "mezz.jei")
}
compileOnly(fg.deobf(group = "cofh", name = "CoFHWorld", version = versionCoFHWorld, classifier = "universal"))
compileOnly(fg.deobf(group = "cofh", name = "ThermalFoundation", version = versionThermalFoundation, classifier = "universal"))
compileOnly(fg.deobf(group = "codechicken", name = "CodeChickenLib", version = versionCodeChickenLib, classifier = "universal"))
compileOnly(fg.deobf(group = "cofh", name = "ThermalExpansion", version = versionThermalExpansion, classifier = "universal")) {
exclude(group = "mezz.jei")
}
runtimeOnly(fg.deobf(group = "mezz.jei", name = "jei_$versionMc", version = versionJEI))
compileOnly(group = "mezz.jei", name = "jei_$versionMc", version = versionJEI, classifier = "api")
compileOnly(fg.deobf(group = "com.mod-buildcraft", name = "buildcraft-main", version = versionBuildCraft))
implementation(fg.deobf(curse(mod = "energy-control", projectId = 373450, fileId = versionEnergyControl.toLong())))
compileOnly(fg.deobf(curse(mod = "railcraft", projectId = 51195, fileId = versionRailcraft.toLong())))
compileOnly(fg.deobf(curse(mod = "applied-energistics-2", projectId = 223794, fileId = versionAE2.toLong())))
compileOnly(fg.deobf(curse(mod = "thaumcraft", projectId = 223628, fileId = versionThaumcraft.toLong())))
compileOnly(fg.deobf(group = "slimeknights.mantle", name = "Mantle", version = versionMantle))
compileOnly(fg.deobf(group = "slimeknights", name = "TConstruct", version = versionTConstruct))
compileOnly(fg.deobf(group = "CraftTweaker2", name = "CraftTweaker2-MC1120-Main", version = "1.12-$versionCraftTweaker"))
compileOnly(group = "CraftTweaker2", name = "CraftTweaker2-API", version = versionCraftTweaker)
compileOnly(group = "CraftTweaker2", name = "ZenScript", version = versionCraftTweaker)
apiDep(shade(group = "com.fasterxml.jackson.core", name = "jackson-databind", version = "2.9.0"))
shade(group = "com.fasterxml.jackson.dataformat", name = "jackson-dataformat-yaml", version = "2.9.0")
apiDep(shade(group = "one.util", name = "streamex", version = "0.8.1"))
}
afterEvaluate {
val component = components["java"] as AdhocComponentWithVariants
component.withVariantsFromConfiguration(configurations.runtimeElements.get(), ConfigurationVariantDetails::skip)
}
curseforge {
apiKey = System.getenv("CURSEFORGE_TOKEN") ?: "UNKNOWN"
project(closureOf<CurseProject> {
id = curseForgeId
changelogType = "markdown"
changelog = changelogText
releaseType = publishReleaseType
mainArtifact(tasks.shadowJar.get(), closureOf<CurseArtifact> {
displayName = "GregTech Experimental ${project.version}"
relations(closureOf<CurseRelation> {
requiredDependency("industrial-craft")
optionalDependency("jei")
optionalDependency("thermal-expansion")
optionalDependency("buildcraft")
optionalDependency("energy-control")
optionalDependency("railcraft")
optionalDependency("applied-energistics-2")
optionalDependency("thaumcraft")
optionalDependency("tinkers-construct")
optionalDependency("crafttweaker")
})
})
addGameVersion("Forge")
addGameVersion(versionMc)
})
}
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set(modrinthId)
versionName.set("GregTech Experimental ${project.version}")
versionType.set(publishReleaseType)
uploadFile.set(tasks.shadowJar.get())
gameVersions.addAll(versionMc)
dependencies {
required.version("wTncj5gs", modrinthVersionIC2) // IC2
optional.project("u6dRKJwZ") // JEI
optional.project("rxIIYO6c") // Tinkers' Construct
}
changelog.set(changelogText)
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
groupId = project.group as String
artifactId = "gregtechmod"
version = project.version as String
from(components["java"])
artifact(devJar)
artifact(apiJar)
}
}
repositories {
maven {
credentials {
username = project.findProperty("MAVEN_USER") as String?
password = project.findProperty("MAVEN_TOKEN") as String?
}
name = "Su5eD"
url = uri("https://maven.su5ed.dev/releases")
}
}
}
fun getGitVersion(): String {
val jgitver = GitVersionCalculator.location(rootDir)
.setNonQualifierBranches("forge-1.12.2")
.setStrategy(Strategies.SCRIPT)
.setScript("print \"\${metadata.CURRENT_VERSION_MAJOR};\${metadata.CURRENT_VERSION_MINOR};\${metadata.CURRENT_VERSION_PATCH + metadata.COMMIT_DISTANCE}\"")
return jgitver.version
}
// Adapted from https://gist.github.com/pupnewfster/6c21401789ca6d74f9892be8c1c505c9
fun RepositoryHandler.exclusiveRepo(location: String, vararg groups: String) {
exclusiveRepo(location) {
for (group in groups) {
includeGroup(group)
}
}
}
fun RepositoryHandler.exclusiveRepo(location: String, config: Action<InclusiveRepositoryContentDescriptor>) {
exclusiveContent {
forRepositories(maven { url = uri(location) }, fg.repository)
filter(config)
}
}