Skip to content

[Maintenance]: Improve JAR experience #5970

Description

@kwvanderlinde

Describe the problem

It is not easy to run MapTool using the JAR file due to the large number of command line parameters we rely on. Most of these are related to opening modules, and are required to run the application at all. Others need to be specified for correct behaviour or to match the behaviour of installable packages, though MT will run without them. Still others have once served a purpose but are no longer needed to do newer JVM behaviour.

This will act as a parent issue for a few independent tasks that should achieve the end goal.

The improvement you'd like to see

  • Redundant options are removed (-Dfile.encoding=UTF-8 is default since Java 18, +ShowCodeDetailsInExceptionMessages is default since Java 15)
  • Options that reflect build parameters are moved into resources inside the JAR (sentry.environment, -v argument)
  • Options for direct use by MT code are made the default values so they don't need to be overridden (MAPTOOL_DATADIR)
  • Options that are needed but could be set programmatically should do so (java.util.Arrays.useLegacyMergeSort)
  • --add-opens flags are removed by producing a modular JAR file or in some other way.

Expected Benefits

The JAR file could be run with few, if any, command line arguments required. I,e., this would be ideal:

java -jar MapTool-1.18.jar

It also means that parameters like the version number can be more reliable with JAR files since they don't have to come from the user.

Additional Context

Today, this is what is looks like trying to run MapTool-1.18.jar today with the same behaviour as an installed package:

"$JAVA_HOME/bin/java" -Xss8M -Dsun.java2d.d3d=false -Dsentry.environment=Production -Dfile.encoding=UTF-8 -Dpolyglot.engine.WarnInterpreterOnly=false -Djava.util.Arrays.useLegacyMergeSort=true -DMAPTOOL_DATADIR=.maptool-rptools -XX:+ShowCodeDetailsInExceptionMessages --add-opens=java.desktop/java.awt=ALL-UNNAMED --add-opens=java.desktop/java.awt.geom=ALL-UNNAMED --add-opens=java.desktop/sun.awt.geom=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=javafx.web/javafx.scene.web=ALL-UNNAMED --add-opens=javafx.web/com.sun.webkit=ALL-UNNAMED --add-opens=javafx.web/com.sun.webkit.dom=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.desktop/sun.awt=ALL-UNNAMED --add-opens=java.desktop/sun.java2d=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/sun.awt.shell=ALL-UNNAMED --add-opens=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED -jar MapTool-1.18.jar -v=1.18.6

Metadata

Metadata

Assignees

Labels

code-maintenanceAdding/editing javadocs, unit tests, formatting.
No fields configured for Code Maintenance.

Projects

Status
In-Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions