generated from isXander/FabricModTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.gradle.kts
180 lines (146 loc) · 5.34 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
plugins {
`java-library`
id("me.modmuss50.mod-publish-plugin") version "0.6.1+"
`maven-publish`
id("fabric-loom")
}
group = "dev.isxander"
val versionWithoutMC = property("modVersion")!!.toString()
version = "$versionWithoutMC+${stonecutter.current.project}"
val isAlpha = "alpha" in version.toString()
val isBeta = "beta" in version.toString()
base.archivesName.set(property("modName").toString())
repositories {
mavenCentral()
maven("https://maven.isxander.dev/releases")
maven("https://maven.terraformersmc.com")
exclusiveContent {
forRepository { maven("https://api.modrinth.com/maven") }
filter { includeGroup("maven.modrinth") }
}
}
val mcVersion = property("mcVersion")!!.toString()
val mcSemverVersion = stonecutter.current.version
dependencies {
minecraft("com.mojang:minecraft:$mcVersion")
mappings(loom.officialMojangMappings())
modImplementation("net.fabricmc:fabric-loader:${property("deps.fabricLoader")}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${property("deps.fapi")}")
modImplementation("maven.modrinth:sodium:${property("deps.sodium")}")
modImplementation("dev.isxander:yet-another-config-lib:${property("deps.yacl")}")
modImplementation("com.terraformersmc:modmenu:${property("deps.modMenu")}")
}
tasks {
processResources {
val modId: String by project
val modName: String by project
val modDescription: String by project
val githubProject: String by project
val props = buildMap {
put("id", modId)
put("group", project.group)
put("name", modName)
put("description", modDescription)
put("version", project.version)
put("github", githubProject)
put("mc", findProperty("fmj.mcDep"))
put("fapi", findProperty("fmj.fapiDep") ?: "*")
}
props.forEach(inputs::property)
filesMatching("fabric.mod.json") {
expand(props)
}
}
}
java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
tasks.withType<JavaCompile> {
options.release = project.property("java.version").toString().toInt()
}
publishMods {
val modChangelog =
rootProject.file("changelog.md")
.takeIf { it.exists() }
?.readText()
?.replace("{version}", versionWithoutMC)
?.replace("{targets}", stonecutter.versions
.map { it.project }
.joinToString(separator = "\n") { "- $it" })
?: "No changelog provided."
changelog.set(modChangelog)
file.set(tasks.remapJar.get().archiveFile)
type.set(
when {
isAlpha -> ALPHA
isBeta -> BETA
else -> STABLE
}
)
modLoaders.add("fabric")
fun versionList(prop: String) = findProperty(prop)?.toString()
?.split(',')
?.map { it.trim() }
?: emptyList()
// modrinth and curseforge use different formats for snapshots. this can be expressed globally
val stableMCVersions = versionList("pub.stableMC")
val modrinthId: String by project
if (modrinthId.isNotBlank() && hasProperty("modrinth.token")) {
modrinth {
projectId.set(modrinthId)
accessToken.set(findProperty("modrinth.token")?.toString())
minecraftVersions.addAll(stableMCVersions)
minecraftVersions.addAll(versionList("pub.modrinthMC"))
announcementTitle = "Download $mcVersion for Fabric from Modrinth"
requires { slug.set("yacl") }
requires { slug.set("sodium") }
requires { slug.set("fabric-api") }
optional { slug.set("modmenu") }
}
}
val curseforgeId: String by project
if (curseforgeId.isNotBlank() && hasProperty("curseforge.token")) {
curseforge {
projectId = curseforgeId
projectSlug = findProperty("curseforgeSlug")!!.toString()
accessToken = findProperty("curseforge.token")?.toString()
minecraftVersions.addAll(stableMCVersions)
minecraftVersions.addAll(versionList("pub.curseMC"))
announcementTitle = "Download $mcVersion for Fabric from CurseForge"
requires { slug.set("yacl") }
requires { slug.set("sodium") }
requires { slug.set("fabric-api") }
optional { slug.set("modmenu") }
}
}
}
publishing {
publications {
create<MavenPublication>("mod") {
groupId = "dev.isxander"
artifactId = "cull-less-leaves"
from(components["java"])
}
}
repositories {
val username = "XANDER_MAVEN_USER".let { System.getenv(it) ?: findProperty(it) }?.toString()
val password = "XANDER_MAVEN_PASS".let { System.getenv(it) ?: findProperty(it) }?.toString()
if (username != null && password != null) {
maven(url = "https://maven.isxander.dev/releases") {
name = "XanderReleases"
credentials {
this.username = username
this.password = password
}
}
} else {
println("Xander Maven credentials not satisfied.")
}
}
}
tasks.create("releaseModVersion") {
dependsOn("publishMods")
dependsOn("publish")
}