src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java
branchJDK-8200758-branch
changeset 57091 06bc4bd64599
parent 57078 db003bfc5bf7
child 57096 d06bec27f8c9
equal deleted inserted replaced
57080:bd4ce7f9ea2c 57091:06bc4bd64599
    22  * or visit www.oracle.com if you need additional information or have any
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package jdk.jpackage.internal;
    26 package jdk.jpackage.internal;
    27 
       
    28 import jdk.jpackage.internal.resources.WinResources;
       
    29 
    27 
    30 import java.io.File;
    28 import java.io.File;
    31 import java.io.FileOutputStream;
    29 import java.io.FileOutputStream;
    32 import java.io.FileInputStream;
    30 import java.io.FileInputStream;
    33 import java.io.IOException;
    31 import java.io.IOException;
   251     public Path getAppModsDir() {
   249     public Path getAppModsDir() {
   252         return appModsDir;
   250         return appModsDir;
   253     }
   251     }
   254 
   252 
   255     @Override
   253     @Override
   256     public InputStream getResourceAsStream(String name) {
       
   257         return WinResources.class.getResourceAsStream(name);
       
   258     }
       
   259 
       
   260     @Override
       
   261     public void prepareApplicationFiles() throws IOException {
   254     public void prepareApplicationFiles() throws IOException {
   262         Map<String, ? super Object> originalParams = new HashMap<>(params);
   255         Map<String, ? super Object> originalParams = new HashMap<>(params);
   263         File rootFile = root.toFile();
   256         File rootFile = root.toFile();
   264         if (!rootFile.isDirectory() && !rootFile.mkdirs()) {
   257         if (!rootFile.isDirectory() && !rootFile.mkdirs()) {
   265             throw new RuntimeException(MessageFormat.format(I18N.getString(
   258             throw new RuntimeException(MessageFormat.format(I18N.getString(
   321         }
   314         }
   322     }
   315     }
   323 
   316 
   324     // TODO: do we still need this?
   317     // TODO: do we still need this?
   325     private boolean copyMSVCDLLs(String VS_VER) throws IOException {
   318     private boolean copyMSVCDLLs(String VS_VER) throws IOException {
   326         final InputStream REDIST_MSVCR_URL =
   319         final InputStream REDIST_MSVCR_URL = getResourceAsStream(
   327                 WinResources.class.getResourceAsStream(
       
   328                 REDIST_MSVCR.replaceAll("VS_VER", VS_VER));
   320                 REDIST_MSVCR.replaceAll("VS_VER", VS_VER));
   329         final InputStream REDIST_MSVCP_URL =
   321         final InputStream REDIST_MSVCP_URL = getResourceAsStream(
   330                 WinResources.class.getResourceAsStream(
       
   331                 REDIST_MSVCP.replaceAll("VS_VER", VS_VER));
   322                 REDIST_MSVCP.replaceAll("VS_VER", VS_VER));
   332 
   323 
   333         if (REDIST_MSVCR_URL != null && REDIST_MSVCP_URL != null) {
   324         if (REDIST_MSVCR_URL != null && REDIST_MSVCP_URL != null) {
   334             Files.copy(
   325             Files.copy(
   335                     REDIST_MSVCR_URL,
   326                     REDIST_MSVCR_URL,
   375         validateValueAndPut(data, "PRODUCT_VERSION", VERSION, params);
   366         validateValueAndPut(data, "PRODUCT_VERSION", VERSION, params);
   376         data.put("SPECIAL_BUILD", "");
   367         data.put("SPECIAL_BUILD", "");
   377 
   368 
   378         Writer w = new BufferedWriter(
   369         Writer w = new BufferedWriter(
   379                 new FileWriter(getConfig_ExecutableProperties(params)));
   370                 new FileWriter(getConfig_ExecutableProperties(params)));
   380         String content = preprocessTextResource(BUNDLER_PREFIX
   371         String content = preprocessTextResource(
   381                 + getConfig_ExecutableProperties(params).getName(),
   372                 getConfig_ExecutableProperties(params).getName(),
   382                 I18N.getString("resource.executable-properties-template"),
   373                 I18N.getString("resource.executable-properties-template"),
   383                 EXECUTABLE_PROPERTIES_TEMPLATE, data,
   374                 EXECUTABLE_PROPERTIES_TEMPLATE, data,
   384                 VERBOSE.fetchFrom(params),
   375                 VERBOSE.fetchFrom(params),
   385                 DROP_IN_RESOURCES_ROOT.fetchFrom(params));
   376                 RESOURCE_DIR.fetchFrom(params));
   386         w.write(content);
   377         w.write(content);
   387         w.close();
   378         w.close();
   388     }
   379     }
   389 
   380 
   390     private void createLauncherForEntryPoint(
   381     private void createLauncherForEntryPoint(
   394         File icon = launcherIcon != null ?
   385         File icon = launcherIcon != null ?
   395                 launcherIcon : ICON_ICO.fetchFrom(params);
   386                 launcherIcon : ICON_ICO.fetchFrom(params);
   396         File iconTarget = getConfig_AppIcon(p);
   387         File iconTarget = getConfig_AppIcon(p);
   397 
   388 
   398         InputStream in = locateResource(
   389         InputStream in = locateResource(
   399                "package/windows/" + APP_NAME.fetchFrom(params) + ".ico",
   390                 APP_NAME.fetchFrom(params) + ".ico",
   400                 "icon",
   391                 "icon",
   401                 TEMPLATE_APP_ICON,
   392                 TEMPLATE_APP_ICON,
   402                 icon,
   393                 icon,
   403                 VERBOSE.fetchFrom(params),
   394                 VERBOSE.fetchFrom(params),
   404                 DROP_IN_RESOURCES_ROOT.fetchFrom(params));
   395                 RESOURCE_DIR.fetchFrom(params));
   405         Files.copy(in, iconTarget.toPath());
   396         Files.copy(in, iconTarget.toPath());
   406 
   397 
   407         writeCfgFile(p, root.resolve(
   398         writeCfgFile(p, root.resolve(
   408                 getLauncherCfgName(p)).toFile(), "$APPDIR\\runtime");
   399                 getLauncherCfgName(p)).toFile(), "$APPDIR\\runtime");
   409 
   400