forked from ForgeEssentials/ForgeEssentials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
450 lines (378 loc) · 11.7 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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
// Build repositories
buildscript {
repositories {
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/releases/"
}
maven {
name = "sponge"
url = "http://repo.spongepowered.org/maven/"
}
mavenCentral()
mavenLocal()
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
jcenter()
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.1"
classpath "org.ajoberstar:gradle-git:0.12.0"
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
}
}
plugins {
id 'org.spongepowered.plugin' version '0.6'
id 'org.sonarqube' version '2.5'
}
apply plugin: 'jacoco'
sonarqube {
properties {
properties['sonar.projectKey'] = "com.forgeessentials:forgeessentials"
properties['sonar.projectName'] = project.name
properties['sonar.projectVersion'] = project.version
}
}
// Set up FE required repositories
repositories {
maven {
name = "sk89q"
url = "http://maven.enginehub.org/repo/"
}
maven {
name = "sponge"
url = "http://repo.spongepowered.org/maven/"
}
maven {
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
maven {
name "Sonatype (Cubic Chunks)"
url "https://oss.sonatype.org/content/repositories/public/"
}
maven {
name = "LatMod"
url "https://maven.latmod.com/"
}
maven {
name = "JEI"
url "http://dvs1.progwml6.com/files/maven"
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'org.spongepowered.mixin'
/************************************************************
* General configuration
*/
// Get buildNumber from environment variable
ext.buildNumber = "0"
if (System.getenv("BUILD_NUMBER") != null) {
buildNumber = System.getenv("BUILD_NUMBER")
}
// Get commit hash
import org.ajoberstar.grgit.Grgit
def repo = Grgit.open(project.file("."))
ext.gitCommitHash = repo.log().find().abbreviatedId
// Set build properties
version = "$baseVersion.$buildNumber"
group = "com.forgeessentials"
archivesBaseName = "forgeessentials"
sourceCompatibility = 1.8
targetCompatibility = 1.8
// Set up forge options
minecraft {
version = "$project.minecraftVersion-$project.forgeVersion"
runDir = "rundir"
mappings = "snapshot_20180304"
replaceIn "src/utils/java/com/forgeessentials/commons/BuildInfo.java"
replace (["_BASEVERSION_":baseVersion,"_MCVERSION_":project.minecraftVersion])
}
// Configure shared manifest
ext.sharedManifest = manifest {
attributes (
"BuildID": gitCommitHash,
"BuildNumber": buildNumber,
"FMLCorePluginContainsFMLMod": "true",
"ForceLoadAsMod": "true",
"MixinCompatibilityLevel": "JAVA_8",
)
}
ext.serverManifest = manifest {
from sharedManifest
attributes (
"TweakClass": "com.forgeessentials.core.preloader.FELaunchHandler",
"TweakOrder": "0",
"MixinConfigs": "mixins.forgeessentials.json",
"FMLAT": "forgeessentials_at.cfg",
)
}
/************************************************************
* Dependency configuration
*/
// Create dependency configurations
configurations {
includeMod
shade
shadeClient
serverLib
compile.extendsFrom shade, shadeClient, serverLib
mavenDeps
}
// def jdkHome = System.getenv("JAVA_HOME")
// Configure dependencies (build-only, shaded and packed libraries)
dependencies {
// IRC
serverLib("org.pircbotx:pircbotx:2.0.1") {
// these are all packaged with the minecraft server jar
exclude module: 'guava'
exclude module: 'commons-lang3'
exclude module: 'commons-codec'
}
// Shade Mixin library
shade (group: "org.spongepowered", name: "mixin", version: "0.8.1-SNAPSHOT") {
exclude group: 'org.ow2.asm', module: 'asm-tree'
}
shadeClient (group: "org.spongepowered", name: "mixin", version: "0.8.1-SNAPSHOT") {
exclude group: 'org.ow2.asm', module: 'asm-tree'
}
// Database libraries
serverLib group: 'com.h2database', name: 'h2', version: '1.3.175'
serverLib group: 'mysql', name: 'mysql-connector-java', version: '5.1.22'
serverLib group: 'org.hibernate', name: 'hibernate-core', version: '5.2.2.Final'
compile group: 'org.hibernate', name: 'hibernate-jpamodelgen', version: '5.2.2.Final'
/* serverLib "org.eclipse.persistence:eclipselink:2.6.0" */
// WorldEdit
compile "com.sk89q.worldedit:worldedit-core:6.1.4-SNAPSHOT"
deobfCompile "com.sk89q.worldedit:worldedit-forge-mc1.10.2:6.1.5"
compile "baubles:Baubles:1.12:1.5.2"
//deobfProvided files('lib/worldedit-forge-mc1.10.2-6.1.4-dist.jar')
mavenDeps "com.sk89q.worldedit:worldedit-core:6.1.4-SNAPSHOT"
//buildDep "org.spongepowered:spongeforge:3.1.0-BETA-1046:deobf"
provided 'org.spongepowered:spongeapi:6.0.0'
provided ("io.github.opencubicchunks:cubicchunks-api:1.12.2-0.0-SNAPSHOT") {
exclude group: "org.spongepowered", module: "mixin"
}
provided "com.feed_the_beast.mods:FTBLib:5.4.4.5"
provided "com.feed_the_beast.mods:FTBUtilities:5.4.0.124"
// TOOLS.jar from jdk for javadoc support
// compile files("$jdkHome/lib/tools.jar")
compile files(System.getenv("JAVA_HOME") + "/lib/tools.jar")
}
/************************************************************
* Configure source sets (e.g., src/main)
*/
sourceSets {
def deps = [
configurations.forgeGradleMcDeps,
configurations.forgeGradleMc,
configurations.provided
]
utils {
compileClasspath = files(configurations.compile, sourceSets.api.output)
compileClasspath += files deps
}
main {
compileClasspath = files(configurations.compile, sourceSets.api.output, sourceSets.utils.output)
compileClasspath += files deps
refMap = "mixins.forgeessentials.refmap.json"
}
client {
compileClasspath = files(configurations.compile, sourceSets.api.output, sourceSets.utils.output)
compileClasspath += files deps
refMap = "mixins.forgeessentials.client.refmap.json"
}
}
// Configure server resource processing
project.processResources {
from (sourceSets.main.resources.srcDirs) {
include "mcmod.info"
expand (
"version": project.version,
"mcversion": project.minecraft.version,
)
}
}
// Configure client resource processing
project.processClientResources {
from (sourceSets.client.resources.srcDirs) {
include "mcmod.info"
expand (
"version": project.version,
"mcversion": project.minecraft.version,
)
}
}
/************************************************************
* Configure server jar (default)
*/
// Javadoc task for generating tsd - does not work yet
task tsd(type: Javadoc) {
dependsOn "classes"
source = fileTree(dir: 'src/main/java/com/forgeessentials/jscripting/fewrapper', include: 'ScriptExtensionRoot.java')
classpath = project.sourceSets.main.compileClasspath
options.doclet = "com.forgeessentials.jscripting.TsdGenerator"
options.docletpath = [ file("build/classes/main") ]
options.addStringOption("sourcepath", "src/main/java")
options.addStringOption("subpackages", "com.forgeessentials.jscripting.fewrapper")
options.addStringOption("out", "jscripting/fe.d.ts")
options.addStringOption("header", "src/main/resources/com/forgeessentials/jscripting/fe_header.d.ts")
options.addStringOption("interface", "com.forgeessentials.jscripting.fewrapper.fe.JsFEServer")
options.addStringOption("static", "com.forgeessentials.jscripting.fewrapper.fe.JsPermissions")
}
// Pack libraries as zip file to include them in the jar file
task serverLibArchive(type: Zip) {
archiveName = "libraries.zip"
destinationDir = jar.destinationDir
from (configurations.serverLib.copyRecursive()) { into("ForgeEssentials/lib") }
from (configurations.includeMod) { into("mods") }
}
jar.doLast {
delete (serverLibArchive.archivePath)
}
// Configure server jar (default)
jar {
dependsOn "serverLibArchive"
classifier = "server"
appendix = minecraft.version
from sourceSets.main.output
from sourceSets.utils.output
exclude('com/forgeessentials/client/**')
from fileTree(serverLibArchive.archivePath)
configurations.shade.copyRecursive().setTransitive(false).each { artifact ->
from (zipTree(artifact))
}
manifest {
from serverManifest
}
}
/************************************************************
* Configure client jar
*/
task clientJar (dependsOn: "clientClasses", type: Jar) {
classifier = "client"
appendix = minecraft.version
from sourceSets.client.output
from sourceSets.utils.output
configurations.shadeClient.copyRecursive().setTransitive(false).each { artifact ->
from (zipTree(artifact))
}
manifest {
from sharedManifest
attributes (
"MixinConfigs": "mixins.forgeessentials.client.json",
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
)
}
}
/************************************************************
* Deobfuscated server jar
* Dependency name for maven = com.forgeessentials:forgeessentials:<version>:
* */
task deobfJar(dependsOn: "classes", type: Jar) {
classifier = "dev"
appendix = minecraft.version
from sourceSets.main.output
from sourceSets.utils.output
from (sourceSets.main.java) {
into ("src/")
}
manifest {
from serverManifest
}
}
/*
task sourceJar(type: Jar) {
classifier = "sources"
appendix = minecraft.version
from sourceSets.main.allSource
manifest {
from serverManifest
}
}
/************************************************************
* Configure API javadoc
*/
javadoc {
include "com/forgeessentials/api/**"
classpath = sourceSets.main.compileClasspath + sourceSets.main.output
options.addBooleanOption("Xdoclint:reference,accessibility,html", true) // excluded: syntax, missing
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc"
appendix = project.minecraft.version
from javadoc.destinationDir
manifest { from sharedManifest }
}
reobf {
clientJar {
classpath = sourceSets.main.compileClasspath
}
}
/************************************************************
* Others
*/
// Add default artifacts for task "build"
artifacts {
//archives deobfJar
archives clientJar
}
task wrapper(type: Wrapper) {
gradleVersion = "3.5"
}
/************************************************************
* Configure maven publishing
*/
apply plugin: "maven-publish"
publishing {
//tasks.publish.dependsOn "deobfJar"
publications {
mavenJava (MavenPublication) {
groupId "com.forgeessentials"
artifactId "forgeessentials"
version baseVersion + "-SNAPSHOT"
if (System.getenv("PUBLISH_RELEASE"))
version baseVersion
artifact deobfJar
//artifact sourceJar
artifact javadocJar
pom.withXml {
def dependenciesNode = asNode().appendNode("dependencies")
def allDeps = configurations.mavenDeps.allDependencies +
configurations.serverLib.allDependencies +
configurations.shade.allDependencies
allDeps.each {
def dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", it.group)
dependencyNode.appendNode("artifactId", it.name)
dependencyNode.appendNode("version", it.version)
//if (it.group == "com.sk89q.worldedit") // Hack to get classifier for worldedit attached (bug https://issues.gradle.org/browse/GRADLE-3030)
//dependencyNode.appendNode("classifier", "dev")
}
}
}
}
repositories {
if (project.hasProperty("forgemaven_user") && project.hasProperty("forgemaven_password")) {
maven {
credentials {
username project.forgemaven_user
password project.forgemaven_password
}
url "http://files.minecraftforge.net/maven/manage/upload"
}
} else {
maven { url "file://${project.projectDir}/build/repo" }
}
}
}
task publishAndClean(type: Delete, dependsOn: "publish") {
delete javadocJar, sourceJar
}