-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathbuild.gradle
More file actions
228 lines (190 loc) · 6.66 KB
/
Copy pathbuild.gradle
File metadata and controls
228 lines (190 loc) · 6.66 KB
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
import com.replaymod.gradle.preprocess.PreprocessTask
buildscript {
def (major, minor, patch) = project.name.split("-")[0].tokenize('.')
project.ext.mcVersion = "${major}${minor.padLeft(2, '0')}${(patch ?: '').padLeft(2, '0')}" as int
dependencies {
classpath 'fabric-loom:fabric-loom.gradle.plugin:1.0-SNAPSHOT'
}
}
plugins {
id "maven-publish"
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'xyz.wagyourtail.jvmdowngrader' version '1.2.2'
}
apply plugin: 'fabric-loom'
apply plugin: 'com.replaymod.preprocess'
preprocess {
patternAnnotation.set("adris.altoclef.multiversion.Pattern")
}
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = sourceCompatibility
tasks.withType(JavaCompile).configureEach {
options.release = 21
}
archivesBaseName = project.archives_base_name
version = "${project.name}-${project.mod_version}"
group = project.maven_group
def mappingsVersions = [
11605: "1.16.5+build.10",
11701: "1.17.1+build.65",
11800: "1.18+build.1",
11802: "1.18.2+build.4",
11904: "1.19.4+build.2",
12001: "1.20.1+build.10",
12002: "1.20.2+build.4",
12004: "1.20.4+build.3",
12005: "1.20.5+build.1",
12006: "1.20.6+build.3",
12100: "1.21+build.9",
12101: "1.21.1+build.3",
]
def fabricApiVersions = [
11605: "0.42.0+1.16",
11701: "0.46.1+1.17",
11800: "0.44.0+1.18",
11802: "0.77.0+1.18.2",
11904: "0.87.2+1.19.4",
12001: "0.92.2+1.20.1",
12002: "0.91.2+1.20.2",
12004: "0.96.3+1.20.4",
12005: "0.97.8+1.20.5",
12006: "0.100.0+1.20.6",
12100: "0.100.7+1.21",
12101: "0.110.0+1.21.1",
]
def getJavaVersion() {
if (mcVersion >= 12006) {
return JavaVersion.VERSION_21;
} else if (mcVersion >= 11700) {
return JavaVersion.VERSION_17;
}
return JavaVersion.VERSION_1_8;
}
repositories {
mavenCentral()
maven {
name = "MiranCZRepo"
url = "https://mirancz.github.io/maven/"
artifactUrls("https://mirancz.github.io/maven/cabaletta/baritone-unoptimized/${project.name}")
}
maven {
name = 'babbaj-repo'
url = 'https://babbaj.github.io/maven/'
}
flatDir {
dirs '../baritone/dist'
}
}
jvmdg {
downgradeTo = getJavaVersion()
}
dependencies {
//to change the versions see the gradle.properties file
minecraft("com.mojang:minecraft:${project.name}")
mappings("net.fabricmc:yarn:${mappingsVersions[mcVersion]}:v2")
modImplementation("net.fabricmc:fabric-loader:${project.loader_version}")
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:0.3.5")))
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation("net.fabricmc.fabric-api:fabric-api:${fabricApiVersions[mcVersion]}")
// Jackson JSON
implementation 'com.fasterxml.jackson.core:jackson-core:2.16.0'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.16.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.16.0'
// Jvm downgrader
include('xyz.wagyourtail.jvmdowngrader:jvmdowngrader-java-api:0.9.0:downgraded-8')
// Nether pathfinder
implementation 'dev.babbaj:nether-pathfinder:1.5'
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
shadow('com.fasterxml.jackson.core:jackson-core:2.16.0')
shadow('com.fasterxml.jackson.core:jackson-annotations:2.16.0')
shadow('com.fasterxml.jackson.core:jackson-databind:2.16.0')
// Thank you georgeagostino for fixing my garbage
if (getProject().hasProperty("altoclef.development")) {
// Must run build from baritone-plus once
modImplementation "baritone-api-fabric:baritone-unoptimized-fabric-${project.name}"
include "baritone-api-fabric:baritone-unoptimized-fabric-${project.name}"
} else {
modImplementation "cabaletta:baritone-unoptimized-fabric:${project.name}"
include "cabaletta:baritone-unoptimized-fabric:${project.name}"
}
//modImplementation 'baritone-api-fabric:baritone-api-fabric:1.6.3'
//implementation files('baritone-plus/build/libs/baritone-unoptimized-fabric-1.6.3.jar')
}
shadowJar {
configurations = [project.configurations.shadow]
}
remapJar {
dependsOn("shadowJar")
input.set(shadowJar.archiveFile)
}
downgradeJar {
dependsOn("remapJar")
inputFile.set(remapJar.archiveFile)
}
tasks.register('replaceJar') {
// do not downgrade java version if we do not need to
if (getJavaVersion() == targetCompatibility) {
return
}
dependsOn downgradeJar
doLast {
def originalJar = tasks.remapJar.archiveFile.get().asFile
def downgradedJar = file("${originalJar.parent}/${originalJar.name.replace('.jar', '-downgraded.jar')}")
if (downgradedJar.exists()) {
originalJar.delete()
downgradedJar.renameTo(originalJar)
} else {
throw new GradleException("Downgraded JAR not found: ${downgradedJar}")
}
}
}
build {
dependsOn tasks.replaceJar
}
processResources {
inputs.property("version", project.version)
inputs.property("mcVersion", project.name)
filesMatching("fabric.mod.json") {
expand "version": project.version,
"mcVersion": project.name
}
from(sourceSets.main.resources.srcDirs) {
duplicatesStrategy DuplicatesStrategy.EXCLUDE
exclude "fabric.mod.json"
}
}
// 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
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allSource
}
jar {
from "LICENSE"
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()
}
}