Skip to content

Commit

Permalink
BUmped to Gradle 8.7
Browse files Browse the repository at this point in the history
Initial work to move to Java 17
  • Loading branch information
rjhancock committed May 26, 2024
1 parent 2ef2dfe commit 0a7b8a0
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
/properties_local.gradle
/settings_local.gradle
/*.sav.gz
/.DS_Store
.DS_Store
135 changes: 70 additions & 65 deletions MekHQ/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.time.LocalDateTime
plugins {
id 'application'
id 'maven-publish'
id 'edu.sc.seis.launch4j' version '2.5.4'
id 'edu.sc.seis.launch4j' version '3.0.5'
id 'jacoco'
}

Expand Down Expand Up @@ -33,32 +33,32 @@ dependencies {
implementation ("org.megamek:megameklab${mmlBranchTag}:${version}") {
// We may want to specify different branches for MM and MML, so we need to exclude the
// transitive MM dependency
exclude group: 'org.megamek', module: "megameklab${mmlBranchTag}"
exclude group: 'org.megamek', module: "megamek${mmBranchTag}"
// We don't need the python and javascript engine taking up space
exclude group: 'org.python', module: 'jython'
exclude group: 'org.mozilla', module: 'rhino'
// Eclipse IDE Multiple Dependency errors.
// Eclipse IDE Multiple Dependency errors.
exclude group: 'xml-apis'
}

implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'
implementation 'javax.vecmath:vecmath:1.5.2'
implementation 'joda-time:joda-time:2.12.5'
implementation 'org.apache.commons:commons-csv:1.10.0'
implementation 'joda-time:joda-time:2.12.7'
implementation 'org.apache.commons:commons-csv:1.11.0'
implementation 'org.apache.commons:commons-math3:3.6.1'
implementation 'org.apache.commons:commons-text:1.10.0'
implementation 'org.apache.logging.log4j:log4j-core:2.20.0'
implementation 'org.commonmark:commonmark:0.21.0'
implementation 'org.apache.commons:commons-text:1.12.0'
implementation 'org.apache.logging.log4j:log4j-core:2.23.1'
implementation 'org.commonmark:commonmark:0.22.0'
implementation 'org.jfree:jfreechart:1.5.4'
implementation 'org.joda:joda-money:1.0.3'
implementation 'org.joda:joda-money:1.0.4'

runtimeOnly 'org.glassfish.jaxb:jaxb-runtime:4.0.2'
runtimeOnly 'org.glassfish.jaxb:jaxb-runtime:4.0.5'
// Required for mml printing scaled vector graphics (SVG) - Eclipse IDE Compatability.
runtimeOnly 'xml-apis:xml-apis-ext:1.3.04'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'
testImplementation 'org.mockito:mockito-core:5.2.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.2.0'

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testImplementation 'org.mockito:mockito-core:5.12.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.12.0'
}

mainClassName = 'mekhq.MekHQ'
Expand Down Expand Up @@ -89,16 +89,9 @@ run {
jvmArgs = mhqJvmOptions
}

task compileMM (type: GradleBuild) {
description = 'Compiles the MM directory for packaging in a Jar'

buildName = "mhq-compile-mm"
dir = "${mmDir}"
tasks = [ 'compileTestJava' ]
}

task mmJar (type: Jar, dependsOn: compileMM) {
task mmJar (type: Jar) {
description = 'Builds a MegaMek jar from the current source'
dependsOn gradle.includedBuild('megamek').task(':compileTestJava')

archiveFileName = "MegaMek.jar"
from "${mmDir}/megamek/build/classes/java/main"
Expand All @@ -117,10 +110,12 @@ task mmJar (type: Jar, dependsOn: compileMM) {
outputs.file jarLocation
}

task mmJarLibDir (type: Jar, dependsOn: compileMM) {
task mmJarLibDir (type: Jar) {
description = 'Builds a MegaMek jar from the current source, with dependencies on the classpath in the same directory'

archiveFileName = "MegaMek.jar"
dependsOn gradle.includedBuild('megameklab').task(':compileTestJava')

from "${mmDir}/megamek/build/classes/java/main"
from "${mmDir}/megamek/build/resources/main"
manifest {
Expand All @@ -137,16 +132,9 @@ task mmJarLibDir (type: Jar, dependsOn: compileMM) {
outputs.file jarLocation
}

task compileMML (type: GradleBuild) {
description = 'Compiles the MML directory for packaging in a Jar'

buildName = "mhq-compile-mml"
dir = "${mmlDir}"
tasks = [ 'compileTestJava' ]
}

task mmlJar (type: Jar, dependsOn: compileMML) {
task mmlJar (type: Jar) {
archiveFileName = "MegaMekLab.jar"
dependsOn gradle.includedBuild('megameklab').task(':compileTestJava')
from "${mmlDir}/megameklab/build/classes/java/main"
from "${mmlDir}/megameklab/build/resources/main"
manifest {
Expand Down Expand Up @@ -348,83 +336,82 @@ distributions {
createExe {
description = 'Create Windows executable that wraps MekHQ jar'
mainClassName = project.mainClassName
jar = "${project.tasks.getByName("jar").archiveFile.get()}"
jarTask = project.tasks.jar
icon = "${projectDir}/${data}/images/misc/mekhq.ico"
internalName = 'MekHQ'
downloadUrl = 'https://adoptium.net/temurin/releases/?os=windows&arch=x64'
supportUrl = 'https://megamek.org'
copyright = '2024 MegaMek Development Team'
companyName = "MegaMek Development Team"
jvmOptions = project.ext.mmlJvmOptions
jreMinVersion = '17'
messagesJreNotFoundError = 'Go here for instructions on installing the correct version of Java: https://github.com/MegaMek/megamek/wiki/Updating-to-Adoptium'
classpath = ["lib/${mmJar.archiveFileName.get()}", "lib/${mmlJar.archiveFileName.get()}"] + project.sourceSets.main.runtimeClasspath.files
.findAll { it.name.endsWith(".jar") && !it.name.toLowerCase().startsWith("megamek")}
.collect { "${lib}/${it.name}" }
def iniFile = outfile.replace('.exe', '.l4j.ini')
outputs.file "${buildDir}/launch4j/${outfile}"
outputs.file "${buildDir}/launch4j/${iniFile}"
doLast {
new File("${buildDir}/${outputDir}/${iniFile}").text = """# Launch4j runtime config
# you can add arguments here that will be processed by the JVM at runtime
${project.ext.mhqJvmOptions.join('\n')}
"""
}
}

task createMMExe (type: Launch4jLibraryTask, dependsOn: mmJar) {
description = 'Create Windows executable stub for MM jar'
outfile = 'MegaMek.exe'
mainClassName = 'megamek.MegaMek'
jar = "lib/${mmJar.archiveFileName.get()}"
jarTask = project.tasks.mmJar
classpath = project.sourceSets.main.runtimeClasspath.files
.findAll { it.name.endsWith(".jar") && !it.name.toLowerCase().startsWith("megamek")}
.collect { "${lib}/${it.name}" }
icon = "${mmDir}/megamek/${data}/images/misc/megamek.ico"
internalName = 'MegaMek'
downloadUrl = 'https://adoptium.net/temurin/releases/?os=windows&arch=x64'
supportUrl = 'https://megamek.org'
copyright = '2024 MegaMek Development Team'
companyName = "MegaMek Development Team"
jvmOptions = project.ext.mmlJvmOptions
jreMinVersion = '17'
messagesJreNotFoundError = 'Go here for instructions on installing the correct version of Java: https://github.com/MegaMek/megamek/wiki/Updating-to-Adoptium'
dontWrapJar = true
def iniFile = outfile.replace('.exe', '.l4j.ini')
outputs.file "${buildDir}/launch4j/${outfile}"
outputs.file "${buildDir}/launch4j/${iniFile}"
doLast {
new File("${buildDir}/${outputDir}/${iniFile}").text = """# Launch4j runtime config
# you can add arguments here that will be processed by the JVM at runtime
${project.ext.mmJvmOptions.join('\n')}
"""
}
}

task createMMLExe (type: Launch4jLibraryTask, dependsOn: mmlJar) {
description = 'Create Windows executable stub for MML jar'
outfile = 'MegaMekLab.exe'
mainClassName = 'megameklab.MegaMekLab'
jar = "lib/${mmlJar.archiveFileName.get()}"
jarTask = project.tasks.mmlJar
classpath = ["lib/${mmJar.archiveFileName.get()}"] + project.sourceSets.main.runtimeClasspath.files
.findAll { it.name.endsWith(".jar") && !it.name.toLowerCase().startsWith("megamek")}
.collect { "${lib}/${it.name}" }
icon = "${mmlDir}/megameklab/${data}/images/misc/megameklab.ico"
internalName = 'MegaMekLab'
downloadUrl = 'https://adoptium.net/temurin/releases/?os=windows&arch=x64'
supportUrl = 'https://megamek.org'
copyright = '2024 MegaMek Development Team'
companyName = "MegaMek Development Team"
jvmOptions = project.ext.mmlJvmOptions
jreMinVersion = '17'
messagesJreNotFoundError = 'Go here for instructions on installing the correct version of Java: https://github.com/MegaMek/megamek/wiki/Updating-to-Adoptium'
dontWrapJar = true
def iniFile = outfile.replace('.exe', '.l4j.ini')
outputs.file "${buildDir}/launch4j/${outfile}"
outputs.file "${buildDir}/launch4j/${iniFile}"
doLast {
new File("${buildDir}/${outputDir}/${iniFile}").text = """# Launch4j runtime config
# you can add arguments here that will be processed by the JVM at runtime
${project.ext.mmlJvmOptions.join('\n')}
"""
}
}

task stageMM (type: GradleBuild) {
description = 'Prepares files from the MegaMek project'
group = 'distribution'

buildName = "mhq-stage-mm"
dependsOn gradle.includedBuild('megamek').task(':stageFiles')
dependsOn gradle.includedBuild('megamek').task(':createStartScripts')

dir = "${mmDir}"
tasks = [ 'stageFiles', 'createStartScripts' ]
}

task stageMML (type: GradleBuild) {
description = 'Prepares files from the MegaMekLab project'
group = 'distribution'

buildName = "mhq-stage-mml"
dependsOn gradle.includedBuild('megameklab').task(':stageFiles')
dependsOn gradle.includedBuild('megameklab').task(':createStartScripts')

dir = "${mmlDir}"
tasks = [ 'stageFiles', 'createStartScripts' ]
}

windowsDistZip {
Expand All @@ -447,6 +434,24 @@ unixDistTar {
compression = Compression.GZIP
}

distTar {
description = 'Creates *nix distribution packaged as a tar ball'
dependsOn stageFiles
dependsOn stageMM
dependsOn stageMML
dependsOn startScripts
archiveExtension = 'tar.gz'
compression = Compression.GZIP
}

distZip {
description = 'Creates *nix distribution packaged as a tar ball'
dependsOn stageFiles
dependsOn stageMM
dependsOn stageMML
dependsOn startScripts
}

// The repository can only be cloned into an empty directory so we need to delete anything left over
// from a previous build
task deleteMMRepoDir (type: Delete) {
Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
id 'org.ajoberstar.grgit' version '5.0.0'
id 'org.ajoberstar.grgit' version '5.2.2'
}

allprojects {
apply plugin: 'java'

sourceCompatibility = 11
targetCompatibility = 11
sourceCompatibility = 17
targetCompatibility = 17

repositories {
mavenLocal()
Expand All @@ -22,7 +22,7 @@ allprojects {

subprojects {
group = 'org.megamek'
version = '0.49.20-SNAPSHOT'
version = '0.50.0-SNAPSHOT'
}

ext {
Expand All @@ -31,16 +31,16 @@ ext {
mhqGitRoot = 'https://github.com/MegaMek/mekhq.git'
// Work on MML or MHQ sometimes requires changes in MM as well. The maven publishing tasks use
// these properties to append the branch name to the artifact id if the repo is not in the master
// branch, making it available separately to the child project.
// branch, making it available separately to the child project.
mhqBranch = grgit.branch.current().name
mhqBranchTag = mhqBranch.equals('master') ? '' : '-' + mhqBranch

// Allows setting a dependency on a different MM branch.
mmBranch = 'master'
mmBranchTag = mmBranch.equals('master') ? '' : '-' + mmBranch
mmlBranch = 'master'
mmlBranchTag = mmlBranch.equals('master') ? '' : '-' + mmlBranch

mmDir = "${rootDir}/../megamek"
mmlDir = "${rootDir}/../megameklab"
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.gradle.jvmArgs=-Dfile.encoding=utf-8
org.gradle.jvmArgs=-Xmx4g -XX:MaxPermSize=2048m -Dfile.encoding=utf-8
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 8 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include 'MekHQ'
// includeBuild('../megamek') will use the local megamek repository instead of a binary jar to fulfill
// the depedency.

def localSettings = file('settings_local.gradle')
def localSettings = file('./settings_local.gradle')
if (localSettings.exists()) {
apply from: localSettings
}

0 comments on commit 0a7b8a0

Please sign in to comment.