@@ -316,29 +316,28 @@ private void switchToNewLauncher() {
316
316
// In order to trigger it successfully, we need to set various properties:
317
317
318
318
File appConfigFile = new File (configDir , appSlug + ".toml" );
319
- File appUserConfigFile = new File (configDir , appSlug + ".cfg" );
320
319
List <String > lines ;
321
320
try {
322
321
lines = Files .readAllLines (appConfigFile .toPath ());
323
322
}
324
323
catch (IOException exc ) {
325
324
log .debug (exc );
326
- // Couldn't read from the config file; define some fallback values.
327
- lines = Arrays .asList (
328
- "-Dscijava.app.java-links='https://downloads.imagej.net/java/jdk-urls.txt'," ,
329
- "-Dscijava.app.java-version-minimum=8," ,
330
- "-Dscijava.app.java-version-recommended=21," ,
331
- "-Dscijava.app.config-file='" + appUserConfigFile .getPath () + "',"
332
- );
325
+ // Couldn't read from the config file.
326
+ lines = new ArrayList <>();
333
327
}
328
+
334
329
setPropertyIfNull ("scijava.app.name" , appTitle );
330
+
335
331
Path splashImage = appDir .toPath ().resolve ("images" ).resolve ("icon.png" );
336
332
setPropertyIfNull ("scijava.app.splash-image" , splashImage .toString ());
337
- extractAndSetProperty ("scijava.app.java-links" , lines );
338
- extractAndSetProperty ("scijava.app.java-version-minimum" , lines );
339
- extractAndSetProperty ("scijava.app.java-version-recommended" , lines );
340
- extractAndSetProperty ("scijava.app.config-file" , lines );
341
- setPropertyIfNull ("scijava.app.config-file" , appUserConfigFile .getPath ());
333
+
334
+ extractAndSetProperty ("scijava.app.java-links" , lines ,
335
+ "https://downloads.imagej.net/java/jdk-urls.txt" );
336
+ extractAndSetProperty ("scijava.app.java-version-minimum" , lines , "8" );
337
+ extractAndSetProperty ("scijava.app.java-version-recommended" , lines , "21" );
338
+ extractAndSetProperty ("scijava.app.config-file" , lines ,
339
+ new File (configDir , appSlug + ".cfg" ).getPath ());
340
+
342
341
String platform = UpdaterUtil .getPlatform ();
343
342
// FIXME: I think the macOS platform will be wrong here. It needs -arm64 suffix!
344
343
setPropertyIfNull ("scijava.app.java-platform" , platform );
@@ -508,13 +507,17 @@ private static void setPropertyIfNull(String name, String value) {
508
507
if (System .getProperty (name ) == null ) System .setProperty (name , value );
509
508
}
510
509
511
- private static void extractAndSetProperty (String name , List <String > lines ) {
510
+ private static void extractAndSetProperty (
511
+ String name ,
512
+ List <String > lines ,
513
+ String fallbackValue )
514
+ {
512
515
// No, the following replacement does not escape all problematic regex
513
516
// characters. But the properties we're working with here are only
514
517
// alphameric with dot separators, so it's OK. Hooray for pragmatism!
515
518
String escaped = name .replaceAll ("\\ ." , "\\ \\ ." );
516
519
Pattern p = Pattern .compile (".*'-D" + escaped + "=['\" ]?(.*?)['\" ]?,$" );
517
- String value = null ;
520
+ String value = fallbackValue ;
518
521
for (String line : lines ) {
519
522
Matcher m = p .matcher (line );
520
523
if (m .matches ()) {
0 commit comments