@@ -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,26 +89,22 @@ 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
107
96
testRuntimeOnly ' org.junit.platform:junit-platform-launcher:1.11.4'
108
97
109
98
testImplementation ' org.junit.jupiter:junit-jupiter:5.11.4'
110
99
testImplementation ' org.mockito:mockito-core:5.15.2'
100
+ testImplementation ' org.mockito:mockito-inline:5.2.0'
111
101
testImplementation ' org.mockito:mockito-junit-jupiter:5.15.2'
112
102
}
113
103
114
104
application {
115
105
mainClass = ' mekhq.MekHQ'
116
106
}
117
107
118
- checkstyle {
119
- toolVersion = ' 10.18.1'
120
- configFile = file(" config/checkstyle/checkstyle.xml" )
121
- ignoreFailures = false
122
- }
123
-
124
108
run {
125
109
jvmArgs = mhqJvmOptions
126
110
}
@@ -129,16 +113,16 @@ jar {
129
113
archiveFileName = " MekHQ.jar"
130
114
131
115
manifest {
132
- attributes " Main-Class" : application. mainClass
133
- attributes " Class-Path" : " MegaMek.jar MegaMekLab.jar " + (project. sourceSets. main. runtimeClasspath. files
134
- .findAll { it. name. endsWith(" .jar" ) && ! it. name. toLowerCase(). startsWith(" megamek" ) }
135
- .collect { " ${ lib} /${ it.name} " }. join(' ' ))
136
- attributes " Add-Opens" : ' java.base/java.util java.base/java.util.concurrent'
137
- 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()
138
122
}
139
123
}
140
124
141
- task generateDynamicFiles ( ) {
125
+ tasks . register( ' generateDynamicFiles ' ) {
142
126
def jvmOptions = project. ext. mhqJvmOptions. join(' \n ' )
143
127
144
128
doLast {
@@ -150,7 +134,7 @@ ${jvmOptions}
150
134
}
151
135
}
152
136
153
- task canonSystemZip ( type : Zip ) {
137
+ tasks . register( ' canonSystemZip ' , Zip ) {
154
138
description = ' Creates a zip archive of canon planetary systems.'
155
139
from " ${ data} /universe/planetary_systems/canon_systems/"
156
140
@@ -160,7 +144,7 @@ task canonSystemZip (type: Zip) {
160
144
outputs. dir " ${ fileStagingDir} /${ data} /universe/planetary_systems"
161
145
}
162
146
163
- task connectorSystemZip ( type : Zip ) {
147
+ tasks . register( ' connectorSystemZip ' , Zip ) {
164
148
description = ' Creates a zip archive of connector systems planetary systems.'
165
149
from " ${ data} /universe/planetary_systems/connector_systems/"
166
150
@@ -170,7 +154,7 @@ task connectorSystemZip (type: Zip) {
170
154
outputs. dir " ${ fileStagingDir} /${ data} /universe/planetary_systems"
171
155
}
172
156
173
- task stageFiles ( type : Copy ) {
157
+ tasks . register( ' stageFiles ' , Copy ) {
174
158
description = ' Stages files that are to be copied into the distribution.'
175
159
176
160
dependsOn generateDynamicFiles
@@ -204,7 +188,6 @@ task stageFiles(type: Copy) {
204
188
include " ${ data} /terrainconditionsodds/"
205
189
include " ${ docs} /**"
206
190
include " ${ mmconf} /**"
207
- include " ${ project.ext.plugins} /"
208
191
include " ${ userdata} "
209
192
include " ${ userdata} /data/universe/"
210
193
include ' license.txt'
@@ -233,7 +216,7 @@ task stageFiles(type: Copy) {
233
216
}
234
217
}
235
218
236
- task createStartScripts ( type : CreateStartScripts ) {
219
+ tasks . register( ' createStartScripts ' , CreateStartScripts ) {
237
220
description = ' Create shell script for generic distribution.'
238
221
239
222
applicationName = ' MekHQ'
@@ -249,87 +232,87 @@ distributions {
249
232
distributionBaseName = ' MekHQ'
250
233
contents {
251
234
// MegaMek Includes
252
- from (" ${ mmDir} /megamek/build/files" )
253
- from (" ${ mmDir} /megamek/build/scripts" ) {
235
+ from(" ${ mmDir} /megamek/build/files" )
236
+ from(" ${ mmDir} /megamek/build/scripts" ) {
254
237
into " bin"
255
238
}
256
- from (" ${ mmDir} /megamek/scripts" ) {
239
+ from(" ${ mmDir} /megamek/scripts" ) {
257
240
include " shell.sh"
258
241
rename " shell.sh" , " MegaMek.sh"
259
242
}
260
- from (" ${ mmDir} /megamek/docs" ) {
243
+ from(" ${ mmDir} /megamek/docs" ) {
261
244
rename ' history.txt' , ' mm-history.txt'
262
245
into ' docs'
263
246
}
264
- from (" ${ mmDir} /megamek/mmconf/log4j2.xml" ) {
247
+ from(" ${ mmDir} /megamek/mmconf/log4j2.xml" ) {
265
248
exclude ' log4j2.xml'
266
249
}
267
- from (" ${ mmDir} /megamek/build/launch4j/lib" ) {
250
+ from(" ${ mmDir} /megamek/build/launch4j/lib" ) {
268
251
into " ${ lib} "
269
252
}
270
- from (" ${ mmDir} /megamek/build/launch4j" ) {
253
+ from(" ${ mmDir} /megamek/build/launch4j" ) {
271
254
include ' *.exe'
272
255
}
273
- from (" ${ mmDir} /megamek/build/libs/MegaMek.jar" ) {
256
+ from(" ${ mmDir} /megamek/build/libs/MegaMek.jar" ) {
274
257
into " ${ lib} "
275
258
}
276
- from (" ${ mmDir} /megamek/build/libs/MegaMek.jar" )
277
- from (" ${ mmDir} /megamek/" ) {
259
+ from(" ${ mmDir} /megamek/build/libs/MegaMek.jar" )
260
+ from(" ${ mmDir} /megamek/" ) {
278
261
include ' *.ini'
279
262
}
280
263
281
264
// MegaMekLab Includes
282
- from (" ${ mmlDir} /megameklab/build/files" ) {
265
+ from(" ${ mmlDir} /megameklab/build/files" ) {
283
266
exclude ' data/mekfiles'
284
267
}
285
- from (" ${ mmlDir} /megameklab/build/launch4j/lib" ) {
268
+ from(" ${ mmlDir} /megameklab/build/launch4j/lib" ) {
286
269
into " ${ lib} "
287
270
}
288
- from (" ${ mmlDir} /megameklab/build/files/${ data} /images" ) {
271
+ from(" ${ mmlDir} /megameklab/build/files/${ data} /images" ) {
289
272
into " ${ data} /images"
290
273
}
291
- from (" ${ mmlDir} /megameklab/build/scripts" ) {
274
+ from(" ${ mmlDir} /megameklab/build/scripts" ) {
292
275
into " bin"
293
276
}
294
- from (" ${ mmlDir} /megameklab/scripts" ) {
277
+ from(" ${ mmlDir} /megameklab/scripts" ) {
295
278
include " shell.sh"
296
279
rename " shell.sh" , " MegaMekLab.sh"
297
280
}
298
- from (" ${ mmlDir} /megameklab/docs" ) {
281
+ from(" ${ mmlDir} /megameklab/docs" ) {
299
282
rename ' history.txt' , ' mml-history.txt'
300
283
into " ${ docs} "
301
284
}
302
- from (" ${ mmlDir} /megameklab/mmconf/log4j2.xml" ) {
285
+ from(" ${ mmlDir} /megameklab/mmconf/log4j2.xml" ) {
303
286
exclude ' log4j2.xml'
304
287
}
305
- from (" ${ mmlDir} /megameklab/build/launch4j" ) {
288
+ from(" ${ mmlDir} /megameklab/build/launch4j" ) {
306
289
include ' *.exe'
307
290
}
308
- from (" ${ mmlDir} /megameklab/build/libs/MegaMekLab.jar" ) {
291
+ from(" ${ mmlDir} /megameklab/build/libs/MegaMekLab.jar" ) {
309
292
into " ${ lib} "
310
293
}
311
- from (" ${ mmlDir} /megameklab/build/libs/MegaMekLab.jar" )
312
- from (" ${ mmlDir} /megameklab/" ) {
294
+ from(" ${ mmlDir} /megameklab/build/libs/MegaMekLab.jar" )
295
+ from(" ${ mmlDir} /megameklab/" ) {
313
296
include ' *.ini'
314
297
}
315
298
316
299
// MekHQ Includes
317
- from (" docs/history.txt" ) {
300
+ from(" docs/history.txt" ) {
318
301
rename ' history.txt' , ' mhq-history.txt'
319
302
into ' docs'
320
303
}
321
- from (fileStagingDir) {
304
+ from(fileStagingDir) {
322
305
exclude ' history.txt'
323
306
}
324
- from (" ${ projectDir} /scripts" ) {
307
+ from(" ${ projectDir} /scripts" ) {
325
308
include ' shell.sh'
326
309
rename ' shell.sh' , ' MekHQ.sh'
327
310
}
328
- from (" ${ buildDir} /launch4j" ) {
311
+ from(" ${ buildDir} /launch4j" ) {
329
312
include ' *.exe'
330
313
}
331
314
332
- from (project. sourceSets. main. runtimeClasspath. files
315
+ from(project. sourceSets. main. runtimeClasspath. files
333
316
.findAll { it. name. endsWith(" .jar" ) && ! it. name. toLowerCase(). startsWith(" megamek" ) }) {
334
317
into " ${ lib} "
335
318
}
@@ -364,6 +347,7 @@ launch4j {
364
347
365
348
tasks. register(" packagePrepWork" ) {
366
349
description = ' General Catch All for all distributions'
350
+ dependsOn jar
367
351
dependsOn stageFiles
368
352
dependsOn startScripts
369
353
dependsOn createStartScripts
@@ -395,18 +379,14 @@ distZip {
395
379
dependsOn packagePrepWork
396
380
}
397
381
398
- // The distribution plugin adds the distribution packages to the assemble task, which causes the build task
399
- // to run all the packaging tasks.
400
- task assemble (overwrite : true ) {
382
+ assemble {
401
383
dependsOn jar
402
384
}
403
385
404
- // Replace the assembleDist task created by the distributions plugin to create the packages we want to
405
- task assembleDist (overwrite : true ) {
386
+ assembleDist {
406
387
description = ' Build unix, Windows, and source packages'
407
388
group = ' distribution'
408
389
dependsOn stageFiles
409
- dependsOn test
410
390
dependsOn distTar
411
391
}
412
392
@@ -433,6 +413,17 @@ tasks.register("cleanAll") {
433
413
dependsOn clean
434
414
}
435
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
+
436
427
test {
437
428
useJUnitPlatform()
438
429
// report is always generated after tests run
@@ -447,12 +438,3 @@ jacocoTestReport {
447
438
html. required = true
448
439
}
449
440
}
450
-
451
- tasks. withType(Checkstyle ) {
452
- minHeapSize = " 200m"
453
- maxHeapSize = " 1g"
454
- reports {
455
- xml. required = false
456
- html. required = true
457
- }
458
- }
0 commit comments