forked from FalseHonesty/AsmHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
289 lines (257 loc) · 8.53 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
// For those who want the bleeding edge
buildscript {
ext.kotlin_version = "1.5.31"
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
repositories {
mavenLocal()
gradlePluginPortal()
mavenCentral()
maven {
name = "fabric"
url = "https://maven.fabricmc.net/"
}
if (!fabric) {
maven {
name = "forge"
url = "https://maven.minecraftforge.net/"
}
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven { url 'https://jitpack.io' }
}
dependencies {
if (fabric) {
classpath 'fabric-loom:fabric-loom.gradle.plugin:0.8-SNAPSHOT'
} else if (mcVersion >= 11400) {
classpath('net.minecraftforge.gradle:ForgeGradle:5.0.5') {
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
'48c4f0c' // 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: 'com.replaymod.preprocess'
apply plugin: 'maven-publish'
preprocess {
vars.put("MC", mcVersion)
vars.put("FABRIC", project.fabric ? 1 : 0)
vars.put("FORGE", project.fabric ? 0 : 1)
}
repositories {
mavenCentral()
maven {
url 'https://repository.apache.org/content/repositories/releases/org/apache/xmlgraphics/'
}
maven { url 'https://jitpack.io' }
maven { url "https://repo.sk1er.club/repository/maven-public" }
}
version = "1.5.2"
group = "dev.falsehonesty.asmhelper"
archivesBaseName = "AsmHelper" + project.name
sourceCompatibility = targetCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'
if (mcVersion >= 11400) {
sourceSets {
api
}
}
if (FABRIC) {
minecraft {
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 <= 11202) {
coreMod = "dev.falsehonesty.asmhelper.core.AsmHelperLoadingPlugin"
}
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.1722',
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: '20201028-1.16.3',
][mcVersion]
}
}
}
configurations {
provided
// Make implementation extend from our provided configuration so that things added to bundled end up on the compile classpath
compile.extendsFrom(provided)
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
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.47:v2',
11701: '1.17.1+build.39:v2',
][mcVersion]
modImplementation 'net.fabricmc:fabric-loader:0.11.6'
}
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]
}
}
// Some workaround for FG2 (don't ask me) which is not required for FG3+/Loom
if (mcVersion <= 11202) {
task moveResources {
doLast {
ant.move file: "${buildDir}/resources/main",
todir: "${buildDir}/classes/java"
}
}
moveResources.dependsOn processResources
classes.dependsOn moveResources
}
processResources {
inputs.property "version", project.version
filesMatching(['fabric.mod.json']) {
expand 'version': project.version
}
}
jar {
exclude 'META-INF/INDEX.LIST', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'module-info.class'
exclude('com/example/examplemod/**')
exclude('META-INF/services/dev.falsehonesty.asmhelper.ClassTransformationService')
exclude("META-INF/mods.toml")
exclude("mods.toml")
// exclude("kotlin/**")
manifest {
attributes(
'FMLModType': 'LIBRARY',
'ModSide': 'CLIENT'
)
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
sourceSets {
main {
kotlin {
// exclude 'dev/falsehonesty/asmhelper/example/**'
exclude 'dev/falsehonesty/asmhelpermod/**'
}
}
}
publishing {
publications {
maven(MavenPublication) {
artifactId = "AsmHelper"
def fabricStr = FABRIC ? "-fabric" : ""
def snapshotStr = this.properties.getOrDefault("IS_CI", false) ? "-SNAPSHOT" : ""
version = "${project.version}-$mcVersion$fabricStr$snapshotStr"
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)
}
}
}
artifact jar
artifact sourcesJar
}
}
if (project.hasProperty("nexus_user") && project.hasProperty("nexus_password")) {
repositories {
maven {
name 'nexus'
url "https://repo.sk1er.club/repository/maven-${this.properties.getOrDefault("IS_CI", false) ? "snapshots" : "releases"}/"
credentials {
username project.nexus_user
password project.nexus_password
}
}
}
}
}