This repository has been archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
386 lines (328 loc) · 9.48 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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath "gradle.plugin.net.minecrell:licenser:0.2.1"
}
}
plugins {
id "com.wynprice.cursemaven" version "2.1.1"
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: net.minecrell.gradle.licenser.Licenser
apply plugin: 'idea'
idea {
module {
// if you hate browsing Javadoc
downloadJavadoc = true
// and love reading sources :)
downloadSources = true
}
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
jcenter()
maven {
name = "Modmuss50"
url = "https://maven.modmuss50.me/"
}
maven {
// JEI
name "JEI"
url "https://dvs1.progwml6.com/files/maven"
}
maven {
// MC MultiPart
name = "Amadornes"
url "http://maven.amadornes.com/"
}
maven {
// CraftTweaker2
name "Jared"
url "http://maven.blamejared.com/"
}
maven {
// TheOneProbe
url "http://maven.tterrag.com/"
}
maven {
// IC2
name = "ic2"
url = "http://maven.ic2.player.to/"
}
maven {
// HWYLA
name "TehNut"
url "http://tehnut.info/maven/"
}
maven {
name 'CB Repo'
url "http://chickenbones.net/maven/"
}
maven {
// CoFH
name 'Covers'
url "http://maven.covers1624.net/"
}
maven {
name "OpenComputer"
url "http://maven.cil.li/"
}
maven {
// Forgelin
url "http://maven.shadowfacts.net/"
}
maven {
// Mekanism, Baubles, Industrial Foregoing, Tesla, AE2
name "CurseForge"
url "https://minecraft.curseforge.com/api/maven/"
}
ivy {
name "BuildCraft"
artifactPattern "https://www.mod-buildcraft.com/releases/BuildCraft/[revision]/[module]-[revision].[ext]"
}
}
version = "1.4.0"
def ENV = System.getenv()
if (ENV.BUILD_NUMBER) {
version = version + "." + "${System.getenv().BUILD_NUMBER}"
}
minecraft {
version = "1.12.2-14.23.5.2847"
mappings = "stable_39"
replace "@MODVERSION@", project.version
useDepAts = true
runDir = "run"
}
license {
header file('HEADER')
include '**/*.java'
ignoreFailures = true //Stops the build from failing if a file does not have a license header
}
group = 'TechReborn-ModCompatibility'
dependencies {
deobfCompile("RebornCore:RebornCore-1.12.2:+:universal") {
transitive = false
}
deobfCompile("TechReborn:TechReborn-1.12.2:+:universal") {
transitive = false
}
deobfCompile ("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.554") {
transitive = true
}
deobfCompile ("baubles:Baubles:1.12:1.5.2") {
transitive = false
}
deobfCompile ("net.industrial-craft:industrialcraft-2:2.8.+") {
transitive = false
}
deobfCompile ("tesla-core-lib:tesla-core-lib:1.12.2:1.0.15") {
transitive = false
}
deobfCompile ("mcp.mobius.waila:Hwyla:1.8+:api") {
transitive = false
}
deobfCompile ("li.cil.oc:OpenComputers:MC1.12.2-1.7.5+") {
transitive = false
}
deobfCompile ("net.sengir.forestry:forestry_1.12.2:+") {
transitive = false
}
deobfCompile ("cofh:CoFHCore:1.12.2-+:universal") {
transitive = false
}
deobfCompile ("cofh:RedstoneFlux:1.12-2.1+:universal") {
transitive = false
}
deobfCompile ("cofh:CoFHWorld:1.12.2-+:universal") {
transitive = false
}
deobfCompile ("cofh:ThermalFoundation:1.12.2-+:universal") {
transitive = false
}
deobfCompile ("cofh:ThermalExpansion:1.12.2-+:universal") {
transitive = false
}
deobfCompile ("appeng:appliedenergistics2:rv6-stable-7") {
transitive = false
}
deobfCompile "mezz.jei:jei_1.12.2:+"
deobfCompile name: 'buildcraft-main', version: '7.99.24.6', ext: 'jar'
deobfCompile "mcjty.theoneprobe:TheOneProbe-1.12:1.12-1.4.+"
deobfProvided "codechicken:CodeChickenLib:1.12.2-+:universal"
runtime "net.shadowfacts:Forgelin:1.8.2" //Needed by tesla-core-lib :D
}
jar {
classifier = 'universal'
}
publishing {
publications {
maven(MavenPublication) {
groupId 'TechReborn'
artifactId project.archivesBaseName
version project.version
from components.java
//Removes all of the dependencies from the maven pom, fixes issues when other projects try to depend on tr
pom.withXml {
asNode().remove(asNode().get('dependencies'))
}
}
}
repositories {
maven {
url "http://mavenupload.modmuss50.me/"
if (project.hasProperty('mavenPass')) {
credentials {
username 'buildslave'
password project.getProperty('mavenPass')
}
}
}
}
}
apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/ideconfig.gradle'
task signJar(type: SignJar, dependsOn: reobfJar) {
onlyIf {
project.hasProperty('keyStore')
}
if (project.hasProperty('keyStore')) {
keyStore = project.keyStore
alias = project.keyStoreAlias
storePass = project.keyStorePass
keyPass = project.keyStoreKeyPass
inputFile = jar.archivePath
outputFile = jar.archivePath
}
}
build.dependsOn signJar
import com.google.gson.GsonBuilder
import com.google.gson.JsonObject
import com.google.gson.JsonArray
import org.apache.commons.io.IOUtils
import java.util.zip.ZipFile
//Reads the new fml_cache_annotation file built into the jar file, to find all crafttweaker methods, and saves the data to a file
task mtDocGen {
doLast{
def inputFile = new File(jar.archivePath.getAbsolutePath())
println("Reading " + inputFile.getName() + " for crafttweaker documentation")
def jarFile = new ZipFile(inputFile)
def annotation_cache = jarFile.getEntry("META-INF/fml_cache_annotation.json")
def cache_json = IOUtils.toString(jarFile.getInputStream(annotation_cache), "UTF-8")
def jsonObject = new GsonBuilder().create().fromJson(cache_json, JsonObject.class)
def builder = new StringBuilder()
for(entry in jsonObject.entrySet()){
def clzz = entry.value.asJsonObject
if(!clzz.has("annotations")){
continue
}
def annoations = clzz.get("annotations").asJsonArray
for(annotation in annoations.toList()){
if(annotation.asJsonObject.get("type").asString.equals("METHOD") && annotation.asJsonObject.get("name").asString.equals("Lstanhebben/zenscript/annotations/ZenMethod;")){
def method = sanitsiseMethodName(annotation.asJsonObject.get("target").asString)
if(hasZenDoc(annotation, annoations)){
method = getZenDoc(annotation, annoations)
}
def zen_name = getZenMetName(clzz)
builder.append(zen_name + "." + method)
builder.append("\n")
}
}
}
def outputFile = new File(jar.archivePath.getAbsolutePath().replace(".jar", "-crafttweaker.txt"))
outputFile.write builder.toString()
println("Crafttweaker documentation saved to " + outputFile.name)
}
}
boolean hasZenDoc(JsonObject currentAnnotation, JsonArray annoations){
for(annotation in annoations.toList()){
if(annotation.asJsonObject.get("target").asString.equals(currentAnnotation.get("target").asString) && annotation.asJsonObject.get("name").asString.equals("Ltechreborn/compat/crafttweaker/ZenDocumentation;")){
return true
}
}
return false
}
String getZenDoc(JsonObject currentAnnotation, JsonArray annoations){
for(annotation in annoations.toList()){
if(annotation.asJsonObject.get("target").asString.equals(currentAnnotation.get("target").asString) && annotation.asJsonObject.get("name").asString.equals("Ltechreborn/compat/crafttweaker/ZenDocumentation;")){
def methodName = annotation.asJsonObject.get("target").asString.split("\\(")[0]
def methodParams = annotation.asJsonObject.get("value").asJsonObject.get("value").asString
if(!methodParams.startsWith("(")){
methodParams = "(" + methodParams
}
if(!methodParams.endsWith(")")){
methodParams = methodParams + ")"
}
return methodName + methodParams
}
}
return ""
}
//Gets the zenMethod class name from the class json object
String getZenMetName(JsonObject jsonObject){
def annoations = jsonObject.get("annotations").asJsonArray
for(annotation in annoations.toList()){
if(annotation.asJsonObject.get("type").asString.equals("CLASS") && annotation.asJsonObject.get("name").asString.equals("Lstanhebben/zenscript/annotations/ZenClass;")){
return annotation.asJsonObject.get("value").asJsonObject.get("value").asString
}
}
}
String sanitsiseMethodName(String methodSig){
def builder = new StringBuilder()
def name = methodSig.split("\\(")[0]
builder.append(name)
builder.append("(")
def methodArgs = methodSig.split("\\(")[1].split("\\)")[0].split(";")
for(arg in methodArgs){
def argSlit = arg.split("/")
def argStr = argSlit[argSlit.length -1]
//If a class is not in a package I assume its a primitive //TODO any suggestions for a better way to do this?
if(!arg.contains("/") && !arg.isEmpty()){
argStr = humanizeArg(argStr)
}
builder.append(argStr)
//Dont add the comma to the last arg
if(arg != methodArgs[methodArgs.length - 1]){
builder.append(",")
}
}
builder.append(")")
return builder.toString()
}
//Argumets that are java primitives do not use a freindly name, this method replaces them with something most people will understand
String humanizeArg(String arg){
def primitiveMap = [
Z: "Boolean",
B: "Byte",
C: "Char",
D: "Double",
F: "Float",
I: "Integer",
J: "Long",
L: "Object",
S: "Short"
]
def builder = new StringBuilder()
for(cha in arg.toCharArray()){
builder.append(primitiveMap.get(cha.toString().toUpperCase()))
builder.append(",")
}
//Removes the last ,
return builder.toString().substring(0, builder.toString().length() - 1)
}