This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
forked from N1nt4nd0/Xenobyte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
140 lines (121 loc) · 4.23 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
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "https://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
flatDir dirs: "$projectDir/proguard/lib/"
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT"
classpath ":proguard:"
}
}
apply plugin: "forge"
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
[compileJava, compileTestJava]*.options*.encoding = "UTF-8"
version = "1.0.0"
group = "forgefuck.team.xenobyte"
archivesBaseName = "xenobyte"
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "minecraft-debug"
}
configurations {
bundle
compile.extendsFrom bundle
}
repositories {
jcenter()
}
dependencies {
bundle fileTree(dir: "libs", includes: ["*.jar"])
}
jar {
from {
configurations.bundle.collect { it.isDirectory() ? it : zipTree(it); }
}
}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"
expand "version" : project.version, "mcversion" : project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
}
def generateString(String alphabet, int n) {
return new Random().with {
(1..n).collect { alphabet[nextInt(alphabet.length())] }.join()
}
}
def generateDictionaryFile(String name) {
File dictionaryFile = new File(name)
if (dictionaryFile.exists())
return;
String outputData = ""
for (int i = 0; i < 10000; i++)
outputData += generateString((('a'..'z') + ('A'..'Z') + ('0'..'9')).join(), 16) + "\n"
dictionaryFile.getParentFile().mkdirs()
dictionaryFile.delete()
dictionaryFile.write outputData
}
task generateDictionary {
doFirst {
generateDictionaryFile("$buildDir/proguard/class-dictionary.txt")
generateDictionaryFile("$buildDir/proguard/package-dictionary.txt")
generateDictionaryFile("$buildDir/proguard/fieldmethod-dictionary.txt")
}
}
task obfuscateProGuard(type: proguard.gradle.ProGuardTask) {
doFirst {
injars "$buildDir/libs/" + project.tasks["jar"].archiveName
outjars "$buildDir/libs/final-" + project.tasks["jar"].archiveName
libraryjars "${System.getProperty("java.home")}/lib/rt.jar"
libraryjars "${System.getProperty("java.home")}/lib/jce.jar"
libraryjars sourceSets.main.compileClasspath
keepattributes "RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations,RuntimeVisibleTypeAnnotations"
keep "class !forgefuck.team.xenobyte.** { *; }"
classobfuscationdictionary "$buildDir/proguard/class-dictionary.txt"
packageobfuscationdictionary "$buildDir/proguard/package-dictionary.txt"
obfuscationdictionary "$buildDir/proguard/fieldmethod-dictionary.txt"
dontshrink
dontoptimize
printmapping "$buildDir/libs/proguard-" + project.tasks["jar"].archiveName + ".map"
}
}
task createJavaInjectorComment {
doFirst {
File mainClassFile = new File("$projectDir/mainclass.txt")
if (mainClassFile.exists())
mainClassFile.delete()
String mappingsText = new File("$buildDir/libs/proguard-" + project.tasks["jar"].archiveName + ".map").text
java.util.regex.Pattern p = java.util.regex.Pattern.compile("forgefuck\\.team\\.xenobyte\\.api\\.integration\\.JavaInjector -> (.*?):")
java.util.regex.Matcher m = p.matcher(mappingsText)
m.find();
new File("$projectDir/mainclass.txt").write m.group(1);
}
}
task copyJar {
doFirst {
copy {
from "$buildDir/libs"
include "final-" + project.tasks["jar"].archiveName
into "$buildDir/libs"
rename "final-" + project.tasks["jar"].archiveName, project.tasks["jar"].archiveName
}
}
}
obfuscateProGuard.dependsOn generateDictionary
createJavaInjectorComment.dependsOn obfuscateProGuard
copyJar.dependsOn createJavaInjectorComment
reobf.dependsOn copyJar