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