forked from SpongePowered/Mixin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
359 lines (315 loc) · 10.2 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
// Gradle repositories and dependencies
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.0'
}
}
// Apply plugin
apply plugin: 'java'
apply plugin: 'license'
apply plugin: 'checkstyle'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'com.github.johnrengelman.shadow'
// Default tasks
defaultTasks 'licenseFormat', 'check', 'build'
// Basic project information
group = 'org.spongepowered'
archivesBaseName = 'mixin'
version = buildVersion + (buildType == 'RELEASE' ? '' : "-$buildType")
// Extended project information
ext.projectName = 'Mixin'
ext.inceptionYear = '2014'
ext.packaging = 'jar'
// Define variables
ext.buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0'
ext.ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown'
ext.commit = project.hasProperty("commit") ? commit : 'unknown'
// Minimum version of Java required
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
// Project repositories
repositories {
mavenCentral()
maven {
name = 'minecraft'
url = 'https://libraries.minecraft.net/'
}
flatDir {
name = 'renamed-packages'
dirs = files("build/renamed-packages/")
}
maven {
// For fernflower
name = 'sponge'
url = 'http://repo.spongepowered.org/maven'
}
}
configurations {
deployerJars // maven stuff
asm // renamer input
jarjar // renamer task
// Exclude non-repackaged ASM so that we don't use it by mistake
compile.exclude module: 'asm-debug-all'
}
configurations.all {
// Force use of Guava 17.0 so that srg2source doesn't evict it
resolutionStrategy {
force 'com.google.guava:guava:17.0'
}
}
// Include annotation processor sourceSet
sourceSets {
ap {
compileClasspath += main.output
}
fernflower {
compileClasspath += main.output
}
agent {
compileClasspath += main.output
}
bridge {
compileClasspath += main.output
}
example {
compileClasspath += main.output
compileClasspath += ap.output
}
}
// Dependencies for renamed ASM
dependencies {
asm 'org.ow2.asm:asm-debug-all:5.0.3'
asm 'org.ow2.asm:asm-debug-all:5.0.3:sources'
jarjar 'com.googlecode.jarjar:jarjar:1.1'
compile 'com.googlecode.jarjar:jarjar:1.1'
}
// Task to read ASM library and rename packages
task renamedASM {
outputs.file files(configurations.asm.files.findAll{!it.name.contains("sources")}.collect { file ->
new File(project.repositories['renamed-packages'].dirs[0], "mixin-" + file.name).path
})
doLast {
ant {
taskdef (
name: "jarjar",
classname: "com.tonicsystems.jarjar.JarJarTask",
classpath: configurations.jarjar.asPath,
)
outputs.files.eachWithIndex { elem, index ->
logger.info "Generating renamed jar {}", elem.name
jarjar (jarfile: elem.path) {
zipfileset (src: configurations.asm.files[index])
rule (
pattern: "org.objectweb.asm.**",
result: "org.spongepowered.asm.lib.@1"
)
}
}
}
}
}
eclipseClasspath.dependsOn(renamedASM)
// Project dependencies
dependencies {
compile 'org.slf4j:slf4j-api:1.7.7'
compile 'com.google.guava:guava:17.0'
compile 'com.google.code.gson:gson:2.2.4'
exampleCompile 'com.google.code.gson:gson:2.2.4'
compile 'commons-io:commons-io:2.4'
compile 'commons-codec:commons-codec:1.9'
apCompile 'com.google.guava:guava:17.0'
exampleCompile 'com.google.guava:guava:17.0'
testCompile 'junit:junit:4.11'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'org.mockito:mockito-core:1.9.0'
// maven
deployerJars 'org.apache.maven.wagon:wagon-ftp:2.7'
// remapped ASM
compile tasks.renamedASM.outputs.files
apCompile tasks.renamedASM.outputs.files
agentCompile tasks.renamedASM.outputs.files
// fernflower bridge
fernflowerCompile 'commons-io:commons-io:2.4'
fernflowerCompile 'org.apache.logging.log4j:log4j-core:2.0-beta9'
fernflowerCompile 'com.google.guava:guava:17.0'
fernflowerCompile 'org.jetbrains.java.decompiler:fernflower:sponge-SNAPSHOT'
compile 'org.jetbrains.java.decompiler:fernflower:sponge-SNAPSHOT'
compile 'net.minecraft:launchwrapper:1.11'
agentCompile 'net.minecraft:launchwrapper:1.11'
// asm bridge
compile 'org.ow2.asm:asm-commons:5.0.3'
bridgeCompile 'org.ow2.asm:asm-commons:5.0.3'
bridgeCompile 'org.apache.logging.log4j:log4j-core:2.0-beta9'
}
// Filter, process, and include resources
processResources {
// Include in final JAR
from 'LICENSE.txt'
}
// License header formatting
license {
ext {
name = project.name
organization = project.organization
url = project.url
}
include '**/*.java'
header file("HEADER.txt")
sourceSets = project.sourceSets
ignoreFailures false
strictCheck true
mapping {
java = 'SLASHSTAR_STYLE'
}
}
checkstyle {
configProperties = [
"name" : project.name,
"organization": project.organization,
"url" : project.url,
"year" : project.inceptionYear
]
configFile = file("checkstyle.xml")
}
// Source compiler configuration
tasks.withType(JavaCompile) {
options.compilerArgs += ['-Xlint:all', '-Xlint:-path']
options.deprecation = true
options.encoding = 'utf8'
}
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
// disable the crazy super-strict doclint tool in Java 8
options.addStringOption('Xdoclint:none', '-quiet')
}
}
jar {
// Include annotation processor
from sourceSets.ap.output
// Include fernflower bridge
from sourceSets.fernflower.output
// Include hotswap agent
from sourceSets.agent.output
// Bridge
from sourceSets.bridge.output
// Renamed ASM
from zipTree(tasks.renamedASM.outputs.files[0])
exclude 'org/objectweb/**'
exclude 'org/spongepowered/asm/lib/commons/**'
exclude 'org/spongepowered/asm/lib/xml/**'
// JAR manifest configuration
manifest.mainAttributes(
"Built-By": System.properties['user.name'],
"Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
"Implementation-Title": name,
"Implementation-Version": version + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit,
"Implementation-Vendor": url,
// for hotswap agent
"Premain-Class": "org.spongepowered.tools.agent.MixinAgent",
"Agent-Class": "org.spongepowered.tools.agent.MixinAgent",
"Can-Redefine-Classes": true,
"Can-Retransform-Classes": true)
}
// generate shadow jar so we can use the AP standalone
shadowJar {
from sourceSets.ap.output
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
dependencies {
include(dependency('com.google.guava:guava'))
include(dependency('com.google.code.gson:gson'))
include(dependency('commons-io:commons-io'))
include(dependency('net.minecraftforge.srg2source:Srg2Source'))
include(dependency('net.sf.jopt-simple:jopt-simple'))
}
classifier = 'processor'
}
build.dependsOn(shadowJar)
// Run this task instead of build to generate a timestamped shadow jar (for dev)
task timestamp(type: Jar, dependsOn: build) {
if (gradle.startParameter.taskNames.contains(name)) {
shadowJar.classifier = new Date().format('yyyyMMddHHmmss')
}
}
task sourceJar(type: Jar) {
from sourceSets.main.java
from sourceSets.main.resources
from sourceSets.ap.java
from sourceSets.ap.resources
from sourceSets.fernflower.java
from sourceSets.fernflower.resources
from sourceSets.agent.java
from sourceSets.agent.resources
from sourceSets.bridge.java
from sourceSets.bridge.resources
from sourceSets.example.java
from sourceSets.example.resources
classifier = "sources"
}
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
classifier = "javadoc"
}
artifacts {
archives jar
archives sourceJar
archives javadocJar
}
uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.deployerJars
if (project.hasProperty("chRepo"))
{
repository(url: project.chRepo) {
authentication(userName: project.chUsername, password: project.chPassword)
}
}
pom {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
project {
name project.archivesBaseName
packaging 'jar'
description 'Sponge API'
url 'http://www.spongepowered.org/'
scm {
url 'https://github.com/SpongePowered/Mixin'
connection 'scm:git:git://github.com/SpongePowered/Mixin.git'
developerConnection 'scm:git:[email protected]:SpongePowered/Mixin.git'
}
issueManagement {
system 'GitHub Issues'
url 'https://github.com/SpongePowered/Mixin/issues'
}
licenses {
license {
name 'MIT license'
url 'http://opensource.org/licenses/MIT'
distribution 'repo'
}
}
}
whenConfigured {
dependencies = dependencies.findAll {
!it.artifactId.contains('fernflower')
}
}
}
}
}
}
install.repositories.mavenInstaller.pom {
whenConfigured {
dependencies = dependencies.findAll {
!it.artifactId.contains('fernflower')
}
}
}