forked from CCEmuX/CCEmuX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
213 lines (169 loc) · 5.89 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
buildscript {
dependencies {
classpath 'net.sf.proguard:proguard-gradle:6.1.0beta1'
classpath 'com.google.code.gson:gson:2.8.1'
}
}
plugins {
id 'java-library'
id 'application'
id 'com.github.johnrengelman.shadow' version '2.0.1'
id 'eclipse'
id 'idea'
}
allprojects {
apply plugin: 'java-library'
apply plugin: 'eclipse'
apply plugin: 'idea'
group = 'net.clgd'
version = '1.0.0'
sourceCompatibility = 1.8
targetCompatibility = 1.8
eclipse.project {
natures 'org.eclipse.buildship.core.gradleprojectnature'
natures 'org.springsource.ide.eclipse.gradle.core.nature'
}
repositories {
mavenCentral()
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.16.20'
testCompileOnly 'org.projectlombok:lombok:1.16.20'
compileOnly 'com.google.auto.service:auto-service:1.0-rc3'
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint" << "-Xlint:-processing" << "-Xlint:-rawtypes" << "-Xlint:-classfile"
}
}
}
mainClassName = 'net.clgd.ccemux.init.Launcher'
repositories {
maven {
name = "cc.crzd.me"
url = "http://cc.crzd.me/maven"
}
maven {
name = 'cc-tweaked'
url = "http://squiddev.cc/maven/"
}
}
configurations {
computercraft
}
dependencies {
api project(':plugin-api')
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.11.2'
implementation 'org.apache.logging.log4j:log4j-core:2.11.2'
implementation 'commons-cli:commons-cli:1.4'
implementation 'org.apache.commons:commons-lang3:3.6'
implementation 'io.netty:netty-all:4.1.9.Final'
implementation 'com.google.code.gson:gson:2.8.1'
testCompile 'junit:junit:4.12'
computercraft 'dan200.computercraft:ComputerCraft:1.80pr1-build5'
}
processResources {
exclude '**/*.xcf' // GIMP images
filesMatching("ccemux.version") {
expand 'version': version
}
}
jar {
manifest {
attributes 'SplashScreen-Image': 'img/splash2.gif'
attributes 'Implementation-Version': version
attributes 'Main-Class': mainClassName
}
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import proguard.gradle.ProGuardTask
shadowJar {
classifier = 'base'
description "A shadowed jar which bundles all dependencies aside from CC"
from sourceSets.main.output
configurations = [project.configurations.runtimeClasspath]
dependencies {
exclude dependency('.*:cc-tweaked-1.12.2:.*')
}
}
task cctweakedJar(type: ShadowJar) {
classifier = 'cct'
description "A shadowed jar which bundles CC: Tweaked"
from sourceSets.main.output
configurations = [project.configurations.runtimeClasspath]
manifest.inheritFrom jar.manifest
}
task computercraftJar(type: ShadowJar) {
classifier = 'cc'
description "A shadowed jar which bundles ComputerCraft"
from sourceSets.main.output
configurations = [project.configurations.runtimeClasspath, project.configurations.computercraft]
manifest.inheritFrom jar.manifest
dependencies {
exclude dependency('.*:cc-tweaked-1.12.2:.*')
}
}
task cctweakedMin(type: ProGuardTask) {
injars cctweakedJar.archivePath
outjars "${cctweakedJar.archivePath.absolutePath.replace(".jar", "")}-min.jar"
}
task computercraftMin(type: ProGuardTask) {
injars computercraftJar.archivePath
outjars "${computercraftJar.archivePath.absolutePath.replace(".jar", "")}-min.jar"
// Ignore some CC:T specific code
dontwarn "dan200.computercraft.core.apis.handles.ArrayByteChannel"
dontwarn "net.clgd.ccemux.init.UserConfigCCTweaked"
}
gradle.projectsEvaluated {
tasks.withType(ShadowJar) {
// Append the base license files
append 'META-INF/LICENSE'
append 'META-INF/LICENSE.txt'
append 'META-INF/NOTICE'
append 'META-INF/NOTICE.txt'
// Exclude random junk
exclude '*.html'
exclude 'META-INF/maven/*/*/*.*'
// Prune arbitrary stuff from the CC jar
exclude(['api/dan200/**', 'docs/**'])
exclude(['assets/computercraft/**/*.json', 'assets/computercraft/textures/blocks/*', 'assets/computercraft/textures/items/*'])
}
tasks.withType(ProGuardTask) {
libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
libraryjars "${System.getProperty('java.home')}/lib/jce.jar"
libraryjars "${System.getProperty('java.home')}/lib/ext/jfxrt.jar"
// Ignore references to these packages
["net.minecraft", "net.minecraftforge", "org.apache.bcel"].each { dontwarn "${it}.**" }
// Ignore any warnings in these packages. They have a lot of soft dependencies.
["io.netty", "org.apache.logging", "org.slf4j"].each { dontwarn "${it}.**" }
// It appears in the constant table, but not in the actual code, hence we need to ignore it.
dontwarn "lombok.val"
// Exclude the non-core portions of CC. These end up referencing a lot of MC stuff indirectly.
["client", "shared", "server"].each { dontwarn "dan200.computercraft.${it}.**" }
dontwarn "dan200.computercraft.core.tracking.ComputerTracker"
dontwarn "dan200.computercraft.api.turtle.**"
dontwarn "org.apache.commons.io.IOUtils"
// We want to avoid as much obfuscation as possible. We're only doing this to shrink code size
dontobfuscate; dontoptimize; keepattributes; keepparameternames
keepdirectories "assets/computercraft/lua**"
keepdirectories "rom/**"
// Keep all members of an enum. Otherwise things like EnumSet start complaining
keep "enum ** { *; }"
// Keep all MBean interfaces.
keep "interface **MBean { public *; }"
// Log4j bundles Java 9 versions, which is great, but rather breaks Proguard
dontwarn 'module-info'
[
// Preserve all dependencies of the plugin-api
"net.clgd.ccemux", "dan200.computercraft", "com.google.common", "org.slf4j",
// We use reflection to create library functions, so we need to be a little basic.
"org.squiddev.cobalt.lib", "org.luaj.vm2.lib",
// Ideally we could strip more from here, but this'll do for now
"org.apache.logging.log4j",
].each { keep "class ${it}.** { *; }" }
}
}
run { standardInput = System.in }
runShadow { standardInput = System.in }
assemble.dependsOn tasks.withType(ShadowJar)
assemble.dependsOn tasks.withType(ProGuardTask)