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
|
import org.gradle.api.component.AdhocComponentWithVariants
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.libs
plugins {
alias(libs.plugins.architectury.loom)
alias(libs.plugins.shadow)
alias(libs.plugins.minotaur)
alias(libs.plugins.cursegradle)
}
architectury {
platformSetupLoomIde()
forge()
}
loom {
silentMojangMappingsLicense()
accessWidenerPath.set(project(":common").loom.accessWidenerPath)
forge {
mixinConfig("yacl.mixins.json")
convertAccessWideners.set(true)
extraAccessWideners.add(loom.accessWidenerPath.get().asFile.name)
}
}
val common by configurations.registering
val shadowCommon by configurations.registering
configurations.compileClasspath.get().extendsFrom(common.get())
configurations["developmentForge"].extendsFrom(common.get())
val minecraftVersion: String = libs.versions.minecraft.get()
dependencies {
minecraft(libs.minecraft)
mappings(loom.layered {
val qm = libs.versions.quilt.mappings.get()
if (qm != "0")
mappings("org.quiltmc:quilt-mappings:${libs.versions.minecraft.get()}+build.${libs.versions.quilt.mappings.get()}:intermediary-v2")
officialMojangMappings()
})
forge(libs.forge)
"common"(project(path = ":common", configuration = "namedElements")) { isTransitive = false }
"shadowCommon"(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false }
}
java {
withSourcesJar()
}
tasks {
processResources {
val modId: String by rootProject
val modName: String by rootProject
val modDescription: String by rootProject
val githubProject: String by rootProject
val majorForge = libs.versions.forge.get().substringAfter('-').split('.').first()
inputs.property("id", modId)
inputs.property("group", project.group)
inputs.property("name", modName)
inputs.property("description", modDescription)
inputs.property("version", project.version)
inputs.property("github", githubProject)
inputs.property("major_forge", majorForge)
filesMatching(listOf("META-INF/mods.toml", "pack.mcmeta")) {
expand(
"id" to modId,
"group" to project.group,
"name" to modName,
"description" to modDescription,
"version" to project.version,
"github" to githubProject,
"major_forge" to majorForge,
)
}
}
shadowJar {
exclude("fabric.mod.json")
exclude("architectury.common.json")
configurations = listOf(shadowCommon.get())
archiveClassifier.set("dev-shadow")
}
remapJar {
injectAccessWidener.set(true)
inputFile.set(shadowJar.get().archiveFile)
dependsOn(shadowJar)
archiveClassifier.set(null as String?)
from(rootProject.file("LICENSE"))
}
named<Jar>("sourcesJar") {
archiveClassifier.set("dev-sources")
val commonSources = project(":common").tasks.named<Jar>("sourcesJar")
dependsOn(commonSources)
from(commonSources.get().archiveFile.map { zipTree(it) })
}
remapSourcesJar {
archiveClassifier.set("sources")
}
jar {
archiveClassifier.set("dev")
}
}
components["java"].run {
if (this is AdhocComponentWithVariants) {
withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
skip()
}
}
}
val changelogText: String by ext
val isBeta: Boolean by ext
val modrinthId: String by project
if (modrinthId.isNotEmpty()) {
modrinth {
token.set(findProperty("modrinth.token")?.toString())
projectId.set(modrinthId)
versionName.set("${project.version} (Forge)")
versionNumber.set("${project.version}-forge")
versionType.set(if (isBeta) "beta" else "release")
uploadFile.set(tasks["remapJar"])
gameVersions.set(listOf("1.19.4"))
loaders.set(listOf("forge"))
changelog.set(changelogText)
syncBodyFrom.set(rootProject.file("README.md").readText())
}
}
rootProject.tasks["releaseMod"].dependsOn(tasks["modrinth"])
val curseforgeId: String by project
if (hasProperty("curseforge.token") && curseforgeId.isNotEmpty()) {
curseforge {
apiKey = findProperty("curseforge.token")
project(closureOf<me.hypherionmc.cursegradle.CurseProject> {
mainArtifact(tasks["remapJar"], closureOf<me.hypherionmc.cursegradle.CurseArtifact> {
displayName = "[Forge] ${project.version}"
})
id = curseforgeId
releaseType = if (isBeta) "beta" else "release"
addGameVersion("1.19.4")
addGameVersion("Forge")
addGameVersion("Java 17")
changelog = changelogText
changelogType = "markdown"
})
options(closureOf<me.hypherionmc.cursegradle.Options> {
forgeGradleIntegration = false
})
}
}
rootProject.tasks["releaseMod"].dependsOn(tasks["curseforge"])
publishing {
publications {
create<MavenPublication>("forge") {
groupId = "dev.isxander.yacl"
artifactId = "yet-another-config-lib-forge"
from(components["java"])
}
}
}
tasks.findByPath("publishForgePublicationToReleasesRepository")?.let {
rootProject.tasks["releaseMod"].dependsOn(it)
}
|