@@ -2,18 +2,17 @@ import java.time.LocalDateTime
2
2
3
3
plugins {
4
4
id ' application'
5
- id ' checkstyle'
6
5
id ' com.palantir.git-version' version ' 3.1.0'
7
6
id ' edu.sc.seis.launch4j' version ' 3.0.6'
8
- id " io.sentry.jvm.gradle" version ' 5.2 .0'
7
+ id " io.sentry.jvm.gradle" version ' 5.3 .0'
9
8
id ' jacoco'
10
9
id ' java'
11
- id ' org.ec4j.editorconfig' version ' 0.1.0'
12
10
}
13
11
14
12
java {
15
- sourceCompatibility = JavaVersion . VERSION_17
16
- targetCompatibility = JavaVersion . VERSION_17
13
+ toolchain {
14
+ languageVersion = JavaLanguageVersion . of(17 )
15
+ }
17
16
}
18
17
19
18
sourceSets {
@@ -37,41 +36,30 @@ sourceSets {
37
36
38
37
ext {
39
38
mhqJvmOptions = [
40
- ' -Xmx4096m' ,
41
- ' --add-opens' ,
42
- ' java.base/java.util=ALL-UNNAMED' ,
43
- ' --add-opens' ,
44
- ' java.base/java.util.concurrent=ALL-UNNAMED' ,
45
- ' -Dsun.awt.disablegrab=true'
39
+ ' -Xmx4096m' ,
40
+ ' --add-opens' ,
41
+ ' java.base/java.util=ALL-UNNAMED' ,
42
+ ' --add-opens' ,
43
+ ' java.base/java.util.concurrent=ALL-UNNAMED' ,
44
+ ' -Dsun.awt.disablegrab=true'
46
45
]
47
46
campaigns = ' campaigns'
48
47
data = ' data'
49
48
docs = ' docs'
50
49
lib = ' lib'
51
50
log = ' logs'
52
51
mmconf = ' mmconf'
53
- plugins = ' plugins'
54
52
userdata = ' userdata'
55
- fileStagingDir = " ${ buildDir } /files"
53
+ fileStagingDir = " ${ layout.buildDirectory.get() } /files"
56
54
scriptsDir = " ${ projectDir} /scripts"
57
- scriptTemplate = " ${ scriptsDir} /startScriptTemplate.txt"
58
-
59
- // Allows setting a dependency on a different MM branch.
60
- mmBranch = ' master'
61
- mmBranchTag = mmBranch. equals(' master' ) ? ' ' : ' -' + mmBranch
62
- mmlBranch = ' master'
63
- mmlBranchTag = mmlBranch. equals(' master' ) ? ' ' : ' -' + mmlBranch
64
55
65
56
mmDir = " ${ rootDir} /../megamek"
66
57
mmlDir = " ${ rootDir} /../megameklab"
67
58
}
68
59
69
60
dependencies {
70
- implementation " org.megamek:megamek${ mmBranchTag} :${ version} "
71
- implementation (" org.megamek:megameklab${ mmlBranchTag} :${ version} " ) {
72
- // We may want to specify different branches for MM and MML, so we need to exclude the transitive MM dependency
73
- exclude group : ' org.megamek' , module : " megamek${ mmBranchTag} :${ version} "
74
-
61
+ implementation " org.megamek:megamek:${ version} "
62
+ implementation(" org.megamek:megameklab:${ version} " ) {
75
63
// We don't need the python and javascript engine taking up space
76
64
exclude group : ' org.python' , module : ' jython'
77
65
exclude group : ' org.mozilla' , module : ' rhino'
@@ -101,6 +89,7 @@ dependencies {
101
89
implementation ' com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2'
102
90
103
91
runtimeOnly ' org.glassfish.jaxb:jaxb-runtime:4.0.5'
92
+
104
93
// Required for mml printing scaled vector graphics (SVG) - Eclipse IDE Compatibility.
105
94
runtimeOnly ' xml-apis:xml-apis-ext:1.3.04'
106
95
@@ -116,12 +105,6 @@ application {
116
105
mainClass = ' mekhq.MekHQ'
117
106
}
118
107
119
- checkstyle {
120
- toolVersion = ' 10.18.1'
121
- configFile = file(" config/checkstyle/checkstyle.xml" )
122
- ignoreFailures = false
123
- }
124
-
125
108
run {
126
109
jvmArgs = mhqJvmOptions
127
110
}
@@ -130,16 +113,16 @@ jar {
130
113
archiveFileName = " MekHQ.jar"
131
114
132
115
manifest {
133
- attributes " Main-Class" : application. mainClass
134
- attributes " Class-Path" : " MegaMek.jar MegaMekLab.jar " + (project. sourceSets. main. runtimeClasspath. files
135
- .findAll { it. name. endsWith(" .jar" ) && ! it. name. toLowerCase(). startsWith(" megamek" ) }
136
- .collect { " ${ lib} /${ it.name} " }. join(' ' ))
137
- attributes " Add-Opens" : ' java.base/java.util java.base/java.util.concurrent'
138
- attributes " Build-Date" : LocalDateTime . now()
116
+ attributes " Main-Class" : application. mainClass
117
+ attributes " Class-Path" : " MegaMek.jar MegaMekLab.jar " + (project. sourceSets. main. runtimeClasspath. files
118
+ .findAll { it. name. endsWith(" .jar" ) && ! it. name. toLowerCase(). startsWith(" megamek" ) }
119
+ .collect { " ${ lib} /${ it.name} " }. join(' ' ))
120
+ attributes " Add-Opens" : ' java.base/java.util java.base/java.util.concurrent'
121
+ attributes " Build-Date" : LocalDateTime . now()
139
122
}
140
123
}
141
124
142
- task generateDynamicFiles ( ) {
125
+ tasks . register( ' generateDynamicFiles ' ) {
143
126
def jvmOptions = project. ext. mhqJvmOptions. join(' \n ' )
144
127
145
128
doLast {
@@ -151,7 +134,7 @@ ${jvmOptions}
151
134
}
152
135
}
153
136
154
- task canonSystemZip ( type : Zip ) {
137
+ tasks . register( ' canonSystemZip ' , Zip ) {
155
138
description = ' Creates a zip archive of canon planetary systems.'
156
139
from " ${ data} /universe/planetary_systems/canon_systems/"
157
140
@@ -161,7 +144,7 @@ task canonSystemZip (type: Zip) {
161
144
outputs. dir " ${ fileStagingDir} /${ data} /universe/planetary_systems"
162
145
}
163
146
164
- task connectorSystemZip ( type : Zip ) {
147
+ tasks . register( ' connectorSystemZip ' , Zip ) {
165
148
description = ' Creates a zip archive of connector systems planetary systems.'
166
149
from " ${ data} /universe/planetary_systems/connector_systems/"
167
150
@@ -171,7 +154,7 @@ task connectorSystemZip (type: Zip) {
171
154
outputs. dir " ${ fileStagingDir} /${ data} /universe/planetary_systems"
172
155
}
173
156
174
- task stageFiles ( type : Copy ) {
157
+ tasks . register( ' stageFiles ' , Copy ) {
175
158
description = ' Stages files that are to be copied into the distribution.'
176
159
177
160
dependsOn generateDynamicFiles
@@ -205,7 +188,6 @@ task stageFiles(type: Copy) {
205
188
include " ${ data} /terrainconditionsodds/"
206
189
include " ${ docs} /**"
207
190
include " ${ mmconf} /**"
208
- include " ${ project.ext.plugins} /"
209
191
include " ${ userdata} "
210
192
include " ${ userdata} /data/universe/"
211
193
include ' license.txt'
@@ -234,7 +216,7 @@ task stageFiles(type: Copy) {
234
216
}
235
217
}
236
218
237
- task createStartScripts ( type : CreateStartScripts ) {
219
+ tasks . register( ' createStartScripts ' , CreateStartScripts ) {
238
220
description = ' Create shell script for generic distribution.'
239
221
240
222
applicationName = ' MekHQ'
@@ -250,87 +232,87 @@ distributions {
250
232
distributionBaseName = ' MekHQ'
251
233
contents {
252
234
// MegaMek Includes
253
- from (" ${ mmDir} /megamek/build/files" )
254
- from (" ${ mmDir} /megamek/build/scripts" ) {
235
+ from(" ${ mmDir} /megamek/build/files" )
236
+ from(" ${ mmDir} /megamek/build/scripts" ) {
255
237
into " bin"
256
238
}
257
- from (" ${ mmDir} /megamek/scripts" ) {
239
+ from(" ${ mmDir} /megamek/scripts" ) {
258
240
include " shell.sh"
259
241
rename " shell.sh" , " MegaMek.sh"
260
242
}
261
- from (" ${ mmDir} /megamek/docs" ) {
243
+ from(" ${ mmDir} /megamek/docs" ) {
262
244
rename ' history.txt' , ' mm-history.txt'
263
245
into ' docs'
264
246
}
265
- from (" ${ mmDir} /megamek/mmconf/log4j2.xml" ) {
247
+ from(" ${ mmDir} /megamek/mmconf/log4j2.xml" ) {
266
248
exclude ' log4j2.xml'
267
249
}
268
- from (" ${ mmDir} /megamek/build/launch4j/lib" ) {
250
+ from(" ${ mmDir} /megamek/build/launch4j/lib" ) {
269
251
into " ${ lib} "
270
252
}
271
- from (" ${ mmDir} /megamek/build/launch4j" ) {
253
+ from(" ${ mmDir} /megamek/build/launch4j" ) {
272
254
include ' *.exe'
273
255
}
274
- from (" ${ mmDir} /megamek/build/libs/MegaMek.jar" ) {
256
+ from(" ${ mmDir} /megamek/build/libs/MegaMek.jar" ) {
275
257
into " ${ lib} "
276
258
}
277
- from (" ${ mmDir} /megamek/build/libs/MegaMek.jar" )
278
- from (" ${ mmDir} /megamek/" ) {
259
+ from(" ${ mmDir} /megamek/build/libs/MegaMek.jar" )
260
+ from(" ${ mmDir} /megamek/" ) {
279
261
include ' *.ini'
280
262
}
281
263
282
264
// MegaMekLab Includes
283
- from (" ${ mmlDir} /megameklab/build/files" ) {
265
+ from(" ${ mmlDir} /megameklab/build/files" ) {
284
266
exclude ' data/mekfiles'
285
267
}
286
- from (" ${ mmlDir} /megameklab/build/launch4j/lib" ) {
268
+ from(" ${ mmlDir} /megameklab/build/launch4j/lib" ) {
287
269
into " ${ lib} "
288
270
}
289
- from (" ${ mmlDir} /megameklab/build/files/${ data} /images" ) {
271
+ from(" ${ mmlDir} /megameklab/build/files/${ data} /images" ) {
290
272
into " ${ data} /images"
291
273
}
292
- from (" ${ mmlDir} /megameklab/build/scripts" ) {
274
+ from(" ${ mmlDir} /megameklab/build/scripts" ) {
293
275
into " bin"
294
276
}
295
- from (" ${ mmlDir} /megameklab/scripts" ) {
277
+ from(" ${ mmlDir} /megameklab/scripts" ) {
296
278
include " shell.sh"
297
279
rename " shell.sh" , " MegaMekLab.sh"
298
280
}
299
- from (" ${ mmlDir} /megameklab/docs" ) {
281
+ from(" ${ mmlDir} /megameklab/docs" ) {
300
282
rename ' history.txt' , ' mml-history.txt'
301
283
into " ${ docs} "
302
284
}
303
- from (" ${ mmlDir} /megameklab/mmconf/log4j2.xml" ) {
285
+ from(" ${ mmlDir} /megameklab/mmconf/log4j2.xml" ) {
304
286
exclude ' log4j2.xml'
305
287
}
306
- from (" ${ mmlDir} /megameklab/build/launch4j" ) {
288
+ from(" ${ mmlDir} /megameklab/build/launch4j" ) {
307
289
include ' *.exe'
308
290
}
309
- from (" ${ mmlDir} /megameklab/build/libs/MegaMekLab.jar" ) {
291
+ from(" ${ mmlDir} /megameklab/build/libs/MegaMekLab.jar" ) {
310
292
into " ${ lib} "
311
293
}
312
- from (" ${ mmlDir} /megameklab/build/libs/MegaMekLab.jar" )
313
- from (" ${ mmlDir} /megameklab/" ) {
294
+ from(" ${ mmlDir} /megameklab/build/libs/MegaMekLab.jar" )
295
+ from(" ${ mmlDir} /megameklab/" ) {
314
296
include ' *.ini'
315
297
}
316
298
317
299
// MekHQ Includes
318
- from (" docs/history.txt" ) {
300
+ from(" docs/history.txt" ) {
319
301
rename ' history.txt' , ' mhq-history.txt'
320
302
into ' docs'
321
303
}
322
- from (fileStagingDir) {
304
+ from(fileStagingDir) {
323
305
exclude ' history.txt'
324
306
}
325
- from (" ${ projectDir} /scripts" ) {
307
+ from(" ${ projectDir} /scripts" ) {
326
308
include ' shell.sh'
327
309
rename ' shell.sh' , ' MekHQ.sh'
328
310
}
329
- from (" ${ buildDir} /launch4j" ) {
311
+ from(" ${ buildDir} /launch4j" ) {
330
312
include ' *.exe'
331
313
}
332
314
333
- from (project. sourceSets. main. runtimeClasspath. files
315
+ from(project. sourceSets. main. runtimeClasspath. files
334
316
.findAll { it. name. endsWith(" .jar" ) && ! it. name. toLowerCase(). startsWith(" megamek" ) }) {
335
317
into " ${ lib} "
336
318
}
@@ -365,6 +347,7 @@ launch4j {
365
347
366
348
tasks. register(" packagePrepWork" ) {
367
349
description = ' General Catch All for all distributions'
350
+ dependsOn jar
368
351
dependsOn stageFiles
369
352
dependsOn startScripts
370
353
dependsOn createStartScripts
@@ -396,18 +379,14 @@ distZip {
396
379
dependsOn packagePrepWork
397
380
}
398
381
399
- // The distribution plugin adds the distribution packages to the assemble task, which causes the build task
400
- // to run all the packaging tasks.
401
- task assemble (overwrite : true ) {
382
+ assemble {
402
383
dependsOn jar
403
384
}
404
385
405
- // Replace the assembleDist task created by the distributions plugin to create the packages we want to
406
- task assembleDist (overwrite : true ) {
386
+ assembleDist {
407
387
description = ' Build unix, Windows, and source packages'
408
388
group = ' distribution'
409
389
dependsOn stageFiles
410
- dependsOn test
411
390
dependsOn distTar
412
391
}
413
392
@@ -434,6 +413,17 @@ tasks.register("cleanAll") {
434
413
dependsOn clean
435
414
}
436
415
416
+ tasks. register(" testAll" ) {
417
+ description = " Cleans all build projects to ensure a clean slate then runs all tests"
418
+ group = " verification"
419
+ dependsOn cleanAll
420
+
421
+ dependsOn gradle. includedBuild(' megamek' ). task(' :megamek:test' )
422
+ dependsOn gradle. includedBuild(' megameklab' ). task(' :megameklab:test' )
423
+ dependsOn test
424
+ }
425
+
426
+
437
427
test {
438
428
useJUnitPlatform()
439
429
// report is always generated after tests run
@@ -448,12 +438,3 @@ jacocoTestReport {
448
438
html. required = true
449
439
}
450
440
}
451
-
452
- tasks. withType(Checkstyle ) {
453
- minHeapSize = " 200m"
454
- maxHeapSize = " 1g"
455
- reports {
456
- xml. required = false
457
- html. required = true
458
- }
459
- }
0 commit comments