Skip to content

Commit

Permalink
Fix Windows console build, work around kryo issues
Browse files Browse the repository at this point in the history
Fix missing Java options in console build for Windows (which meant OpenSlide couldn't be loaded).

Avoid memoization errors with --add-opens, see ome/bioformats#3659
Note that reflection may cause more problems with kryo/gson/groovy (possibly).
  • Loading branch information
petebankhead committed Mar 23, 2021
1 parent 6b09b5a commit 73512bc
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,18 @@ task createPackage(dependsOn:createRuntime, type:Exec) {
logger.info("No package type specified, using default ${packageType}")
}
boolean associateFiles = packageType != 'app-image'

// Set up the main Java options
def javaOptions = []

// Default to using 50% available memory
javaOptions << '-XX:MaxRAMPercentage=50'

// Set the library path to the app directory, for loading native libraries
javaOptions << '-Djava.library.path=$APPDIR'

// Temp workaround for kyro and Bio-Formats memoization - see https://github.com/ome/bioformats/issues/3659
javaOptions << '--add-opens=java.base/java.util.regex=ALL-UNNAMED'

def params = ["${jdkHome}/bin/jpackage"]

Expand All @@ -778,9 +790,6 @@ task createPackage(dependsOn:createRuntime, type:Exec) {
String launcherName = 'QuPath'
// params << '--name' << 'QuPath-' + qupathVersion

// Default to using 50% available memory
params << '--java-options' << '-XX:MaxRAMPercentage=50'

if (OperatingSystem.current().isMacOsX()) {
params << '--mac-package-name' << 'QuPath'
params << '--mac-package-identifier' << 'QuPath'
Expand Down Expand Up @@ -813,20 +822,22 @@ task createPackage(dependsOn:createRuntime, type:Exec) {
def consoleLauncherName = launcherName + " (console)"
fileTemp.deleteOnExit()
fileTemp.text = 'win-console=true'
fileTemp << System.lineSeparator() << 'java-options=' << '-XX:MaxRAMPercentage=50' << ' -Dqupath.config=console'
// fileTemp << System.lineSeparator() << 'java-options=' << '-Dqupath.config=console'
fileTemp << System.lineSeparator()
fileTemp << 'java-options=' << '-Dqupath.config=console' << String.join(" ", javaOptions) << System.lineSeparator()
params << '--add-launcher' << "\"${consoleLauncherName}\"=\"${fileTemp.getAbsolutePath()}\""
} else
params << '--type' << packageType


params << '--name' << launcherName

// Add the java options
for (opt in javaOptions)
params << '--java-options' << opt

// Store the app version (typically a simplified version of the full format)
if (appVersion)
params << '--app-version' << appVersion

params << '--java-options' << '-Djava.library.path=$APPDIR'

// Try to find the icon
def pathIcon = Paths.get(
Expand Down

0 comments on commit 73512bc

Please sign in to comment.