< prev index next >

src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinExeBundler.java

Print this page




  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.jpackage.internal;
  27 
  28 import java.io.*;
  29 import java.nio.charset.Charset;
  30 import java.nio.file.Files;
  31 import java.text.MessageFormat;
  32 import java.util.*;
  33 import java.util.regex.Matcher;
  34 import java.util.regex.Pattern;
  35 
  36 import static jdk.jpackage.internal.WindowsBundlerParam.*;
  37 
  38 public class WinExeBundler extends AbstractBundler {
  39 
  40     private static final ResourceBundle I18N = ResourceBundle.getBundle(
  41             "jdk.jpackage.internal.resources.WinResources");
  42 
  43     public static final BundlerParamInfo<WinAppBundler> APP_BUNDLER =
  44             new WindowsBundlerParam<>(
  45             "win.app.bundler",
  46             WinAppBundler.class,
  47             params -> new WinAppBundler(),
  48             null);
  49 
  50     public static final BundlerParamInfo<File> EXE_IMAGE_DIR =
  51             new WindowsBundlerParam<>(
  52             "win.exe.imageDir",
  53             File.class,
  54             params -> {


 446         data.put(key, innosetupEscape(value));
 447     }
 448 
 449     private String innosetupEscape(String value) {
 450         if (value == null) {
 451             return "";
 452         }
 453 
 454         if (value.contains("\"") || !value.trim().equals(value)) {
 455             value = "\"" + value.replace("\"", "\"\"") + "\"";
 456         }
 457         return value;
 458     }
 459 
 460     boolean prepareMainProjectFile(Map<String, ? super Object> p)
 461             throws IOException {
 462         Map<String, String> data = new HashMap<>();
 463         data.put("PRODUCT_APP_IDENTIFIER",
 464                 innosetupEscape(getAppIdentifier(p)));
 465 
 466 
 467         validateValueAndPut(data, "INSTALLER_NAME", APP_NAME, p);
 468         validateValueAndPut(data, "APPLICATION_VENDOR", VENDOR, p);
 469         validateValueAndPut(data, "APPLICATION_VERSION", VERSION, p);
 470         validateValueAndPut(data, "INSTALLER_FILE_NAME",
 471                 INSTALLER_FILE_NAME, p);
 472 
 473         data.put("LAUNCHER_NAME",
 474                 innosetupEscape(WinAppBundler.getAppName(p)));
 475 
 476         data.put("APPLICATION_LAUNCHER_FILENAME",
 477                 innosetupEscape(WinAppBundler.getLauncherName(p)));
 478 
 479         data.put("APPLICATION_DESKTOP_SHORTCUT",
 480                 SHORTCUT_HINT.fetchFrom(p) ? "returnTrue" : "returnFalse");
 481         data.put("APPLICATION_MENU_SHORTCUT",
 482                 MENU_HINT.fetchFrom(p) ? "returnTrue" : "returnFalse");
 483         validateValueAndPut(data, "APPLICATION_GROUP", MENU_GROUP, p);
 484         validateValueAndPut(data, "APPLICATION_COPYRIGHT", COPYRIGHT, p);
 485 
 486         data.put("APPLICATION_LICENSE_FILE",




  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.jpackage.internal;
  27 
  28 import java.io.*;
  29 import java.nio.charset.Charset;
  30 import java.nio.file.Files;
  31 import java.text.MessageFormat;
  32 import java.util.*;


  33 
  34 import static jdk.jpackage.internal.WindowsBundlerParam.*;
  35 
  36 public class WinExeBundler extends AbstractBundler {
  37 
  38     private static final ResourceBundle I18N = ResourceBundle.getBundle(
  39             "jdk.jpackage.internal.resources.WinResources");
  40 
  41     public static final BundlerParamInfo<WinAppBundler> APP_BUNDLER =
  42             new WindowsBundlerParam<>(
  43             "win.app.bundler",
  44             WinAppBundler.class,
  45             params -> new WinAppBundler(),
  46             null);
  47 
  48     public static final BundlerParamInfo<File> EXE_IMAGE_DIR =
  49             new WindowsBundlerParam<>(
  50             "win.exe.imageDir",
  51             File.class,
  52             params -> {


 444         data.put(key, innosetupEscape(value));
 445     }
 446 
 447     private String innosetupEscape(String value) {
 448         if (value == null) {
 449             return "";
 450         }
 451 
 452         if (value.contains("\"") || !value.trim().equals(value)) {
 453             value = "\"" + value.replace("\"", "\"\"") + "\"";
 454         }
 455         return value;
 456     }
 457 
 458     boolean prepareMainProjectFile(Map<String, ? super Object> p)
 459             throws IOException {
 460         Map<String, String> data = new HashMap<>();
 461         data.put("PRODUCT_APP_IDENTIFIER",
 462                 innosetupEscape(getAppIdentifier(p)));
 463 
 464         validateValueAndPut(data, "INSTALL_DIR", WINDOWS_INSTALL_DIR, p);
 465         validateValueAndPut(data, "INSTALLER_NAME", APP_NAME, p);
 466         validateValueAndPut(data, "APPLICATION_VENDOR", VENDOR, p);
 467         validateValueAndPut(data, "APPLICATION_VERSION", VERSION, p);
 468         validateValueAndPut(data, "INSTALLER_FILE_NAME",
 469                 INSTALLER_FILE_NAME, p);
 470 
 471         data.put("LAUNCHER_NAME",
 472                 innosetupEscape(WinAppBundler.getAppName(p)));
 473 
 474         data.put("APPLICATION_LAUNCHER_FILENAME",
 475                 innosetupEscape(WinAppBundler.getLauncherName(p)));
 476 
 477         data.put("APPLICATION_DESKTOP_SHORTCUT",
 478                 SHORTCUT_HINT.fetchFrom(p) ? "returnTrue" : "returnFalse");
 479         data.put("APPLICATION_MENU_SHORTCUT",
 480                 MENU_HINT.fetchFrom(p) ? "returnTrue" : "returnFalse");
 481         validateValueAndPut(data, "APPLICATION_GROUP", MENU_GROUP, p);
 482         validateValueAndPut(data, "APPLICATION_COPYRIGHT", COPYRIGHT, p);
 483 
 484         data.put("APPLICATION_LICENSE_FILE",


< prev index next >