forked from EssentialGG/Vigilance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
313 lines (280 loc) · 10.1 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
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
buildscript {
ext.kotlin_version = "1.5.10"
def mcVersionStr = project.name.tokenize('-')[0]
def (major, minor, patch) = mcVersionStr.tokenize('.')
def mcVersion = "${major}${minor.padLeft(2, '0')}${(patch ?: '').padLeft(2, '0')}" as int
def fabric = mcVersion >= 11400 && project.name.endsWith("-fabric")
project.ext.mcVersion = mcVersion
project.ext.mcVersionStr = mcVersionStr
project.ext.mcPlatform = fabric ? 'fabric' : 'forge'
project.ext.fabric = fabric
project.ext.forge = !fabric
repositories {
mavenCentral()
maven { url "https://maven.fabricmc.net/" }
if (!fabric) maven { url "https://files.minecraftforge.net/maven" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://jitpack.io" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17"
if (fabric) {
classpath 'fabric-loom:fabric-loom.gradle.plugin:0.8-SNAPSHOT'
} else if (mcVersion >= 11400) {
classpath('net.minecraftforge.gradle:ForgeGradle:5.0.5') { // later versions emit tsrg2
exclude group: 'trove', module: 'trove' // preprocessor/idea requires more recent one
}
} else {
def forgeGradleVersion = mcVersion >= 11200 ? '34ab703' : // FG 2.3
mcVersion >= 10904 ? '5d1e8d8' : // FG 2.2
'd1a7165' // FG 2.1
classpath("com.github.ReplayMod:ForgeGradle:$forgeGradleVersion:all") {
exclude group: 'net.sf.trove4j', module: 'trove4j' // preprocessor/idea requires more recent one
exclude group: 'trove', module: 'trove' // different name same thing
}
}
}
}
def FG3 = !fabric && mcVersion >= 11400
def FABRIC = fabric
if (FABRIC) {
apply plugin: 'fabric-loom'
} else if (FG3) {
apply plugin: 'net.minecraftforge.gradle'
} else {
apply plugin: 'net.minecraftforge.gradle.forge'
}
apply plugin: 'kotlin'
apply plugin: 'maven-publish'
apply plugin: 'com.replaymod.preprocess'
sourceCompatibility = targetCompatibility = mcVersion >= 11700 ? 16 : 1.8
repositories {
mavenCentral()
maven { url 'https://repository.apache.org/content/repositories/releases/org/apache/xmlgraphics/' }
maven { url 'https://repo.spongepowered.org/maven' }
maven { url "https://repo.sk1er.club/repository/maven-public" }
}
preprocess {
vars.put("MC", mcVersion)
vars.put("FABRIC", fabric ? 1 : 0)
vars.put("FORGE", forge ? 1 : 0)
}
version = project.parent.version
group = "gg.essential" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "Vigilance" + project.name
if (mcVersion >= 11400) {
sourceSets {
api
}
}
if (FABRIC) {
minecraft {
refmapName = 'mixins.replaymod.refmap.json'
runConfigs.all {
ideConfigGenerated = true
}
}
} else {
minecraft {
if (FG3) {
runs {
client {
workingDirectory rootProject.file('run')
property 'forge.logging.console.level', 'info'
mods {
examplemod {
source sourceSets.main
}
}
}
}
} else {
if (mcVersion >= 10800) {
coreMod = 'com.replaymod.core.LoadingPlugin'
}
runDir = "run"
}
if (!FG3) {
version = [
11202: '1.12.2-14.23.0.2486',
11201: '1.12.1-14.22.0.2444',
11200: '1.12-14.21.1.2387',
11102: '1.11.2-13.20.0.2216',
11100: '1.11-13.19.1.2188',
11002: '1.10.2-12.18.2.2099',
10904: '1.9.4-12.17.0.1976',
10809: '1.8.9-11.15.1.2318-1.8.9',
10800: '1.8-11.14.4.1563',
10710: '1.7.10-10.13.4.1558-1.7.10',
][mcVersion]
mappings = [
11404: "snapshot_20190719-1.14.3",
11202: "snapshot_20170615",
11201: "snapshot_20170615",
11200: "snapshot_20170615",
11102: "snapshot_20161220",
11100: "snapshot_20161111",
11002: "snapshot_20160518",
10904: "snapshot_20160518",
10809: "stable_22",
10800: "snapshot_nodoc_20141130",
10710: "stable_12",
][mcVersion]
} else {
mappings channel: 'snapshot', version: [
11502: '20200220-1.15.1',
11602: '20200723-1.16.1'
][mcVersion]
}
}
}
if (!FABRIC) {
configurations {
modApi
api.extendsFrom(modApi)
modImplementation
implementation.extendsFrom(modImplementation)
}
}
dependencies {
// Using the "mod" prefix will allow Loom to automatically remap the dependencies (to configured yarn mappings) and
// to configure the maven publication such that we externally still depend on the non-remapped dep.
// The Api/Implementation difference is the same as in Gradle.
modImplementation('com.electronwill.night-config:toml:3.6.0')
modImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
modImplementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
modApi("gg.essential:elementa-${mcVersionStr}-${mcPlatform}:370+next") {
exclude module: 'kotlin-reflect'
exclude module: 'kotlin-stdlib-jdk8'
}
testImplementation "io.mockk:mockk:1.9.3"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
testImplementation "io.strikt:strikt-core:0.22.1"
if (FABRIC) {
minecraft 'com.mojang:minecraft:' + [
11404: '1.14.4',
11502: '1.15.2',
11601: '1.16.1',
11602: '1.16.2',
11701: '1.17.1',
][mcVersion]
mappings 'net.fabricmc:yarn:' + [
11404: '1.14.4+build.16',
11502: '1.15.2+build.14',
11601: '1.16.1+build.17:v2',
11602: '1.16.2+build.1:v2',
11701: '1.17.1+build.39:v2',
][mcVersion]
modImplementation 'net.fabricmc:fabric-loader:0.11.6'
def fabricApiVersion = [
11404: '0.4.3+build.247-1.14',
11502: '0.5.1+build.294-1.15',
11601: '0.14.0+build.371-1.16',
11602: '0.17.1+build.394-1.16',
11701: '0.38.1+1.17',
][mcVersion]
def fabricApiModules = [
"api-base",
"networking-v0",
"keybindings-v0",
"resource-loader-v0",
"command-api-v1",
"lifecycle-events-v1",
]
if (mcVersion >= 11600) {
fabricApiModules.add("key-binding-api-v1")
}
fabricApiModules.each { module ->
// Using this combo to add it to our deps but not to our maven publication cause it's only for the example
modRuntime(modCompileOnly(fabricApi.module("fabric-$module", fabricApiVersion)))
}
}
if (FG3) {
minecraft 'net.minecraftforge:forge:' + [
11404: '1.14.4-28.1.113',
11502: '1.15.2-31.1.18',
11602: '1.16.2-33.0.58'
][mcVersion]
}
}
processResources {
inputs.property "version", project.version
filesMatching(['fabric.mod.json']) {
expand 'version': project.version
}
exclude "mcmod.info"
exclude "mods.toml"
exclude "META-INF/mods.toml"
}
compileKotlin {
kotlinOptions {
jvmTarget = mcVersion >= 11700 ? "16" : "1.8"
freeCompilerArgs = ["-Xjvm-default=all"]
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
task wrapper(type: Wrapper) {
gradleVersion = '4.10.3'
}
jar {
exclude 'META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'module-info.class'
exclude('gg/essential/vigilance/example/**')
exclude("META-INF/mods.toml")
exclude("mods.toml")
exclude("kotlin/**")
manifest {
attributes(
'FMLModType': 'LIBRARY'
)
}
}
publishing {
publications {
maven(MavenPublication) {
artifactId = "vigilance-$mcVersionStr-$mcPlatform"
if (!FABRIC) // handled by Loom
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.implementation.allDependencies.each {
if (it.group != null && it.name != null && it.name != "forge" && it.version != null) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
if (FABRIC) {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
} else {
artifact jar
artifact sourcesJar
}
}
}
if (project.hasProperty("nexus_user") && project.hasProperty("nexus_password")) {
repositories {
maven {
name 'nexus'
url "https://repo.sk1er.club/repository/maven-releases/"
credentials {
username project.nexus_user
password project.nexus_password
}
}
}
}
}