generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
159 lines (137 loc) · 4.64 KB
/
build.gradle
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
import net.fabricmc.loom.api.mappings.layered.MappingContext
import net.fabricmc.loom.api.mappings.layered.MappingLayer
import net.fabricmc.loom.api.mappings.layered.MappingsNamespace
import net.fabricmc.loom.api.mappings.layered.spec.MappingsSpec
import net.fabricmc.loom.configuration.providers.mappings.intermediary.IntermediaryMappingLayer
import net.fabricmc.mappingio.MappingVisitor
import net.fabricmc.mappingio.tree.MemoryMappingTree
plugins {
id 'maven-publish'
alias(libs.plugins.quilt.loom)
}
archivesBaseName = project.archives_base_name
version = project.version
group = project.maven_group
repositories {
maven {
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org'
}
maven {
name = 'GeckoLib'
url = 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
}
}
// add a new configuration for a transitive `include`
configurations {
includeTransitive {
transitive = true
}
}
dependencies {
minecraft libs.minecraft
// auto-generate mappings to stop mojmap conflicts with geckolib
mappings loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-1.18.2:2022.03.13@zip") // couldn't get this to work with libs.versions.toml :irr:
// don't convert this to a dynamic instantiation, otherwise java won't see the overridden hashCode
addLayer(new MappingsSpec<MappingLayer>() {
final Map<String, String> METHOD_NAME_MAP = Map.of(
"getTextureLocation", "_getTextureLocation"
)
@Override
MappingLayer createLayer(MappingContext mappingContext) {
return new MappingLayer() {
@Override
void visit(MappingVisitor mappingVisitor) throws IOException {
MemoryMappingTree memoryMappingTree = mappingVisitor as MemoryMappingTree
memoryMappingTree.getClasses().forEach(classEntry -> {
classEntry.methods.forEach(methodEntry -> {
String newMethodName = METHOD_NAME_MAP.get(methodEntry.getName(MappingsNamespace.NAMED.toString()))
if (newMethodName != null) {
//noinspection GroovyAccessibility
methodEntry.srcName = newMethodName
}
})
})
}
@Override
MappingsNamespace getSourceNamespace() {
return MappingsNamespace.NAMED
}
@Override
List<Class<? extends MappingLayer>> dependsOn() {
return List.of(IntermediaryMappingLayer.class)
}
}
}
@Override
int hashCode() {
// used to make sure caches stay consistent
return METHOD_NAME_MAP.hashCode()
}
})
}
modImplementation libs.quilt.loader
modImplementation libs.quilted.fabric.api
// for some reason the native and main jffi clash, so we have to exclude them.
// we also exclude ASM because loader already bundles it.
includeTransitive(implementation("org.lmdbjava:lmdbjava:0.8.2")) {
exclude group: "com.github.jnr", module: "jffi"
exclude group: "org.ow2.asm"
}
// this is set to runtimeOnly because it will otherwise conflict with the main module
include(runtimeOnly("com.github.jnr:jffi:1.3.9:native"))
include(implementation("com.github.jnr:jffi:1.3.9"))
modImplementation("software.bernie.geckolib:geckolib-quilt-1.18:3.0.1") {
// we already include it ourselves, and we don't want to conflict
exclude group: "org.quiltmc.qsl"
}
}
// resolve dependencies and add to `include`
// original by Hexafice
afterEvaluate {
configurations.getByName("includeTransitive").resolvedConfiguration.resolvedArtifacts.forEach(dep -> {
dependencies.add("include", dep.id.componentIdentifier.displayName)
})
}
processResources {
inputs.property "version", version
filesMatching('quilt.mod.json') {
expand "version": version
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}
java {
// Still required by IDEs such as Eclipse and Visual Studio Code
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()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
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.
}
}