Skip to content

Commit 467e7ee

Browse files
committed
Merge branch 'refs/heads/master' into advancedMedicalDialogBug
2 parents f7b7cf3 + 449674f commit 467e7ee

28 files changed

+1797
-503
lines changed

.editorconfig

+607-3
Large diffs are not rendered by default.

.github/workflows/ci.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: MekHQ CI with Gradle
22

33
on:
44
pull_request:
5-
branches: [master]
5+
branches: [ master ]
66

77
env:
88
GRADLE_OPTS: "-Dscan.link.VCS=${{ github.event.pull_request.html_url }}"
@@ -19,9 +19,9 @@ jobs:
1919

2020
strategy:
2121
matrix:
22-
os: [ubuntu-latest]
23-
java-distribution: [temurin]
24-
java-version: [17]
22+
os: [ ubuntu-latest ]
23+
java-distribution: [ temurin ]
24+
java-version: [ 17 ]
2525
fail-fast: false
2626

2727
steps:
@@ -91,9 +91,9 @@ jobs:
9191
run: |
9292
echo ${{ github.sha }} >> mekhq/MekHQ/mhq-revision.txt
9393
94-
- name: Build with Gradle
94+
- name: Test All
9595
working-directory: mekhq
96-
run: ./gradlew build -x checkstyleMain -x checkstyleTest --stacktrace --scan
96+
run: ./gradlew testAll --stacktrace --scan
9797

9898
- name: Upload Test Logs on Failure
9999
uses: actions/upload-artifact@v4
@@ -102,6 +102,10 @@ jobs:
102102
name: cd-failure-logs
103103
path: ./mekhq/MekHQ/build/reports/
104104

105+
- name: Build with Gradle
106+
working-directory: mekhq
107+
run: ./gradlew build -x test
108+
105109
- name: CodeCov.io Coverage Report
106110
uses: codecov/codecov-action@v5
107111
with:

MekHQ/build.gradle

+66-84
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ import java.time.LocalDateTime
22

33
plugins {
44
id 'application'
5-
id 'checkstyle'
65
id 'com.palantir.git-version' version '3.1.0'
76
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'
98
id 'jacoco'
109
id 'java'
11-
id 'org.ec4j.editorconfig' version '0.1.0'
1210
}
1311

1412
java {
15-
sourceCompatibility = JavaVersion.VERSION_17
16-
targetCompatibility = JavaVersion.VERSION_17
13+
toolchain {
14+
languageVersion = JavaLanguageVersion.of(17)
15+
}
1716
}
1817

1918
sourceSets {
@@ -37,41 +36,30 @@ sourceSets {
3736

3837
ext {
3938
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'
4645
]
4746
campaigns = 'campaigns'
4847
data = 'data'
4948
docs = 'docs'
5049
lib = 'lib'
5150
log = 'logs'
5251
mmconf = 'mmconf'
53-
plugins = 'plugins'
5452
userdata = 'userdata'
55-
fileStagingDir = "${buildDir}/files"
53+
fileStagingDir = "${layout.buildDirectory.get()}/files"
5654
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
6455

6556
mmDir = "${rootDir}/../megamek"
6657
mmlDir = "${rootDir}/../megameklab"
6758
}
6859

6960
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}") {
7563
// We don't need the python and javascript engine taking up space
7664
exclude group: 'org.python', module: 'jython'
7765
exclude group: 'org.mozilla', module: 'rhino'
@@ -101,26 +89,22 @@ dependencies {
10189
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2'
10290

10391
runtimeOnly 'org.glassfish.jaxb:jaxb-runtime:4.0.5'
92+
10493
// Required for mml printing scaled vector graphics (SVG) - Eclipse IDE Compatibility.
10594
runtimeOnly 'xml-apis:xml-apis-ext:1.3.04'
10695

10796
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.4'
10897

10998
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
11099
testImplementation 'org.mockito:mockito-core:5.15.2'
100+
testImplementation 'org.mockito:mockito-inline:5.2.0'
111101
testImplementation 'org.mockito:mockito-junit-jupiter:5.15.2'
112102
}
113103

114104
application {
115105
mainClass = 'mekhq.MekHQ'
116106
}
117107

