-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.gradle.kts
255 lines (226 loc) · 8.05 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
@file:Suppress("PropertyName")
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseProject
import com.matthewprenger.cursegradle.CurseRelation
import com.matthewprenger.cursegradle.Options
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
java
idea
`maven-publish`
id("fabric-loom") version "1.0-SNAPSHOT"
id("com.github.ben-manes.versions") version "0.42.0"
id("com.matthewprenger.cursegradle") version "1.4.0"
id("com.modrinth.minotaur") version "2.+"
id("com.diffplug.spotless") version "6.11.0"
kotlin("jvm") version "1.7.20"
kotlin("plugin.serialization") version "1.7.20"
id("org.shipkit.shipkit-auto-version") version "1.+"
id("org.shipkit.shipkit-changelog") version "1.+"
id("org.shipkit.shipkit-github-release") version "1.+"
}
tasks.withType<DependencyUpdatesTask> {
gradleReleaseChannel = "current"
rejectVersionIf {
candidate.version.contains("""-M\d+""".toRegex()) ||
candidate.version.contains("RC")
}
}
repositories {
mavenCentral()
maven {
url = uri("https://maven.fabricmc.net/")
name = "Fabric"
}
maven {
url = uri("https://maven.shedaniel.me/")
name = "shedaniel"
}
maven {
url = uri("https://maven.terraformersmc.com/releases/")
name = "TerraformersMC"
}
maven {
url = uri("https://maven.skaggsm.com/releases")
name = "Personal"
}
}
val curseforge_id: String by project
val modrinth_id: String by project
val archives_base_name: String by project
val maven_group: String by project
val minecraft_version: String by project
val yarn_mappings: String by project
val loader_version: String by project
val fabric_version: String by project
val kotlin_version: String by project
val cloth_config_version: String by project
val fiber_2_cloth_version: String by project
val fiber_version: String by project
val modmenu_version: String by project
base {
archivesName.set(archives_base_name)
group = maven_group
}
loom {
}
dependencies {
// to change the versions see the gradle.properties file
minecraft("com.mojang:minecraft:$minecraft_version")
mappings("net.fabricmc:yarn:$yarn_mappings:v2")
modImplementation("net.fabricmc:fabric-loader:$loader_version")
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation("net.fabricmc.fabric-api:fabric-api:$fabric_version")
modImplementation("net.fabricmc:fabric-language-kotlin:$kotlin_version")
include("net.fabricmc:fabric-language-kotlin:$kotlin_version")
modImplementation("com.terraformersmc:modmenu:$modmenu_version")
modImplementation("me.shedaniel.cloth:cloth-config-fabric:$cloth_config_version")
include("me.shedaniel.cloth:cloth-config-fabric:$cloth_config_version")
modImplementation("me.shedaniel.cloth:fiber2cloth:$fiber_2_cloth_version")
include("me.shedaniel.cloth:fiber2cloth:$fiber_2_cloth_version")
modImplementation("me.zeroeightsix:fiber:$fiber_version")
include("me.zeroeightsix:fiber:$fiber_version")
include("com.skaggsm:java-mumble-link:0.2.6")
implementation("com.skaggsm:java-mumble-link:0.2.6")
include("com.skaggsm:jvm-shared-memory:0.2.9")
implementation("com.skaggsm:jvm-shared-memory:0.2.9")
}
tasks.processResources {
inputs.properties(
"version" to project.version
)
filesMatching("fabric.mod.json") {
expand(
"version" to project.version
)
}
}
tasks.withType<JavaCompile> {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
options.encoding = "UTF-8"
// Minecraft 1.17 (21w19a) upwards uses Java 16.
options.release.set(17)
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
publishing {
publications {
create<MavenPublication>("mod") {
from(components["java"])
}
}
repositories {
mavenLocal()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/magneticflux-/fabric-mumblelink-mod")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
tasks.generateChangelog {
repository = "magneticflux-/fabric-mumblelink-mod"
previousRevision = project.ext["shipkit-auto-version.previous-tag"]?.toString()
githubToken = System.getenv("GITHUB_TOKEN")
}
tasks.githubRelease {
dependsOn(tasks.generateChangelog)
repository = "magneticflux-/fabric-mumblelink-mod"
changelog = tasks.generateChangelog.get().outputFile
githubToken = System.getenv("GITHUB_TOKEN")
newTagRevision = System.getenv("GITHUB_SHA")
}
// Configure CurseForge publishing
curseforge {
// Stored in ~/.gradle/gradle.properties
when {
project.hasProperty("curseApiKey") -> apiKey = project.ext["curseApiKey"]
System.getenv("CURSE_API_KEY") != null -> apiKey = System.getenv("CURSE_API_KEY")
else -> println("No CurseForge API key found, \'curseforge\' tasks will not work")
}
project(
closureOf<CurseProject> {
id = curseforge_id
releaseType = "release"
addGameVersion(minecraft_version)
addGameVersion("Fabric")
changelog =
"View the latest changelog here: https://github.com/magneticflux-/fabric-mumblelink-mod/releases"
mainArtifact(
tasks.remapJar.get(),
closureOf<CurseArtifact> {
relations(
closureOf<CurseRelation> {
requiredDependency("fabric-api")
embeddedLibrary("fabric-language-kotlin")
embeddedLibrary("cloth-config")
embeddedLibrary("fiber2cloth")
optionalDependency("modmenu")
}
)
}
)
addArtifact(tasks["sourcesJar"])
}
)
options(
closureOf<Options> {
forgeGradleIntegration = false
}
)
}
modrinth {
// Stored in ~/.gradle/gradle.properties
when {
project.hasProperty("modrinthApiKey") -> token.set(project.property("modrinthApiKey").toString())
System.getenv("MODRINTH_API_KEY") != null -> token.set(System.getenv("MODRINTH_API_KEY"))
else -> println("No Modrinth API key found, \'modrinth\' tasks will not work")
}
projectId.set(modrinth_id)
versionNumber.set(version.toString())
gameVersions.add(minecraft_version)
uploadFile.set(tasks.remapJar as Any)
additionalFiles.add(tasks.remapSourcesJar as Any)
loaders.addAll("fabric", "quilt")
dependencies {
required.project("fabric-api")
optional.project("modmenu")
embedded.project("cloth-config")
embedded.project("fabric-language-kotlin")
}
}
spotless {
kotlin {
ktlint("0.47.1")
}
kotlinGradle {
ktlint("0.47.1")
}
}
afterEvaluate {
// CurseGradle generates tasks in afterEvaluate for each project
// There isn't really any other way to make it depend on a task unless it is an AbstractArchiveTask
val curseforgeTask = tasks.getByName("curseforge$curseforge_id")
val modrinthTask = tasks.modrinth
tasks.publish {
dependsOn(curseforgeTask, modrinthTask)
}
}