forked from BuildCraft/BuildCraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
473 lines (396 loc) · 13.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
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
// DON'T TOUCH THE BUILDSCRIPT[] BLOCK
// its special, and it is only there to make ForgeGradle work correctly.
buildscript {
repositories {
mavenCentral()
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.2-SNAPSHOT"
}
}
apply plugin: "net.minecraftforge.gradle.forge" // adds the forge dependency
apply plugin: 'maven' // for uploading to a maven repo
ext.configFile = file "build.properties"
configFile.withReader {
// Load config. It shall from now be referenced as simply config or project.config
def prop = new Properties()
prop.load(it)
project.ext.config = new ConfigSlurper().parse prop
}
if (System.getenv("BUILD_NUMBER") != null) {
config.mod_version += "-${System.getenv("BUILD_NUMBER")}"
}
if (System.getenv("BUILD_VARIANT") != null) {
config.mod_version += "-${System.getenv("BUILD_VARIANT")}"
}
version = config.mod_version
group= "com.mod-buildcraft"
archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension]
ext.mcModInfo = new groovy.json.JsonSlurper().parse(file("buildcraft_resources/mcmod.info"))
ext.priv = parseConfig(file('private.properties'))
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
dependencies {
// Testing
testCompile "junit:junit:4.12"
}
minecraft {
version = config.mc_version + "-" + config.forge_version
runDir = "run"
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not allways work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = config.mappings_version
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// replacing stuff in the source
replace "@VERSION@", project.version
replace "@MC_VERSION@", version
}
// configure the source folders
sourceSets {
main {
java {
srcDir "common"
srcDir "common_old_license"
// srcDir "src_old_license"
// exclude 'some exclusion'
// include 'some inclusion'
}
resources {
srcDir "buildcraft_resources"
srcDir "BuildCraft-Localization"
exclude "**/.md" // exclude readme from localization repo
// exclude 'some exclusion'
// include 'some inclusion'
}
}
api {
java {
srcDir "BuildCraftAPI/api"
}
}
}
// Obfuscated Jar location
ext.jarFile = zipTree(jar.archivePath)
// Add API dir to the IDEA module
idea.module.sourceDirs += sourceSets.api.java.srcDirs
processResources
{
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
// ${version} and ${mcversion} are the exact strings being replaced
expand "version":project.version, "mcversion":project.minecraft.version
}
// copy everything else, that's not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
compileJava {
options.compilerArgs << "-Xmaxerrs" << "2000"
options.compilerArgs << "-Xmaxwarns" << "2"
options.compilerArgs << "-Xlint:all"
options.compilerArgs << "-Xdiags:verbose"
}
// --------------------
// extra jar section
// -------------------
def createMCModInfo(def id, def taskName)
{
File temp = new File("build/processing/" + taskName + "/mcmod.info")
temp.parentFile.mkdirs()
if (temp.exists())
temp.delete()
temp.createNewFile()
String prettyPrinted = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson([ext.mcModInfo[id]]))
prettyPrinted = prettyPrinted.replace("\${version}", project.version)
prettyPrinted = prettyPrinted.replace("\${mcversion}", project.minecraft.version)
temp.write(prettyPrinted)
temp.deleteOnExit()
return temp
}
def parseConfig(File config) {
if (!config.exists())
return null;
config.withReader {
def prop = new Properties()
prop.load(it)
return (new ConfigSlurper().parse(prop))
}
}
// add a source jar
//task sourceJar(type: Jar) {
// from sourceSets.main.allSource
// from sourceSets.api.allSource
// classifier = 'sources'
//}
// add api classes to javadoc
javadoc {
source += sourceSets.api.allSource
}
// add a javadoc jar
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
// because the normal output has been made to be obfuscated
task deobfJar(type: Jar) {
from sourceSets.main.output
from sourceSets.api.output
classifier = 'dev'
}
task apiJar(type: Jar, dependsOn: reobfJar) {
destinationDir = file("modules")
classifier = 'api'
doFirst {
from(project.ext.jarFile) {
includes.addAll(["buildcraft/api/**"])
}
}
}
task libJar(type: Jar, dependsOn: reobfJar) {
destinationDir = file("modules")
classifier = 'lib'
doFirst {
from(createMCModInfo(0, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraft/**", "assets/buildcraftlib/**", "buildcraft/lib/**", "buildcraft/api/**", "changelog/**", "LICENSE**", "versions.txt"])
}
}
}
task coreJar(type: Jar, dependsOn: reobfJar) {
destinationDir = file("modules")
classifier = 'core'
doFirst {
from(createMCModInfo(1, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraft/**", "assets/buildcraftlib/**", "assets/buildcraftcore/**", "buildcraft/lib/**", "buildcraft/core/**", "buildcraft/api/**", "changelog/**", "LICENSE**", "versions.txt"])
}
}
}
task buildersJar(type: Jar, dependsOn: reobfJar) {
destinationDir = file("modules")
classifier = 'builders'
doFirst {
from(createMCModInfo(2, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraftbuilders/**", "buildcraft/builders/**", "LICENSE"])
}
}
}
task energyJar(type: Jar, dependsOn: reobfJar) {
destinationDir = file("modules")
classifier = 'energy'
doFirst {
from(createMCModInfo(3, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraftenergy/**", "buildcraft/energy/**", "LICENSE"])
}
}
}
task factoryJar(type: Jar, dependsOn: reobfJar) {
destinationDir = file("modules")
classifier = 'factory'
doFirst {
from(createMCModInfo(4, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraftfactory/**", "buildcraft/factory/**", "LICENSE"])
}
}
}
task siliconJar(type: Jar, dependsOn: reobfJar) {
destinationDir = file("modules")
classifier = 'silicon'
doFirst {
from(createMCModInfo(5, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraftsilicon/**", "buildcraft/silicon/**", "LICENSE"])
}
}
}
task transportJar(type: Jar, dependsOn: reobfJar) {
destinationDir = file("modules")
classifier = 'transport'
doFirst {
from(createMCModInfo(6, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcrafttransport/**", "buildcraft/transport/**", "LICENSE"])
}
}
}
task roboticsJar(type: Jar, dependsOn: reobfJar) {
destinationDir = file("modules")
classifier = 'robotics'
doFirst {
from(createMCModInfo(7, name).parentFile)
from(project.ext.jarFile) {
includes.addAll(["assets/buildcraftrobotics/**", "buildcraft/robotics/**", "LICENSE"])
}
}
}
task allJar(type: Jar, dependsOn:reobfJar) {
destinationDir = file("modules")
doFirst {
from(project.ext.jarFile) {
includes.addAll("**")
}
}
}
// add api classes to main package
jar {
from sourceSets.api.output
}
// make sure all of these happen when we run build
build.dependsOn sourceJar, apiJar, deobfJar, javadocJar
// --------------------
// maven section
// -------------------
// create the deployerJars dependency configuration
configurations {
deployerJars
sshAntTask
}
dependencies {
// dependency in deployerJars, for maven deployment. see definition in mavenDeployer{} below
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
sshAntTask "org.apache.ant:ant-jsch:1.9.6", "com.jcraft:jsch:0.1.53"
}
clean{
delete "modules"
}
// specify artifacts to be uploaded
artifacts {
// the default jar is already here by default
archives sourceJar
archives javadocJar
// Modules
archives apiJar
archives libJar
archives coreJar
archives buildersJar
archives energyJar
archives factoryJar
archives siliconJar
archives transportJar
archives roboticsJar
archives allJar
}
def sftp(String subPath, Closure antFileset = {}) {
ant {
taskdef(name: 'scp', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
classpath: configurations.sshAntTask.asPath)
Map sftpArgs = [
verbose : 'yes',
todir : priv.username + "@" + priv.host + ":" + priv.remotedir + version + "/" + subPath,
port: priv.port,
password: priv.password,
sftp: true,
trust: 'yes'
]
delegate.scp(sftpArgs) {
antFileset.delegate = delegate
antFileset()
}
}
}
task upload(dependsOn: build) {
description = 'Update files on remote server.'
doFirst {
sftp("") {
fileset(dir: libsDir)
}
sftp("modules") {
fileset(dir: 'modules')
}
}
}
if (ext.priv == null)
upload.enabled = false;
uploadArchives {
// make sure this happens after reobfuscation
//dependsOn "reobf"
repositories {
if (project.hasProperty("filesmaven")) { // if this is the Forge server, and this stuff is defined...
logger.info('Publishing to files server')
mavenDeployer {
// specify the jars that maven needs to deploy here
configuration = configurations.deployerJars
// authentication, again, specially set in the forge server environment
repository(url: project.filesmaven.url) {
authentication(userName: project.filesmaven.username, privateKey: project.filesmaven.key)
}
// here you specify all your metadata
// this is the definition of the maven pom.xml. This is simply a DSL to define the XML. Not actual fields or things to set.
pom {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
project {
name project.archivesBaseName
packaging 'jar'
description 'A Minecraft mod adding all sorts of machinery'
url 'http://www.mod-buildcraft.com/'
scm {
url 'https://github.com/BuildCraft/BuildCraft'
connection 'scm:git:git://github.com/BuildCraft/BuildCraft.git'
developerConnection 'scm:git:git@github.com:BuildCraft/BuildCraft.git'
}
issueManagement {
system 'github'
url 'https://github.com/BuildCraft/BuildCraft/issues'
}
licenses {
license {
name 'Minecraft Mod Public License'
url 'http://www.mod-buildcraft.com/MMPL-1.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'SpaceToad'
name 'SpaceToad'
roles { role 'developer' }
}
developer {
id 'CovertJaguar'
name 'CovertJaguar'
roles { role 'developer' }
}
developer {
id 'SirSngir'
name 'SirSengir'
roles { role 'developer' }
}
developer {
id 'Krapht'
name 'Krapht'
roles { role 'developer' }
}
}
}
}
}
}
else
{
// otherwise publishing to the local repo in ~/.m2 is fine...
add project.repositories.mavenLocal()
}
}
}