118-
checkstyle {
119-
toolVersion = '10.18.1'
120-
configFile = file("config/checkstyle/checkstyle.xml")
121-
ignoreFailures = false
122-
}
123-
124108
run {
125109
jvmArgs = mhqJvmOptions
126110
}
@@ -129,16 +113,16 @@ jar {
129113
archiveFileName = "MekHQ.jar"
130114

131115
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()
138122
}
139123
}
140124

141-
task generateDynamicFiles() {
125+
tasks.register('generateDynamicFiles') {
142126
def jvmOptions = project.ext.mhqJvmOptions.join('\n')
143127

144128
doLast {
@@ -150,7 +134,7 @@ ${jvmOptions}
150134
}
151135
}
152136

153-
task canonSystemZip (type: Zip) {
137+
tasks.register('canonSystemZip', Zip) {
154138
description = 'Creates a zip archive of canon planetary systems.'
155139
from "${data}/universe/planetary_systems/canon_systems/"
156140

@@ -160,7 +144,7 @@ task canonSystemZip (type: Zip) {
160144
outputs.dir "${fileStagingDir}/${data}/universe/planetary_systems"
161145
}
162146

163-
task connectorSystemZip (type: Zip) {
147+
tasks.register('connectorSystemZip', Zip) {
164148
description = 'Creates a zip archive of connector systems planetary systems.'
165149
from "${data}/universe/planetary_systems/connector_systems/"
166150

@@ -170,7 +154,7 @@ task connectorSystemZip (type: Zip) {
170154
outputs.dir "${fileStagingDir}/${data}/universe/planetary_systems"
171155
}
172156

173-
task stageFiles(type: Copy) {
157+
tasks.register('stageFiles', Copy) {
174158
description = 'Stages files that are to be copied into the distribution.'
175159

176160
dependsOn generateDynamicFiles
@@ -204,7 +188,6 @@ task stageFiles(type: Copy) {
204188
include "${data}/terrainconditionsodds/"
205189
include "${docs}/**"
206190
include "${mmconf}/**"
207-
include "${project.ext.plugins}/"
208191
include "${userdata}"
209192
include "${userdata}/data/universe/"
210193
include 'license.txt'
@@ -233,7 +216,7 @@ task stageFiles(type: Copy) {
233216
}
234217
}
235218

236-
task createStartScripts (type: CreateStartScripts) {
219+
tasks.register('createStartScripts', CreateStartScripts) {
237220
description = 'Create shell script for generic distribution.'
238221

239222
applicationName = 'MekHQ'
@@ -249,87 +232,87 @@ distributions {
249232
distributionBaseName = 'MekHQ'
250233
contents {
251234
// 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") {
254237
into "bin"
255238
}
256-
from ("${mmDir}/megamek/scripts") {
239+
from("${mmDir}/megamek/scripts") {
257240
include "shell.sh"
258241
rename "shell.sh", "MegaMek.sh"
259242
}
260-
from ("${mmDir}/megamek/docs") {
243+
from("${mmDir}/megamek/docs") {
261244
rename 'history.txt', 'mm-history.txt'
262245
into 'docs'
263246
}
264-
from ("${mmDir}/megamek/mmconf/log4j2.xml") {
247+
from("${mmDir}/megamek/mmconf/log4j2.xml") {
265248
exclude 'log4j2.xml'
266249
}
267-
from ("${mmDir}/megamek/build/launch4j/lib") {
250+
from("${mmDir}/megamek/build/launch4j/lib") {
268251
into "${lib}"
269252
}
270-
from ("${mmDir}/megamek/build/launch4j") {
253+
from("${mmDir}/megamek/build/launch4j") {
271254
include '*.exe'
272255
}
273-
from ("${mmDir}/megamek/build/libs/MegaMek.jar") {
256+
from("${mmDir}/megamek/build/libs/MegaMek.jar") {
274257
into "${lib}"
275258
}
276-
from ("${mmDir}/megamek/build/libs/MegaMek.jar")
277-
from ("${mmDir}/megamek/") {
259+
from("${mmDir}/megamek/build/libs/MegaMek.jar")
260+
from("${mmDir}/megamek/") {
278261
include '*.ini'
279262
}
280263

281264
// MegaMekLab Includes
282-
from ("${mmlDir}/megameklab/build/files") {
265+
from("${mmlDir}/megameklab/build/files") {
283266
exclude 'data/mekfiles'
284267
}
285-
from ("${mmlDir}/megameklab/build/launch4j/lib") {
268+
from("${mmlDir}/megameklab/build/launch4j/lib") {
286269
into "${lib}"
287270
}
288-
from ("${mmlDir}/megameklab/build/files/${data}/images") {
271+
from("${mmlDir}/megameklab/build/files/${data}/images") {
289272
into "${data}/images"
290273
}
291-
from ("${mmlDir}/megameklab/build/scripts") {
274+
from("${mmlDir}/megameklab/build/scripts") {
292275
into "bin"
293276
}
294-
from ("${mmlDir}/megameklab/scripts") {
277+
from("${mmlDir}/megameklab/scripts") {
295278
include "shell.sh"
296279
rename "shell.sh", "MegaMekLab.sh"
297280
}
298-
from ("${mmlDir}/megameklab/docs") {
281+
from("${mmlDir}/megameklab/docs") {
299282
rename 'history.txt', 'mml-history.txt'
300283
into "${docs}"
301284
}
302-
from ("${mmlDir}/megameklab/mmconf/log4j2.xml") {
285+
from("${mmlDir}/megameklab/mmconf/log4j2.xml") {
303286
exclude 'log4j2.xml'
304287
}
305-
from ("${mmlDir}/megameklab/build/launch4j") {
288+
from("${mmlDir}/megameklab/build/launch4j") {
306289
include '*.exe'
307290
}
308-
from ("${mmlDir}/megameklab/build/libs/MegaMekLab.jar") {
291+
from("${mmlDir}/megameklab/build/libs/MegaMekLab.jar") {
309292
into "${lib}"
310293
}
311-
from ("${mmlDir}/megameklab/build/libs/MegaMekLab.jar")
312-
from ("${mmlDir}/megameklab/") {
294+
from("${mmlDir}/megameklab/build/libs/MegaMekLab.jar")
295+
from("${mmlDir}/megameklab/") {
313296
include '*.ini'
314297
}
315298

316299
// MekHQ Includes
317-
from ("docs/history.txt") {
300+
from("docs/history.txt") {
318301
rename 'history.txt', 'mhq-history.txt'
319302
into 'docs'
320303
}
321-
from (fileStagingDir) {
304+
from(fileStagingDir) {
322305
exclude 'history.txt'
323306
}
324-
from ("${projectDir}/scripts") {
307+
from("${projectDir}/scripts") {
325308
include 'shell.sh'
326309
rename 'shell.sh', 'MekHQ.sh'
327310
}
328-
from ("${buildDir}/launch4j") {
311+
from("${buildDir}/launch4j") {
329312
include '*.exe'
330313
}
331314

332-
from (project.sourceSets.main.runtimeClasspath.files
315+
from(project.sourceSets.main.runtimeClasspath.files
333316
.findAll { it.name.endsWith(".jar") && !it.name.toLowerCase().startsWith("megamek") }) {
334317
into "${lib}"
335318
}
@@ -364,6 +347,7 @@ launch4j {
364347

365348
tasks.register("packagePrepWork") {
366349
description = 'General Catch All for all distributions'
350+
dependsOn jar
367351
dependsOn stageFiles
368352
dependsOn startScripts
369353
dependsOn createStartScripts
@@ -395,18 +379,14 @@ distZip {
395379
dependsOn packagePrepWork
396380
}
397381

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 {
401383
dependsOn jar
402384
}
403385

404-
// Replace the assembleDist task created by the distributions plugin to create the packages we want to
405-
task assembleDist(overwrite: true) {
386+
assembleDist {
406387
description = 'Build unix, Windows, and source packages'
407388
group = 'distribution'
408389
dependsOn stageFiles
409-
dependsOn test
410390
dependsOn distTar
411391
}
412392

@@ -433,6 +413,17 @@ tasks.register("cleanAll") {
433413
dependsOn clean
434414
}
435415

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+
436427
test {
437428
useJUnitPlatform()
438429
// report is always generated after tests run
@@ -447,12 +438,3 @@ jacocoTestReport {
447438
html.required = true
448439
}
449440
}
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

Comments
 (0)