src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java
branchJDK-8200758-branch
changeset 57407 2c14fbeff1dc
parent 57404 a477b26bf888
child 57414 6eda749d3117
equal deleted inserted replaced
57405:539d8b3f9e1e 57407:2c14fbeff1dc
   484         return appDir != null;
   484         return appDir != null;
   485     }
   485     }
   486 
   486 
   487     public File bundle(Map<String, ? super Object> params, File outdir)
   487     public File bundle(Map<String, ? super Object> params, File outdir)
   488             throws PackagerException {
   488             throws PackagerException {
   489         if (!outdir.isDirectory() && !outdir.mkdirs()) {
   489 
   490             throw new PackagerException("error.cannot-create-output-dir",
   490         IOUtils.writableOutputDir(outdir.toPath());
   491                     outdir.getAbsolutePath());
       
   492         }
       
   493         if (!outdir.canWrite()) {
       
   494             throw new PackagerException("error.cannot-write-to-output-dir",
       
   495                     outdir.getAbsolutePath());
       
   496         }
       
   497 
   491 
   498         // validate we have valid tools before continuing
   492         // validate we have valid tools before continuing
   499         String light = TOOL_LIGHT_EXECUTABLE.fetchFrom(params);
   493         String light = TOOL_LIGHT_EXECUTABLE.fetchFrom(params);
   500         String candle = TOOL_CANDLE_EXECUTABLE.fetchFrom(params);
   494         String candle = TOOL_CANDLE_EXECUTABLE.fetchFrom(params);
   501         if (light == null || !new File(light).isFile() ||
   495         if (light == null || !new File(light).isFile() ||
   585             XMLStreamWriter xml = xmlFactory.createXMLStreamWriter(w);
   579             XMLStreamWriter xml = xmlFactory.createXMLStreamWriter(w);
   586 
   580 
   587             xml.writeStartDocument();
   581             xml.writeStartDocument();
   588             xml.writeStartElement("Include");
   582             xml.writeStartElement("Include");
   589 
   583 
   590             File launcher = new File(imageRootDir, WinAppBundler.getLauncherName(params));
   584             File launcher = new File(imageRootDir,
       
   585                     WinAppBundler.getLauncherRelativePath(params));
   591             if (launcher.exists()) {
   586             if (launcher.exists()) {
   592                 String iconPath = launcher.getAbsolutePath().replace(".exe", ".ico");
   587                 String iconPath = launcher.getAbsolutePath().replace(".exe", ".ico");
   593                 if (MENU_HINT.fetchFrom(params)) {
   588                 if (MENU_HINT.fetchFrom(params)) {
   594                     xml.writeStartElement("Icon");
   589                     xml.writeStartElement("Icon");
   595                     xml.writeAttribute("Id", "StartMenuIcon.exe");
   590                     xml.writeAttribute("Id", "StartMenuIcon.exe");
   606 
   601 
   607             for (int i = 0; i < addLaunchers.size(); i++) {
   602             for (int i = 0; i < addLaunchers.size(); i++) {
   608                 Map<String, ? super Object> sl = addLaunchers.get(i);
   603                 Map<String, ? super Object> sl = addLaunchers.get(i);
   609                 if (SHORTCUT_HINT.fetchFrom(sl) || MENU_HINT.fetchFrom(sl)) {
   604                 if (SHORTCUT_HINT.fetchFrom(sl) || MENU_HINT.fetchFrom(sl)) {
   610                     File addLauncher = new File(imageRootDir,
   605                     File addLauncher = new File(imageRootDir,
   611                             WinAppBundler.getLauncherName(sl));
   606                             WinAppBundler.getLauncherRelativePath(sl));
   612                     String addLauncherPath
   607                     String addLauncherPath
   613                             = relativePath(imageRootDir, addLauncher);
   608                             = relativePath(imageRootDir, addLauncher);
   614                     String addLauncherIconPath
   609                     String addLauncherIconPath
   615                             = addLauncherPath.replace(".exe", ".ico");
   610                             = addLauncherPath.replace(".exe", ".ico");
   616 
   611 
   739         out.println(prefix + "  <RemoveFolder Id=\"RemoveDir"
   734         out.println(prefix + "  <RemoveFolder Id=\"RemoveDir"
   740                 + (id++) + "\" On=\"uninstall\" />");
   735                 + (id++) + "\" On=\"uninstall\" />");
   741 
   736 
   742         boolean needRegistryKey = !MSI_SYSTEM_WIDE.fetchFrom(params);
   737         boolean needRegistryKey = !MSI_SYSTEM_WIDE.fetchFrom(params);
   743         File imageRootDir = WIN_APP_IMAGE.fetchFrom(params);
   738         File imageRootDir = WIN_APP_IMAGE.fetchFrom(params);
   744         File launcherFile =
   739         File launcherFile = new File(imageRootDir,
   745                 new File(imageRootDir, WinAppBundler.getLauncherName(params));
   740                 WinAppBundler.getLauncherRelativePath(params));
   746 
   741 
   747         // Find out if we need to use registry. We need it if
   742         // Find out if we need to use registry. We need it if
   748         //  - we doing user level install as file can not serve as KeyPath
   743         //  - we doing user level install as file can not serve as KeyPath
   749         //  - if we adding shortcut in this component
   744         //  - if we adding shortcut in this component
   750 
   745 
   812             List<Map<String, ? super Object>> addLaunchers =
   807             List<Map<String, ? super Object>> addLaunchers =
   813                     ADD_LAUNCHERS.fetchFrom(params);
   808                     ADD_LAUNCHERS.fetchFrom(params);
   814             for (int i = 0; i < addLaunchers.size(); i++) {
   809             for (int i = 0; i < addLaunchers.size(); i++) {
   815                 Map<String, ? super Object> sl = addLaunchers.get(i);
   810                 Map<String, ? super Object> sl = addLaunchers.get(i);
   816                 File addLauncherFile = new File(imageRootDir,
   811                 File addLauncherFile = new File(imageRootDir,
   817                         WinAppBundler.getLauncherName(sl));
   812                         WinAppBundler.getLauncherRelativePath(sl));
   818                 if (f.equals(addLauncherFile)) {
   813                 if (f.equals(addLauncherFile)) {
   819                     if (SHORTCUT_HINT.fetchFrom(sl)) {
   814                     if (SHORTCUT_HINT.fetchFrom(sl)) {
   820                         out.println(prefix
   815                         out.println(prefix
   821                                 + "  <Shortcut Id=\"desktopShortcut"
   816                                 + "  <Shortcut Id=\"desktopShortcut"
   822                                 + i + "\" Directory=\"DesktopFolder\""
   817                                 + i + "\" Directory=\"DesktopFolder\""