< prev index next >

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java

Print this page




  48 import static jdk.jpackage.internal.StandardBundlerParam.*;
  49 
  50 public class LinuxAppImageBuilder extends AbstractAppImageBuilder {
  51 
  52     private static final ResourceBundle I18N = ResourceBundle.getBundle(
  53         "jdk.jpackage.internal.resources.LinuxResources");
  54 
  55     private static final String LIBRARY_NAME = "libapplauncher.so";
  56 
  57     private final Path root;
  58     private final Path appDir;
  59     private final Path appModsDir;
  60     private final Path runtimeDir;
  61     private final Path resourcesDir;
  62     private final Path mdir;
  63 
  64     private final Map<String, ? super Object> params;
  65 
  66     public static final BundlerParamInfo<File> ICON_PNG =
  67             new StandardBundlerParam<>(
  68             I18N.getString("param.icon-png.name"),
  69             I18N.getString("param.icon-png.description"),
  70             "icon.png",
  71             File.class,
  72             params -> {
  73                 File f = ICON.fetchFrom(params);
  74                 if (f != null && !f.getName().toLowerCase().endsWith(".png")) {
  75                     Log.error(MessageFormat.format(I18N.getString(
  76                             "message.icon-not-png"), f));
  77                     return null;
  78                 }
  79                 return f;
  80             },
  81             (s, p) -> new File(s));
  82 
  83     public LinuxAppImageBuilder(Map<String, Object> config, Path imageOutDir)
  84             throws IOException {
  85         super(config,
  86                 imageOutDir.resolve(APP_NAME.fetchFrom(config) + "/runtime"));
  87 
  88         Objects.requireNonNull(imageOutDir);
  89 


 174         return appDir;
 175     }
 176 
 177     @Override
 178     public Path getAppModsDir() {
 179         return appModsDir;
 180     }
 181 
 182     @Override
 183     public void prepareApplicationFiles() throws IOException {
 184         Map<String, ? super Object> originalParams = new HashMap<>(params);
 185 
 186         // create the primary launcher
 187         createLauncherForEntryPoint(params, root);
 188 
 189         // Copy library to the launcher folder
 190         try (InputStream is_lib = getResourceAsStream(LIBRARY_NAME)) {
 191             writeEntry(is_lib, root.resolve(LIBRARY_NAME));
 192         }
 193 
 194         // create the secondary launchers, if any
 195         List<Map<String, ? super Object>> entryPoints
 196                 = StandardBundlerParam.SECONDARY_LAUNCHERS.fetchFrom(params);
 197         for (Map<String, ? super Object> entryPoint : entryPoints) {
 198             Map<String, ? super Object> tmp = new HashMap<>(originalParams);
 199             tmp.putAll(entryPoint);
 200             createLauncherForEntryPoint(tmp, root);
 201         }
 202 
 203         // Copy class path entries to Java folder
 204         copyApplication();
 205 
 206         // Copy icon to Resources folder
 207         copyIcon();
 208     }
 209 
 210     @Override
 211     public void prepareJreFiles() throws IOException {}
 212 
 213     private void createLauncherForEntryPoint(Map<String, ? super Object> p,
 214             Path rootDir) throws IOException {
 215         // Copy executable to Linux folder
 216         Path executableFile = root.resolve(getLauncherName(p));




  48 import static jdk.jpackage.internal.StandardBundlerParam.*;
  49 
  50 public class LinuxAppImageBuilder extends AbstractAppImageBuilder {
  51 
  52     private static final ResourceBundle I18N = ResourceBundle.getBundle(
  53         "jdk.jpackage.internal.resources.LinuxResources");
  54 
  55     private static final String LIBRARY_NAME = "libapplauncher.so";
  56 
  57     private final Path root;
  58     private final Path appDir;
  59     private final Path appModsDir;
  60     private final Path runtimeDir;
  61     private final Path resourcesDir;
  62     private final Path mdir;
  63 
  64     private final Map<String, ? super Object> params;
  65 
  66     public static final BundlerParamInfo<File> ICON_PNG =
  67             new StandardBundlerParam<>(


  68             "icon.png",
  69             File.class,
  70             params -> {
  71                 File f = ICON.fetchFrom(params);
  72                 if (f != null && !f.getName().toLowerCase().endsWith(".png")) {
  73                     Log.error(MessageFormat.format(I18N.getString(
  74                             "message.icon-not-png"), f));
  75                     return null;
  76                 }
  77                 return f;
  78             },
  79             (s, p) -> new File(s));
  80 
  81     public LinuxAppImageBuilder(Map<String, Object> config, Path imageOutDir)
  82             throws IOException {
  83         super(config,
  84                 imageOutDir.resolve(APP_NAME.fetchFrom(config) + "/runtime"));
  85 
  86         Objects.requireNonNull(imageOutDir);
  87 


 172         return appDir;
 173     }
 174 
 175     @Override
 176     public Path getAppModsDir() {
 177         return appModsDir;
 178     }
 179 
 180     @Override
 181     public void prepareApplicationFiles() throws IOException {
 182         Map<String, ? super Object> originalParams = new HashMap<>(params);
 183 
 184         // create the primary launcher
 185         createLauncherForEntryPoint(params, root);
 186 
 187         // Copy library to the launcher folder
 188         try (InputStream is_lib = getResourceAsStream(LIBRARY_NAME)) {
 189             writeEntry(is_lib, root.resolve(LIBRARY_NAME));
 190         }
 191 
 192         // create the additional launchers, if any
 193         List<Map<String, ? super Object>> entryPoints
 194                 = StandardBundlerParam.ADD_LAUNCHERS.fetchFrom(params);
 195         for (Map<String, ? super Object> entryPoint : entryPoints) {
 196             Map<String, ? super Object> tmp = new HashMap<>(originalParams);
 197             tmp.putAll(entryPoint);
 198             createLauncherForEntryPoint(tmp, root);
 199         }
 200 
 201         // Copy class path entries to Java folder
 202         copyApplication();
 203 
 204         // Copy icon to Resources folder
 205         copyIcon();
 206     }
 207 
 208     @Override
 209     public void prepareJreFiles() throws IOException {}
 210 
 211     private void createLauncherForEntryPoint(Map<String, ? super Object> p,
 212             Path rootDir) throws IOException {
 213         // Copy executable to Linux folder
 214         Path executableFile = root.resolve(getLauncherName(p));


< prev index next >