src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractImageBundler.java
branchJDK-8200758-branch
changeset 57256 d7c27451f759
parent 57213 8ff0a29bf9bc
child 57307 4948a1944cf9
equal deleted inserted replaced
57255:f686bda3b831 57256:d7c27451f759
    57 
    57 
    58     public void imageBundleValidation(Map<String, ? super Object> p)
    58     public void imageBundleValidation(Map<String, ? super Object> p)
    59              throws ConfigException {
    59              throws ConfigException {
    60         StandardBundlerParam.validateMainClassInfoFromAppResources(p);
    60         StandardBundlerParam.validateMainClassInfoFromAppResources(p);
    61 
    61 
    62         boolean hasMainJar = MAIN_JAR.fetchFrom(p) != null;
       
    63         boolean hasMainModule =
       
    64                 StandardBundlerParam.MODULE.fetchFrom(p) != null;
       
    65         boolean hasMainClass = MAIN_CLASS.fetchFrom(p) != null;
       
    66         boolean runtime = RUNTIME_INSTALLER.fetchFrom(p);
       
    67 
       
    68         if (!hasMainJar && !hasMainModule && !hasMainClass && !runtime) {
       
    69             throw new ConfigException(
       
    70                     I18N.getString("error.no-application-class"),
       
    71                     I18N.getString("error.no-application-class.advice"));
       
    72         }
       
    73     }
    62     }
    74 
    63 
    75     public static void extractFlagsFromVersion(
    64     public static void extractFlagsFromVersion(
    76             Map<String, ? super Object> params, String versionOutput) {
    65             Map<String, ? super Object> params, String versionOutput) {
    77         Pattern bitArchPattern = Pattern.compile("(\\d*)[- ]?[bB]it");
    66         Pattern bitArchPattern = Pattern.compile("(\\d*)[- ]?[bB]it");
   119             }
   108             }
   120         }
   109         }
   121     }
   110     }
   122 
   111 
   123     protected File createRoot(Map<String, ? super Object> p,
   112     protected File createRoot(Map<String, ? super Object> p,
   124             File outputDirectory, boolean dependentTask,
   113             File outputDirectory, boolean dependentTask, String name)
   125             String name, String jlinkKey) throws PackagerException {
   114             throws PackagerException {
   126         if (!outputDirectory.isDirectory() && !outputDirectory.mkdirs()) {
   115         if (!outputDirectory.isDirectory() && !outputDirectory.mkdirs()) {
   127             throw new RuntimeException(MessageFormat.format(
   116             throw new RuntimeException(MessageFormat.format(
   128                     I18N.getString("error.cannot-create-output-dir"),
   117                     I18N.getString("error.cannot-create-output-dir"),
   129                     outputDirectory.getAbsolutePath()));
   118                     outputDirectory.getAbsolutePath()));
   130         }
   119         }
   141 
   130 
   142         // Create directory structure
   131         // Create directory structure
   143         File rootDirectory = new File(outputDirectory, name);
   132         File rootDirectory = new File(outputDirectory, name);
   144 
   133 
   145         if (rootDirectory.exists()) {
   134         if (rootDirectory.exists()) {
   146             if (!(OVERWRITE.fetchFrom(p))) {
   135             throw new PackagerException("error.root-exists",
   147                 throw new PackagerException("error.root-exists-without-overwrite",
   136                     rootDirectory.getAbsolutePath());
   148                         rootDirectory.getAbsolutePath());
       
   149             }
       
   150             try {
       
   151                 IOUtils.deleteRecursive(rootDirectory);
       
   152             } catch (IOException ioe) {
       
   153                 throw new PackagerException(ioe);
       
   154             }
       
   155         }
   137         }
       
   138 
   156         rootDirectory.mkdirs();
   139         rootDirectory.mkdirs();
   157 
   140 
   158         return rootDirectory;
   141         return rootDirectory;
   159     }
   142     }
   160 
   143