generated from VulpixelMC/fabric-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
217 lines (180 loc) · 5.62 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
@file:Suppress("UnstableApiUsage")
import nl.javadude.gradle.plugins.license.License
plugins {
id("com.github.hierynomus.license").version("0.16.1")
alias(libs.plugins.quilt.loom)
`maven-publish`
}
val modVersion: String by project
val mavenGroup: String by project
val modId: String by project
base.archivesName = modId
version = modVersion
group = mavenGroup
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
mavenCentral()
maven {
name = "ParchmentMC"
url = uri("https://maven.parchmentmc.org")
}
// Mod Artifacts
maven {
name = "WTHIT Maven"
url = uri("https://maven2.bai.lol")
content {
includeGroup("lol.bai")
includeGroup("mcp.mobius.waila")
}
}
maven {
name = "TerraformersMC"
url = uri("https://maven.terraformersmc.com/")
}
maven {
name = "Modrinth"
url = uri("https://api.modrinth.com/maven")
content {
includeGroup("maven.modrinth")
}
}
}
val modImplementationInclude by configurations.register("modImplementationInclude")
// All the dependencies are declared at gradle/libs.version.toml and referenced with "libs.<id>"
// See https://docs.gradle.org/current/userguide/platforms.html for information on how version catalogs work.
dependencies {
minecraft(libs.minecraft)
mappings(loom.layered {
officialMojangMappings()
parchment(libs.parchment)
})
// Loader
modImplementation(libs.fabric.loader)
// Libraries
modImplementation(libs.fabric.api)
// Mod Integrations
modCompileOnly(libs.wthit)
modCompileOnly(libs.wthit.api)
modCompileOnly(libs.lucko.fabric.permissions) {
exclude(group = "net.fabricmc.fabric-api")
exclude(group = "net.fabricmc")
}
modCompileOnly(libs.sodium)
modRuntimeOnly(libs.wthit)
modRuntimeOnly(libs.modmenu) {
exclude(group = "net.fabricmc.fabric-api")
exclude(group = "net.fabricmc")
}
modRuntimeOnly(libs.luckperms)
modRuntimeOnly(libs.lucko.fabric.permissions) {
exclude(group = "net.fabricmc.fabric-api")
exclude(group = "net.fabricmc")
}
modRuntimeOnly(libs.resource.explorer)
modRuntimeOnly(libs.spark)
modRuntimeOnly(libs.sodium)
}
configurations {
runtimeClasspath {
// remove duplicate fabric-loader
exclude(group = "net.fabricmc", module = "fabric-loader")
}
}
tasks.create("markImplInternal") {
description = "Marks all implementation classes with @ApiStatus.Internal"
fileTree("${project.projectDir}/src/main/java/gay/sylv/weird_wares/impl").matching {
include("**/*.java")
}.forEach {
var contents = it.readText(charset = Charsets.UTF_8) // this project uses UTF-8
val pattern = "^(?<whitespace>[^\\S\\n]*)(?<classKeywords>(private |public )*(static )*(final )*(class|record|interface)+ )".toRegex(RegexOption.MULTILINE)
if (!contents.contains("@org.jetbrains.annotations.ApiStatus.Internal")) {
contents = contents.replace(pattern) { match -> "${match.groups["whitespace"]?.value ?: ""}@org.jetbrains.annotations.ApiStatus.Internal\n${match.groups["whitespace"]?.value ?: ""}${match.groups["classKeywords"]!!.value}" }
it.writeText(contents)
}
}
}
tasks.processResources {
inputs.property("version", version)
filesMatching("fabric.mod.json") {
expand("group" to mavenGroup, "id" to modId, "version" to version)
}
filesMatching("**/lang/*.json") {
expand("id" to modId)
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
// Minecraft 1.21 upwards uses Java 21.
options.release.set(21)
}
loom {
accessWidenerPath.set(file("src/main/resources/$modId.accesswidener"))
}
fabricApi {
configureDataGeneration()
}
java {
// Still required by IDEs such as Eclipse and Visual Studio Code
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
// 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()
// If this mod is going to be a library, then it should also generate Javadocs in order to aid with development.
// Uncomment this line to generate them.
// withJavadocJar()
}
// If you plan to use a different file for the license, don't forget to change the file name here!
tasks.withType<AbstractArchiveTask> {
from("COPYING") {
rename { "${it}_${modId}" }
}
from("COPYING.LESSER") {
rename { "${it}_${modId}" }
}
from("LICENSE") {
rename { "${it}_${modId}" }
}
}
tasks.license.configure {
mustRunAfter(tasks.licenseFormat)
}
tasks.build {
dependsOn(tasks.licenseFormat)
dependsOn(tasks.license)
dependsOn(tasks["markImplInternal"])
mustRunAfter(tasks["markImplInternal"])
}
tasks.withType<License> {
header = file("LHEADER")
exclude("**/*.json")
}
// Configure the maven publication
publishing {
publications {
create<MavenPublication>("maven") {
groupId = mavenGroup
artifactId = modId
version = modVersion
from(components["java"])
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
maven {
url = uri("https://maven.muonmc.org/releases")
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}