forked from alexandermburke/JurassiCraft2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
505 lines (449 loc) · 13.9 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
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
buildscript {
repositories {
jcenter()
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
}
maven {
name = 'gradle'
url 'https://plugins.gradle.org/m2/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public'
}
}
dependencies {
classpath "net.minecraftforge.gradle:${project.fg_version}"
// classpath 'org.junit.platform:junit-platform-gradle-plugin:1.2.+'
// classpath 'com.jaredsburrows:gradle-checker-framework-plugin:0.2.1'
}
}
plugins {
//id 'com.github.spotbugs' version '1.6.2'
id 'com.matthewprenger.cursegradle' version '1.1.0'
id 'org.sonarqube' version '2.6.2'
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'com.matthewprenger.cursegradle'
apply plugin: 'maven-publish'
apply plugin: 'org.sonarqube'
//apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'jacoco'
//apply plugin: 'com.github.spotbugs'
//apply plugin: 'com.jaredsburrows.checkerframework'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
testCompile('org.junit.jupiter:junit-jupiter-api:5.2.+')
// Only used for JUnit Platform Launcher 1.2.0 and earlier
//testCompile('org.junit.platform:junit-platform-launcher:1.2.+')
testRuntime('org.junit.jupiter:junit-jupiter-engine:5.2.+')
testCompile('org.mockito:mockito-core:2.+')
}
// TODO: Fix this for JUnit Platform Launcher 1.3
project.afterEvaluate {
// def junitPlatformTestTask = project.tasks.getByName('junitPlatformTest')
// configure jacoco to analyze the junitPlatformTest task
jacoco {
// this tool version is compatible with
toolVersion = '0.8.1'
// applyTo junitPlatformTestTask
}
// create junit platform jacoco task
project.task(type: JacocoReport, "junitPlatformJacocoReport",
{
sourceDirectories = files("./src/main")
classDirectories = files("$buildDir/classes/main")
// executionData junitPlatformTestTask
})
}
// Only used for JUnit Platform Launcher 1.2.0 and earlier
/*
junitPlatform {
// platformVersion '1.2.0'
// logManager 'org.apache.logging.log4j.jul.LogManager'
reportsDir file("${project.buildDir}/test-results/junit-platform")
// enableStandardTestTask true
// selectors (optional)
// filters (optional)
}
*/
/*
spotbugs {
toolVersion = '3.1.6'
}
*/
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs = [
'-Xlint:deprecation', // deprecation, rawtypes, cast, unchecked, all
// '-Xdiags:verbose',
// '-Werror'
]
}
javadoc {
failOnError = false
}
test {
useJUnitPlatform()
/*
useJUnitPlatform {
includeTags 'fast', 'smoke & feature-a'
// excludeTags 'slow', 'ci'
includeEngines 'junit-jupiter'
// excludeEngines 'junit-vintage'
}
*/
}
//ext.short_version = '1.0.0'
//ext.short_version = getVersion('VERSION', <path to file containing version string)
ext.short_version = getVersion('VERSION', getModFile())
version = mc_version + '-' + short_version
ext.display_version = short_version
def llibrary_version = getVersion('LLIBRARY_VERSION', getModFile())
if ((System.getenv('BUILD_NUMBER')) || (System.getenv('TRAVIS_BUILD_NUMBER')) || (System.getenv('CIRCLE_BUILD_NUM'))) {
version += '.' +getBuildNumber()
display_version += '.' + getBuildNumber()
}
String getBuildNumber() {
return System.getenv('BUILD_NUMBER') ? System.getenv('BUILD_NUMBER') : System.getenv('TRAVIS_BUILD_NUMBER') ? System.getenv('TRAVIS_BUILD_NUMBER') : System.getenv('CIRCLE_BUILD_NUM') ? System.getenv('CIRCLE_BUILD_NUM') : '0';
}
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
eclipse.project {
buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
natures 'org.eclipse.buildship.core.gradleprojectnature'
}
class Secrets {
def data = null
def getProperty(String key) {
return data ? data[key] : ''
}
}
import groovy.json.JsonSlurper
def secretFile
if (System.getenv('SECRET_FILE')) {
secretFile = file System.getenv().SECRET_FILE
} else {
secretFile = file 'secret.json'
}
ext.secret = new Secrets()
if (secretFile.exists()) {
secretFile.withReader {
project.secret.data = new JsonSlurper().parse it
}
}
minecraft {
version = project.forge_mc_version + '-' + project.forge_version
runDir = 'run'
mappings = project.mcp_mappings
replace '@MOD_VERSION@', project.short_version
if ((project.hasProperty('signSHA1')) && (project.hasProperty('doSignJar'))) {
replace '@FINGERPRINT@', project.findProperty('signSHA1')
} else {
replace '@FINGERPRINT@', ''
}
if (project.hasProperty('coreplugin')) {
clientJvmArgs += '-Dfml.coreMods.load=' + project.coreplugin
serverJvmArgs += '-Dfml.coreMods.load=' + project.coreplugin
}
if (project.hasProperty('mc_username')) {
clientRunArgs += ['--username', project.mc_username]
if (project.hasProperty('mc_password')) {
clientRunArgs += ['--password', project.mc_password]
}
}
if (project.hasProperty('mc_uuid')) {
clientRunArgs += ['--uuid', project.mc_uuid]
}
// disable server gui
if (project.hasProperty('server_nogui')) {
serverRunArgs += 'nogui'
}
// skip the screen to confirm that you want to load a world with missing registry entries
if (project.hasProperty('doNotBackup')) {
serverJvmArgs += '-Dfml.doNotBackup=true'
clientJvmArgs += '-Dfml.doNotBackup=true'
}
// skip having to confirm on server
if (project.hasProperty('queryResultConfirm')) {
serverJvmArgs += '-Dfml.queryResult=confirm'
}
// skip jansi warnings in the log
if (project.hasProperty('skipJansi')) {
serverJvmArgs += '-Dlog4j.skipJansi=true'
clientJvmArgs += '-Dlog4j.skipJansi=true'
}
if (project.hasProperty('client_args')) {
clientJvmArgs += project.client_args
}
if (project.hasProperty('server_args')) {
serverJvmArgs += project.server_args
}
if (!project.hasProperty('doSourceJar')) {
makeObfSourceJar = false
}
if (project.hasProperty('depHasATs')) {
useDepAts = ${depHasATs}
}
}
repositories {
maven {
name 'MMD'
url 'https://maven.mcmoddev.com/'
}
maven {
name 'JEI'
url = "http://dvs1.progwml6.com/files/maven"
}
maven { // HWYLA
name 'tehnut'
url 'http://tehnut.info/maven/'
}
}
dependencies {
deobfProvided "mezz.jei:jei_1.12.2:4.9.1.187:api"
runtime "mezz.jei:jei_1.12.2:4.9.1.187"
deobfCompile "net.ilexiconn:llibrary:${llibrary_version}-1.12.2"
runtime "mcp.mobius.waila:Hwyla:${hwyla_version}"
}
processResources {
inputs.property 'version', project.short_version
inputs.property 'mcversion', project.minecraft.version
from (sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version': project.short_version, 'mcversion': project.minecraft.version
}
from (sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
rename '(.+_at.cfg)', 'META-INF/$1'
}
jar {
//from sourceSets.api.output
//from sourceSets.main.output
manifest {
attributes 'Maven-Artifact' : "${project.group}:${project.archivesBaseName}:${project.version}"
attributes 'Timestamp' : System.currentTimeMillis()
if (project.hasProperty('coreplugin')) {
attributes 'FMLCorePluginContainsFMLMod': 'true'
attributes 'FMLCorePlugin': ${coreplugin}
}
if (project.hasProperty('at_file')) {
attributes 'FMLAT' : ${at_file}
}
}
}
task apiJar(type: Jar) {
classifier = 'apiClasses'
from apiClasses
// from sourceSets.api.output
}
task deobfJar(type: Jar) {
classifier = 'deobf'
from sourceSets.main.output
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.getDestinationDir()
}
task signJar(type: SignJar, dependsOn: reobfJar) {
onlyIf {
project.hasProperty('keyStore')
}
inputFile = jar.archivePath
outputFile = jar.archivePath
keyStore = project.findProperty('keyStore')
alias = project.findProperty('keyStoreAlias')
storePass = project.findProperty('keyStorePass')
keyPass = project.findProperty('keyStoreKeyPass')
}
if (project.hasProperty('doSignJar')) {
build.dependsOn signJar
}
artifacts {
if (project.hasProperty('doAPIJar')) {
archives apiJar
}
if (project.hasProperty('doDeobfJar')) {
archives deobfJar
}
if (project.hasProperty('doSourceJar')) {
archives sourceJar
}
if (project.hasProperty('doJavadocJar')) {
archives javadocJar
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
from components.java
if (project.hasProperty('doSourceJar')) {
artifact sourceJar {
classifier 'sources'
}
}
if (project.hasProperty('doAPIJar')) {
artifact apiJar {
classifier 'api'
}
}
if (project.hasProperty('doDeobfJar')) {
artifact deobfJar {
classifier 'deobf'
}
}
if (project.hasProperty('doJavadocJar')) {
artifact javadocJar {
classifier 'javadoc'
}
}
}
}
repositories {
maven {
credentials {
username secret.username
password secret.password
}
url secret.url
}
}
}
curseforge {
if (project.hasProperty('cf_project_id') && project.hasProperty('cf_release_type') && project.hasProperty('cf_changelog_filename') &&
((project.cf_release_type == 'alpha') || (project.cf_release_type == 'beta') || (project.cf_release_type == 'release'))) {
apiKey = secret.curseforgeAPIKey
def versions = "${cf_versions}".split(', ')
project {
id = "${cf_project_id}"
// A list of changes for the current build. This can be a String or a File. If a file is set, its contents will be used. This is a required field.
changelog = file(project.cf_changelog_filename)
// The type of changelog. This can be: text, html, or markdown. The default is text.
changelogType = project.cf_changelog_type
releaseType = project.cf_release_type
versions.each {
addGameVersion "${it}"
}
mainArtifact(jar) {
//displayName = "$project.description $project.display_version"
if (project.hasProperty('curse_requirements') || project.hasProperty('curse_optionals') || project.hasProperty('curse_embeddeds') || project.hasProperty('curse_tools') || project.hasProperty('curse_incompatibles') || project.hasProperty('curse_includes')) {
relations {
if (project.hasProperty('curse_requirements')) {
def requirements = "${curse_requirements}".split(', ')
requirements.each {
requiredLibrary "${it}"
}
}
if (project.hasProperty('curse_optionals')) {
def optionals = "${curse_optionals}".split(', ')
optionals.each {
optionalLibrary "${it}"
}
}
if (project.hasProperty('curse_embeddeds')) {
def embeddeds = "${curse_embeddeds}".split(', ')
embeddeds.each {
embeddedLibrary "${it}"
}
}
if (project.hasProperty('curse_tools')) {
def tools = "${curse_tools}".split(', ')
tools.each {
tool "${it}"
}
}
if (project.hasProperty('curse_incompatibles')) {
def incompatibles = "${curse_incompatibles}".split(', ')
incompatibles.each {
incompatible "${it}"
}
}
if (project.hasProperty('curse_includes')) {
def includes = "${curse_includes}".split(', ')
includeds.each {
include "${it}"
}
}
}
}
}
if (project.hasProperty('doAPIJar')) {
addArtifact(apiJar) {
//displayName = "$project.description $project.display_version API"
}
}
if (project.hasProperty('doSourceJar')) {
addArtifact(sourceJar) {
//displayName = "$project.description $project.display_version Sources"
}
}
if (project.hasProperty('doDeobfJar')) {
addArtifact(deobfJar) {
//displayName = "$project.description $project.display_version Development"
}
}
if (project.hasProperty('doJavadocJar')) {
addArtifact(javadocJar) {
//displayName = "$project.description $project.display_version Javadoc"
}
}
}
}
}
sonarqube {
properties {
property 'sonar.host.url', secret.sonarHost
property 'sonar.organization', secret.sonarOrganization
property 'sonar.login', secret.sonarToken
// property 'sonar.projectName', project.archivesBaseName
// property 'sonar.projectKey', "$project.group:$project.archivesBaseName"
// property 'sonar.branch.name', 'master-1.12'
// property 'sonar.branch.target', ''
property 'sonar.junit.reportPaths', "${project.buildDir}/test-results/junit-platform/*.xml"
property 'sonar.jacoco.reportPaths', "${project.buildDir}/jacoco/junitPlatformTest.exec"
}
}
String getModFile() {
String path = ''
FileTree tree = fileTree(dir: 'src/main/java')
tree.include '**/*.java'
tree.visit { element ->
if (element.file.isFile()) {
element.file.eachLine { String s ->
s = s.trim()
if (s.startsWith('@Mod(')) {
path = "src/main/java/$element.relativePath"
}
}
}
}
return path
}
String getVersion(String type, String mod_file) {
String major = '0'
String revision = '0'
String patch = '0'
File file = file(mod_file)
def prefix = ~/^(?:public|protected|private) static final String $type = ".*$/
file.eachLine { String s ->
s = s.trim()
if (s ==~ prefix || prefix.matcher(s).matches()) {
String[] bits = s.split("=")
String interesting = bits[1].trim()
interesting = interesting.substring(1, interesting.length() - 2)
String[] pts = interesting.trim().split("\\.")
major = pts[0] ?: '0'
revision = pts[1] ?: '0'
patch = pts[2] ?: '0'
}
}
return "$major.$revision.$patch"
}