forked from mekanism/Mekanism
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
526 lines (473 loc) · 19.7 KB
/
build.gradle
File metadata and controls
526 lines (473 loc) · 19.7 KB
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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
buildscript {
repositories {
jcenter()
maven {
name "forge"
url "https://files.minecraftforge.net/maven"
}
}
dependencies {
classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "3.+", changing: true
}
}
plugins {
id 'org.ajoberstar.grgit' version '4.0.0'
id "com.matthewprenger.cursegradle" version '1.4.0'
id 'java'
id 'idea'
id 'maven'
id 'maven-publish'
}
defaultTasks 'fullBuild'
idea {
module {
// For some reason this is necessary for IDEA 2014 workspaces to recognize assets
inheritOutputDirs = true
//Exclude directories from being managed
for (String excludeDirName in ["run", "out", "logs", "gradle"]) {
File excludeDir = new File(projectDir, excludeDirName)
excludeDirs.add(excludeDir)
}
}
}
apply plugin: 'net.minecraftforge.gradle'
sourceSets {
api {
java {
srcDir 'src/api/java'
}
}
main {
java {
srcDir 'src/main/java'
}
resources {
include '**/**'
// copy everything else, but blender files.
exclude '**/*.blend'
//Add the generated main module resources
srcDirs += 'src/datagen/generated/mekanism'
//But exclude the cache of the generated data from what gets built
exclude '.cache'
}
compileClasspath += sourceSets.api.output
runtimeClasspath += sourceSets.api.output
}
additions { setupSourceSet(sourceSets.additions, 'additions') }
generators { setupSourceSet(sourceSets.generators, 'generators') }
tools { setupSourceSet(sourceSets.tools, 'tools') }
//Data gen modules for the different modules
datagenmain { setupDataGenSourceSet(sourceSets.datagenmain, null, 'main') }
datagenadditions { setupDataGenSourceSet(sourceSets.datagenadditions, sourceSets.additions, 'additions') }
datagengenerators { setupDataGenSourceSet(sourceSets.datagengenerators, sourceSets.generators, 'generators') }
datagentools { setupDataGenSourceSet(sourceSets.datagentools, sourceSets.tools, 'tools') }
}
//This method sets up an additional sourceset in src/$name and adds a reference to the corresponding
// data gen's resource directory excluding the cache. It also adds the api and main mekanism module
// to the dependencies of the source set we are setting up
def setupSourceSet(SourceSet sourceSet, String name) {
sourceSet.java {
srcDir 'src/' + name + '/java'
}
sourceSet.resources {
//Add the generated module resources
srcDirs += 'src/datagen/generated/mekanism' + name
//But exclude the cache of the generated data from what gets built
exclude '.cache'
}
sourceSet.compileClasspath += sourceSets.api.output
sourceSet.compileClasspath += sourceSets.main.output
}
//This method sets up a source set in datagen/$name and adds the api, main mekanism module and an optional
// base module to the dependencies of the data generators source set that we are setting up
def setupDataGenSourceSet(SourceSet datagenSourceSet, SourceSet baseSourceSet, String name) {
datagenSourceSet.java.srcDirs = ['src/datagen/' + name + '/java']
datagenSourceSet.resources.srcDirs = ['src/datagen/' + name + '/resources']
datagenSourceSet.compileClasspath += project.sourceSets.api.output
datagenSourceSet.compileClasspath += project.sourceSets.main.output
if (baseSourceSet != null) {
//Only case it is null is when we are doing datagenmain so other cases also add access to the stuff
// in datagenmain so we can add helper classes
datagenSourceSet.compileClasspath += project.sourceSets.datagenmain.output
datagenSourceSet.compileClasspath += baseSourceSet.output
}
}
configurations {
//Make sure all our sub source set stuff extends the proper base methods so that
// they can see all the dependencies we have in dependencies including forge
def compileExtenders = [apiCompile, additionsCompile, generatorsCompile, toolsCompile,
datagenmainCompile, datagenadditionsCompile, datagengeneratorsCompile, datagentoolsCompile];
def compileOnlyExtenders = [apiCompileOnly, additionsCompileOnly, generatorsCompileOnly, toolsCompileOnly,
datagenmainCompileOnly, datagenadditionsCompileOnly, datagengeneratorsCompileOnly, datagentoolsCompileOnly];
def runtimeOnlyExtenders = [apiRuntimeOnly, additionsRuntimeOnly, generatorsRuntimeOnly, toolsRuntimeOnly,
datagenmainRuntimeOnly, datagenadditionsRuntimeOnly, datagengeneratorsRuntimeOnly, datagentoolsRuntimeOnly];
for (def compileExtender : compileExtenders) {
compileExtender.extendsFrom(compile)
}
for (def compileOnlyExtender : compileOnlyExtenders) {
compileOnlyExtender.extendsFrom(compileOnly)
}
for (def runtimeOnlyExtender : runtimeOnlyExtenders) {
runtimeOnlyExtender.extendsFrom(runtimeOnly)
}
}
repositories {
maven {
name 'ForgeFS'
url 'https://files.minecraftforge.net/maven'
}
maven {
name 'amadornes'
url 'https://maven.amadornes.com/'
}
maven {
name 'prog'
url 'http://dvs1.progwml6.com/files/maven'
}
maven {
name 'curseforge'
url 'https://minecraft.curseforge.com/api/maven/'
}
maven {
name 'opencomputers'
url 'http://maven.cil.li/'
}
maven {
name 'hwyla'
url 'https://tehnut.info/maven'
}
maven {
name 'tterrag'
url 'https://maven.tterrag.com/'
}
maven {
name 'ic2'
url 'http://maven.ic2.player.to'
}
maven {
name 'BlameJared - Crafttweaker'
url 'https://maven.blamejared.com/'
}
maven {
name 'thiakil'
url 'https://maven.thiakil.com'
}
}
group = "mekanism"
version = "${minecraft_version}-${mod_version}." + (System.env.BUILD_NUMBER ?: "homebaked")
archivesBaseName = "MekanismAll"
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
minecraft {
mappings channel: "snapshot", version: "${mappings_version}"
accessTransformers(file('src/main/resources/META-INF/accesstransformer.cfg'),
file('src/tools/resources/META-INF/accesstransformer.cfg'))
runs {
client {
workingDirectory project.file("run")
properties 'fml.earlyprogresswindow': 'false'
//The below if statements are to add args to your gradle.properties file in user home
// (DO NOT add them directly to the gradle.properties file for this project)
// Setting the below properties allows use of your normal Minecraft account in the
// dev environment including having your skin load. Each property also has a comment
// explaining what information to set the value to/format it expects
// One thing to note is because of the caching that goes on, after changing these
// variables, you need to refresh the project and rerun genIntellijRuns/genEclipseRuns
if (project.hasProperty('mc_uuid')) {
//Your uuid without any dashes in the middle
args '--uuid', project.getProperty('mc_uuid')
}
if (project.hasProperty('mc_username')) {
//Your username/display name, this is the name that shows up in chat
// Note: This is not your email, even if you have a Mojang account
args '--username', project.getProperty('mc_username')
}
if (project.hasProperty('mc_accessToken')) {
//Your access token, you can find it in your '.minecraft/launcher_profiles.json' file
args '--accessToken', project.getProperty('mc_accessToken')
}
mods {
mekanism {
sources(sourceSets.main, sourceSets.api)
}
mekanismadditions {
source(sourceSets.additions)
}
mekanismgenerators {
source(sourceSets.generators)
}
mekanismtools {
source(sourceSets.tools)
}
}
}
server {
workingDirectory project.file("run")
mods {
mekanism {
sources(sourceSets.main, sourceSets.api)
}
mekanismadditions {
source(sourceSets.additions)
}
mekanismgenerators {
source(sourceSets.generators)
}
mekanismtools {
source(sourceSets.tools)
}
}
}
data {
workingDirectory project.file("run")
environment 'target', 'fmluserdevdata'
properties 'fml.earlyprogresswindow': 'false'
args '--all', '--output', '"' + file('src/datagen/generated/') + '"',
'--mod', 'mekanism',
'--existing', '"' + sourceSets.main.resources.srcDirs[0] + '"',
'--mod', 'mekanismadditions',
'--existing', '"' + sourceSets.additions.resources.srcDirs[0] + '"',
'--mod', 'mekanismgenerators',
'--existing', '"' + sourceSets.generators.resources.srcDirs[0] + '"',
'--mod', 'mekanismtools',
'--existing', '"' + sourceSets.tools.resources.srcDirs[0] + '"'
mods {
mekanism {
sources(sourceSets.main, sourceSets.api, sourceSets.datagenmain)
}
mekanismadditions {
sources(sourceSets.additions, sourceSets.datagenadditions)
}
mekanismgenerators {
sources(sourceSets.generators, sourceSets.datagengenerators)
}
mekanismtools {
sources(sourceSets.tools, sourceSets.datagentools)
}
}
}
}
}
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
compileOnly "org.jetbrains:annotations:${jb_annotations}"
// compile against the JEI API but do not include it at runtime
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}:api")
// at runtime, use the full JEI jar
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}")
//TODO: Fix this once https://github.com/McJtyMods/TheOneProbe/issues/344 gets resolved
compile fg.deobf(project.dependencies.create("mcjty.theoneprobe:TheOneProbe-1.14:${top_version}:api") {
transitive = false
})
//runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-1.14:${top_version}")
//compileOnly "mcjty.theoneprobe:TheOneProbe-1.14:${top_version}:api"
//compileOnly fg.deobf("mcp.mobius.waila:Hwyla:${hwyla_version}:api")
//runtimeOnly fg.deobf("mcp.mobius.waila:Hwyla:${hwyla_version}")
//compileOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-${minecraft_version}:${crafttweaker_version}")
// Not updated yet
/*deobfCompile "MCMultiPart2:MCMultiPart:${mcmp_version}"
compileOnly "inventory-tweaks:InventoryTweaks:${invtweak_version}:api"
compileOnly "li.cil.oc:OpenComputers:MC${minecraft_version}-${opencomputers_version}:api"
compileOnly "team.chisel.ctm:CTM:MC${minecraft_version}-${ctm_version}:api"
runtime "team.chisel.ctm:CTM:MC${minecraft_version}-${ctm_version}"
compileOnly "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
compileOnly "dan200.computercraft:ComputerCraft:${computercraft_version}:api"
compileOnly("appeng:appliedenergistics2:${ae2_version}:api") {
exclude module: "jei_1.12.2"
}*/
}
def version_properties = ["version": mod_version, "mc_version": minecraft_version, "forge_version": min_forge_version, "loader_version": loader_version]
processResources {
outputs.upToDateWhen { false }
filesMatching('META-INF/mods.toml') { expand version_properties }
}
processToolsResources {
outputs.upToDateWhen { false }
filesMatching('META-INF/mods.toml') { expand version_properties }
}
processAdditionsResources {
outputs.upToDateWhen { false }
filesMatching('META-INF/mods.toml') { expand version_properties }
}
processGeneratorsResources {
outputs.upToDateWhen { false }
filesMatching('META-INF/mods.toml') { expand version_properties }
}
jar {
//TODO: Make this be an "All" jar again, needs to include all sourcesets and then use a merged mods.toml file
// Ideally we would have the mods.toml file get combined in processing rather than have to manually
// make sure that it stays up to date
from sourceSets.main.output
from sourceSets.api.output
}
//TODO: Sources Jars?
task coreJar(type: Jar) {
archiveName = "Mekanism-${project.version}.jar"
from sourceSets.main.output
from sourceSets.api.output
}
task additionsJar(type: Jar) {
archiveName = "MekanismAdditions-${project.version}.jar"
from sourceSets.additions.output
}
task generatorsJar(type: Jar) {
archiveName = "MekanismGenerators-${project.version}.jar"
from sourceSets.generators.output
}
task toolsJar(type: Jar) {
archiveName = "MekanismTools-${project.version}.jar"
from sourceSets.tools.output
}
task apiJar(type: Jar) {
classifier "api"
from sourceSets.api.output
}
artifacts {
archives apiJar
archives coreJar
archives additionsJar
archives generatorsJar
archives toolsJar
}
reobf {
apiJar { classpath = sourceSets.api.compileClasspath }
coreJar { classpath = sourceSets.main.compileClasspath }
additionsJar { classpath = sourceSets.additions.compileClasspath }
generatorsJar { classpath = sourceSets.generators.compileClasspath }
toolsJar { classpath = sourceSets.tools.compileClasspath }
}
task fullBuild(type: Delete) {
delete jar
dependsOn "build"
}
uploadArchives {
if (System.getenv("LOCAL_MAVEN") != null) {
repositories {
mavenDeployer {
repository(url: "file://" + System.getenv("LOCAL_MAVEN"))
pom {
groupId = project.group
version = project.version
if (System.getenv("MAVEN_ARTIFACT") != null) {
artifactId = System.getenv("MAVEN_ARTIFACT")
} else {
artifactId = "Mekanism"
}
project {
name = "Mekanism"
packaging 'jar'
description 'Mekanism is a Minecraft add-on featuring high-tech machinery that can be used to create powerful tools, armor, and weapons.'
url 'http://aidancbrady.com/mekanism/'
scm {
url 'https://github.com/mekanism/Mekanism.git'
}
issueManagement {
system 'github'
url 'https://github.com/mekanism/Mekanism/issues'
}
licenses {
license {
name = 'MIT'
distribution 'repo'
}
}
}
}
}
}
}
}
tasks.curseforge.dependsOn coreJar, additionsJar, generatorsJar, toolsJar, apiJar
if (System.getenv("CURSEFORGE_KEY") != null || project.hasProperty('curseforgeKey')) {
println "Enabling Curseforge config"
curseforge {
apiKey = System.getenv("CURSEFORGE_KEY") ?: project.findProperty("curseforgeKey")
def generatedChangelog = "Unable to generate changelog :("
def currentCommit = System.getenv("GIT_COMMIT")
def prevCommit = System.getenv("GIT_PREVIOUS_SUCCESSFUL_COMMIT") ?: System.getenv("GIT_PREVIOUS_COMMIT")
if (currentCommit != null && prevCommit != null) {
generatedChangelog = "<pre>"
grgit.log {
range(prevCommit, currentCommit)
}.reverse().each { commit ->
String message = commit.shortMessage
if (!message.startsWith("Merge branch") && !message.startsWith("Merge pull request")) {
//Ignore PRs and Merges
message = message.replaceAll("#(\\d+)", { match ->//turn issues/prs into links (github currently supports prs being linked as issues)
return "<a href=\"https://github.com/mekanism/Mekanism/issues/${match[1]}\">${match[0]}</a>"
})
generatedChangelog += "<a href=\"https://github.com/mekanism/Mekanism/commit/${commit.id}\">${commit.getAbbreviatedId()}</a> - ${message}\n"
}
}
generatedChangelog += "</pre>"
println "Changelog generated"
}
def releaseNotesFile = project.file("docs/release_${mod_version}.html")
if (releaseNotesFile.exists()) {
//Add any version specific changelog stuff
def releaseNotes = releaseNotesFile.getText()
generatedChangelog = "$releaseNotes<br> $generatedChangelog"
}
if (curse_release_type == "alpha") {
//Add a warning at the top about what an alpha build means
generatedChangelog = "Warning: Mekanism is currently in alpha, and is not recommended for widespread use in modpacks. There are likely to be game breaking bugs, " +
"and updating from one alpha to the next may cause various mekanism blocks to disappear/void their contents. While we will try to not have this happen/keep " +
"it to a minimum make sure to make backups. You can read more about the alpha state of this project <a href=\"https://github.com/mekanism/Mekanism#alpha-status\">here</a>." +
"<br> $generatedChangelog"
}
//Core
project {
id = '268560'
changelogType = "html"
changelog = generatedChangelog
// A file can also be set using: changelog = file('changelog.txt')
releaseType = "${curse_release_type}"
mainArtifact(coreJar) {
relations {
optionalDependency "jei"
optionalDependency "biomes-o-plenty"
}
}
addArtifact apiJar
addGameVersion "${minecraft_version}"
}
//Additions
project {
id = '345425'
changelogType = "html"
changelog = generatedChangelog
releaseType = "${curse_release_type}"
mainArtifact(additionsJar) {
relations {
requiredDependency "mekanism"
}
}
addGameVersion "${minecraft_version}"
}
//Generators
project {
id = '268566'
changelogType = "html"
changelog = generatedChangelog
releaseType = "${curse_release_type}"
mainArtifact(generatorsJar) {
relations {
requiredDependency "mekanism"
}
}
addGameVersion "${minecraft_version}"
}
//Tools
project {
id = '268567'
changelogType = "html"
changelog = generatedChangelog
releaseType = "${curse_release_type}"
mainArtifact(toolsJar) {
relations {
requiredDependency "mekanism"
}
}
addGameVersion "${minecraft_version}"
}
}
}