< prev index next >

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

Print this page




  29 import java.io.IOException;
  30 import java.io.InputStream;
  31 import java.nio.file.Files;
  32 import java.nio.file.Path;
  33 import java.nio.file.StandardCopyOption;
  34 import java.text.MessageFormat;
  35 import java.util.HashMap;
  36 import java.util.List;
  37 import java.util.Map;
  38 import java.util.Objects;
  39 import java.util.ResourceBundle;
  40 
  41 import static jdk.jpackage.internal.StandardBundlerParam.*;
  42 
  43 public class LinuxAppImageBuilder extends AbstractAppImageBuilder {
  44 
  45     private static final ResourceBundle I18N = ResourceBundle.getBundle(
  46         "jdk.jpackage.internal.resources.LinuxResources");
  47 
  48     private static final String LIBRARY_NAME = "libapplauncher.so";
  49     private final static String DEFAULT_ICON = "java32.png";
  50 
  51     private final Path root;
  52     private final Path appDir;
  53     private final Path appModsDir;
  54     private final Path runtimeDir;
  55     private final Path binDir;
  56     private final Path mdir;
  57 
  58     public static final BundlerParamInfo<File> ICON_PNG =
  59             new StandardBundlerParam<>(
  60             "icon.png",
  61             File.class,
  62             params -> {
  63                 File f = ICON.fetchFrom(params);
  64                 if (f != null && !f.getName().toLowerCase().endsWith(".png")) {
  65                     Log.error(MessageFormat.format(I18N.getString(
  66                             "message.icon-not-png"), f));
  67                     return null;
  68                 }
  69                 return f;


  89 
  90     public LinuxAppImageBuilder(String appName, Path imageOutDir)
  91             throws IOException {
  92         super(null, imageOutDir.resolve(appName));
  93 
  94         Objects.requireNonNull(imageOutDir);
  95 
  96         this.root = imageOutDir.resolve(appName);
  97         this.appDir = null;
  98         this.appModsDir = null;
  99         this.runtimeDir = null;
 100         this.binDir = null;
 101         this.mdir = null;
 102     }
 103 
 104     private void writeEntry(InputStream in, Path dstFile) throws IOException {
 105         Files.createDirectories(dstFile.getParent());
 106         Files.copy(in, dstFile);
 107     }
 108 
 109     // it is static for the sake of sharing with "installer" bundlers
 110     // that may skip calls to validate/bundle in this class!
 111     public static File getRootDir(File outDir,
 112             Map<String, ? super Object> params) {
 113         return new File(outDir, APP_NAME.fetchFrom(params));
 114     }
 115 
 116     public static String getLauncherRelativePath(
 117             Map<String, ? super Object> params) {
 118         return "bin" + File.separator + APP_NAME.fetchFrom(params);
 119     }
 120 
 121     private static String getLauncherName(Map<String, ? super Object> params) {
 122         return APP_NAME.fetchFrom(params);
 123     }
 124 
 125     public static String getLauncherCfgName(
 126             Map<String, ? super Object> params) {
 127         return "app" + File.separator + APP_NAME.fetchFrom(params) + ".cfg";
 128     }
 129 
 130     @Override
 131     public Path getAppDir() {
 132         return appDir;
 133     }
 134 
 135     @Override
 136     public Path getAppModsDir() {
 137         return appModsDir;
 138     }
 139 
 140     @Override
 141     public void prepareApplicationFiles(Map<String, ? super Object> params)




  29 import java.io.IOException;
  30 import java.io.InputStream;
  31 import java.nio.file.Files;
  32 import java.nio.file.Path;
  33 import java.nio.file.StandardCopyOption;
  34 import java.text.MessageFormat;
  35 import java.util.HashMap;
  36 import java.util.List;
  37 import java.util.Map;
  38 import java.util.Objects;
  39 import java.util.ResourceBundle;
  40 
  41 import static jdk.jpackage.internal.StandardBundlerParam.*;
  42 
  43 public class LinuxAppImageBuilder extends AbstractAppImageBuilder {
  44 
  45     private static final ResourceBundle I18N = ResourceBundle.getBundle(
  46         "jdk.jpackage.internal.resources.LinuxResources");
  47 
  48     private static final String LIBRARY_NAME = "libapplauncher.so";
  49     final static String DEFAULT_ICON = "java32.png";
  50 
  51     private final Path root;
  52     private final Path appDir;
  53     private final Path appModsDir;
  54     private final Path runtimeDir;
  55     private final Path binDir;
  56     private final Path mdir;
  57 
  58     public static final BundlerParamInfo<File> ICON_PNG =
  59             new StandardBundlerParam<>(
  60             "icon.png",
  61             File.class,
  62             params -> {
  63                 File f = ICON.fetchFrom(params);
  64                 if (f != null && !f.getName().toLowerCase().endsWith(".png")) {
  65                     Log.error(MessageFormat.format(I18N.getString(
  66                             "message.icon-not-png"), f));
  67                     return null;
  68                 }
  69                 return f;


  89 
  90     public LinuxAppImageBuilder(String appName, Path imageOutDir)
  91             throws IOException {
  92         super(null, imageOutDir.resolve(appName));
  93 
  94         Objects.requireNonNull(imageOutDir);
  95 
  96         this.root = imageOutDir.resolve(appName);
  97         this.appDir = null;
  98         this.appModsDir = null;
  99         this.runtimeDir = null;
 100         this.binDir = null;
 101         this.mdir = null;
 102     }
 103 
 104     private void writeEntry(InputStream in, Path dstFile) throws IOException {
 105         Files.createDirectories(dstFile.getParent());
 106         Files.copy(in, dstFile);
 107     }
 108 
 109     public static String getLauncherName(Map<String, ? super Object> params) {












 110         return APP_NAME.fetchFrom(params);
 111     }
 112 
 113     public static String getLauncherCfgName(
 114             Map<String, ? super Object> params) {
 115         return "app" + File.separator + APP_NAME.fetchFrom(params) + ".cfg";
 116     }
 117 
 118     @Override
 119     public Path getAppDir() {
 120         return appDir;
 121     }
 122 
 123     @Override
 124     public Path getAppModsDir() {
 125         return appModsDir;
 126     }
 127 
 128     @Override
 129     public void prepareApplicationFiles(Map<String, ? super Object> params)


< prev index next >