# HG changeset patch # User herrick # Date 1560468744 14400 # Node ID a477b26bf8887c8686bd1b30471ae9fe405163f6 # Parent 05e411fc4b77def2ba8e72f07893b96e38f82b4b 8223643: Provide better defined context for custom installer steps on Windows Submitted-by: asemenyuk Reviewed-by: almatvee diff -r 05e411fc4b77 -r a477b26bf888 make/CompileJavaModules.gmk --- a/make/CompileJavaModules.gmk Thu Jun 13 19:04:29 2019 -0400 +++ b/make/CompileJavaModules.gmk Thu Jun 13 19:32:24 2019 -0400 @@ -381,7 +381,7 @@ ################################################################################ jdk.jpackage_COPY += .gif .png .txt .spec .script .prerm .preinst .postrm .postinst .list \ - .desktop .copyright .control .plist .template .icns .scpt .entitlements .wxs .iss .ico .bmp + .desktop .copyright .control .plist .template .icns .scpt .entitlements .wxs .wxl .iss .ico .bmp jdk.jpackage_CLEAN += .properties diff -r 05e411fc4b77 -r a477b26bf888 src/jdk.jpackage/share/classes/jdk/jpackage/main/CommandLine.java --- a/src/jdk.jpackage/share/classes/jdk/jpackage/main/CommandLine.java Thu Jun 13 19:04:29 2019 -0400 +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/main/CommandLine.java Thu Jun 13 19:32:24 2019 -0400 @@ -49,7 +49,7 @@ * This code and its internal interfaces are subject to change or * deletion without notice. */ -public class CommandLine { +class CommandLine { /** * Process Win32-style command files for the specified command line * arguments and return the resulting arguments. A command file argument @@ -98,7 +98,7 @@ * @param args the arguments that may contain @files * @return the arguments, with environment variable's content and expansion of @files * @throws IOException if there is a problem reading any of the @files - * @throws com.sun.tools.javac.main.CommandLine.UnmatchedQuote + * @throws UnmatchedQuote */ public static List parse(String envVariable, List args) throws IOException, UnmatchedQuote { @@ -125,7 +125,7 @@ * @param args the arguments that may contain @files * @return the arguments, with environment variable's content and expansion of @files * @throws IOException if there is a problem reading any of the @files - * @throws com.sun.tools.javac.main.CommandLine.UnmatchedQuote + * @throws UnmatchedQuote */ public static String[] parse(String envVariable, String[] args) throws IOException, UnmatchedQuote { List out = parse(envVariable, Arrays.asList(args)); diff -r 05e411fc4b77 -r a477b26bf888 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java Thu Jun 13 19:04:29 2019 -0400 +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java Thu Jun 13 19:32:24 2019 -0400 @@ -28,12 +28,66 @@ import java.io.*; import java.nio.charset.Charset; import java.nio.file.Files; +import java.nio.file.Paths; import java.text.MessageFormat; import java.util.*; import java.util.regex.Pattern; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; import static jdk.jpackage.internal.WindowsBundlerParam.*; +/** + * WinMsiBundler + * + * Produces .msi installer from application image. Uses WiX Toolkit to build + * .msi installer. + *

+ * {@link #execute} method creates a number of source files with the description + * of installer to be processed by WiX tools. Generated source files are stored + * in "config" subdirectory next to "app" subdirectory in the root work + * directory. The following WiX source files are generated: + *

    + *
  • main.wxs. Main source file with the installer description + *
  • bundle.wxi. Source file with application and Java run-time directory tree + * description. This source file is included from main.wxs + *
  • icons.wxi. Source file with the list of icons used by the application. + * This source file is included from main.wxs + *
+ *

+ * main.wxs file is a copy of main.wxs resource from + * jdk.jpackage.internal.resources package. It is parametrized with the + * following WiX variables: + *

    + *
  • JpAppName. Name of the application. Set to the value of --name command + * line option + *
  • JpAppVersion. Version of the application. Set to the value of + * --app-version command line option + *
  • JpAppVendor. Vendor of the application. Set to the value of --vendor + * command line option + *
  • JpAppDescription. Description of the application. Set to the value of + * --description command line option + *
  • JpProductCode. Set to product code UUID of the application. Random value + * generated by jpackage every time {@link #execute} method is called + *
  • JpProductUpgradeCode. Set to upgrade code UUID of the application. Random + * value generated by jpackage every time {@link #execute} method is called if + * --win-upgrade-uuid command line option is not specified. Otherwise this + * variable is set to the value of --win-upgrade-uuid command line option + *
  • JpAllowDowngrades. Set to "yes" if --win-upgrade-uuid command line option + * was specified. Undefined otherwise + *
  • JpLicenseRtf. Set to the value of --license-file command line option. + * Undefined is --license-file command line option was not specified + *
  • JpInstallDirChooser. Set to "yes" if --win-dir-chooser command line + * option was specified. Undefined otherwise + *
  • JpConfigDir. Absolute path to the directory with generated WiX source + * files. + *
  • JpIsSystemWide. Set to "yes" if --win-per-user-install command line + * option was not specified. Undefined otherwise + *
  • JpWixVersion36OrNewer. Set to "yes" if WiX Toolkit v3.6 or newer is used. + * Undefined otherwise + *
+ */ public class WinMsiBundler extends AbstractBundler { private static final ResourceBundle I18N = ResourceBundle.getBundle( @@ -403,6 +457,7 @@ File destFile = new File(CONFIG_ROOT.fetchFrom(params), lfile.getName()); IOUtils.copyFile(lfile, destFile); + destFile.setWritable(true); ensureByMutationFileIsRTF(destFile); } @@ -452,6 +507,8 @@ throw new PackagerException("error.no-wix-tools"); } + Map wixVars = null; + File imageDir = MSI_IMAGE_DIR.fetchFrom(params); try { imageDir.mkdirs(); @@ -464,8 +521,10 @@ params.put(MENU_HINT.getID(), true); } - if (prepareProto(params) && prepareWiXConfig(params) - && prepareBasicProjectConfig(params)) { + prepareBasicProjectConfig(params); + if (prepareProto(params)) { + wixVars = prepareWiXConfig(params); + File configScriptSrc = getConfig_Script(params); if (configScriptSrc.exists()) { // we need to be running post script in the image folder @@ -482,7 +541,7 @@ configScript.getAbsolutePath())); IOUtils.run("wscript", configScript); } - return buildMSI(params, outdir); + return buildMSI(params, wixVars, outdir); } return null; } catch (IOException ex) { @@ -497,7 +556,7 @@ APP_NAME.fetchFrom(params) + "-post-image.wsf"); } - private boolean prepareBasicProjectConfig( + private void prepareBasicProjectConfig( Map params) throws IOException { fetchResource(getConfig_Script(params).getName(), I18N.getString("resource.post-install-script"), @@ -505,15 +564,74 @@ getConfig_Script(params), VERBOSE.fetchFrom(params), RESOURCE_DIR.fetchFrom(params)); - return true; } - private String relativePath(File basedir, File file) { + private static String relativePath(File basedir, File file) { return file.getAbsolutePath().substring( basedir.getAbsolutePath().length() + 1); } - boolean prepareMainProjectFile( + private void prepareIconsFile( + Map params) throws IOException { + + File imageRootDir = WIN_APP_IMAGE.fetchFrom(params); + + List> addLaunchers = + ADD_LAUNCHERS.fetchFrom(params); + + XMLOutputFactory xmlFactory = XMLOutputFactory.newInstance(); + try (Writer w = new BufferedWriter(new FileWriter(new File( + CONFIG_ROOT.fetchFrom(params), "icons.wxi")))) { + XMLStreamWriter xml = xmlFactory.createXMLStreamWriter(w); + + xml.writeStartDocument(); + xml.writeStartElement("Include"); + + File launcher = new File(imageRootDir, WinAppBundler.getLauncherName(params)); + if (launcher.exists()) { + String iconPath = launcher.getAbsolutePath().replace(".exe", ".ico"); + if (MENU_HINT.fetchFrom(params)) { + xml.writeStartElement("Icon"); + xml.writeAttribute("Id", "StartMenuIcon.exe"); + xml.writeAttribute("SourceFile", iconPath); + xml.writeEndElement(); + } + if (SHORTCUT_HINT.fetchFrom(params)) { + xml.writeStartElement("Icon"); + xml.writeAttribute("Id", "DesktopIcon.exe"); + xml.writeAttribute("SourceFile", iconPath); + xml.writeEndElement(); + } + } + + for (int i = 0; i < addLaunchers.size(); i++) { + Map sl = addLaunchers.get(i); + if (SHORTCUT_HINT.fetchFrom(sl) || MENU_HINT.fetchFrom(sl)) { + File addLauncher = new File(imageRootDir, + WinAppBundler.getLauncherName(sl)); + String addLauncherPath + = relativePath(imageRootDir, addLauncher); + String addLauncherIconPath + = addLauncherPath.replace(".exe", ".ico"); + + xml.writeStartElement("Icon"); + xml.writeAttribute("Id", "Launcher" + i + ".exe"); + xml.writeAttribute("SourceFile", addLauncherIconPath); + xml.writeEndElement(); + } + } + + xml.writeEndElement(); + xml.writeEndDocument(); + xml.flush(); + xml.close(); + } catch (XMLStreamException ex) { + Log.verbose(ex); + throw new IOException(ex); + } + } + + Map prepareMainProjectFile( Map params) throws IOException { Map data = new HashMap<>(); @@ -528,193 +646,65 @@ // Upgrade guid is important to decide whether it is an upgrade of // installed app. I.e. we need it to be the same for // 2 different versions of app if possible - data.put("PRODUCT_GUID", productGUID.toString()); - data.put("PRODUCT_UPGRADE_GUID", + data.put("JpProductCode", productGUID.toString()); + data.put("JpProductUpgradeCode", UPGRADE_UUID.fetchFrom(params).toString()); - data.put("UPGRADE_BLOCK", getUpgradeBlock(params)); - data.put("APPLICATION_NAME", APP_NAME.fetchFrom(params)); - data.put("APPLICATION_DESCRIPTION", DESCRIPTION.fetchFrom(params)); - data.put("APPLICATION_VENDOR", VENDOR.fetchFrom(params)); - data.put("APPLICATION_VERSION", PRODUCT_VERSION.fetchFrom(params)); - - // WinAppBundler will add application folder again => step out - File imageRootDir = WIN_APP_IMAGE.fetchFrom(params); - File launcher = new File(imageRootDir, - WinAppBundler.getLauncherName(params)); + if (!UPGRADE_UUID.getIsDefaultValue()) { + data.put("JpAllowDowngrades", "yes"); + } - String launcherPath = relativePath(imageRootDir, launcher); - data.put("APPLICATION_LAUNCHER", launcherPath); - - String iconPath = launcherPath.replace(".exe", ".ico"); - - data.put("APPLICATION_ICON", iconPath); + if (CAN_USE_WIX36.fetchFrom(params)) { + data.put("JpWixVersion36OrNewer", "yes"); + } - data.put("REGISTRY_ROOT", getRegistryRoot(params)); + data.put("JpAppName", APP_NAME.fetchFrom(params)); + data.put("JpAppDescription", DESCRIPTION.fetchFrom(params)); + data.put("JpAppVendor", VENDOR.fetchFrom(params)); + data.put("JpAppVersion", PRODUCT_VERSION.fetchFrom(params)); - boolean canUseWix36Features = CAN_USE_WIX36.fetchFrom(params); - data.put("WIX36_ONLY_START", - canUseWix36Features ? "" : ""); + data.put("JpConfigDir", CONFIG_ROOT.fetchFrom(params).getAbsolutePath()); + + File imageRootDir = WIN_APP_IMAGE.fetchFrom(params); if (MSI_SYSTEM_WIDE.fetchFrom(params)) { - data.put("INSTALL_SCOPE", "perMachine"); - } else { - data.put("INSTALL_SCOPE", "perUser"); + data.put("JpIsSystemWide", "yes"); } - data.put("PLATFORM", "x64"); - data.put("WIN64", "yes"); - - data.put("UI_BLOCK", getUIBlock(params)); + if (LICENSE_FILE.fetchFrom(params) != null) { + data.put("JpLicenseRtf", LICENSE_FILE.fetchFrom(params)); + } - // Add CA to check install dir + // Copy CA dll to include with installer if (INSTALLDIR_CHOOSER.fetchFrom(params)) { - data.put("CA_BLOCK", CA_BLOCK); - data.put("INVALID_INSTALL_DIR_DLG_BLOCK", INVALID_INSTALL_DIR_DLG_BLOCK); - } else { - data.put("CA_BLOCK", ""); - data.put("INVALID_INSTALL_DIR_DLG_BLOCK", ""); + data.put("JpInstallDirChooser", "yes"); + String fname = "wixhelper.dll"; + try (InputStream is = getResourceAsStream(fname)) { + Files.copy(is, Paths.get( + CONFIG_ROOT.fetchFrom(params).getAbsolutePath(), fname)); + } } - List> addLaunchers = - ADD_LAUNCHERS.fetchFrom(params); - - StringBuilder addLauncherIcons = new StringBuilder(); - for (int i = 0; i < addLaunchers.size(); i++) { - Map sl = addLaunchers.get(i); - // - if (SHORTCUT_HINT.fetchFrom(sl) || MENU_HINT.fetchFrom(sl)) { - File addLauncher = new File(imageRootDir, - WinAppBundler.getLauncherName(sl)); - String addLauncherPath = - relativePath(imageRootDir, addLauncher); - String addLauncherIconPath = - addLauncherPath.replace(".exe", ".ico"); - - addLauncherIcons.append(" \r\n"); + // Copy l10n files. + for (String loc : Arrays.asList("en", "ja", "zh_CN")) { + String fname = "MsiInstallerStrings_" + loc + ".wxl"; + try (InputStream is = getResourceAsStream(fname)) { + Files.copy(is, Paths.get( + CONFIG_ROOT.fetchFrom(params).getAbsolutePath(), fname)); } } - data.put("ADD_LAUNCHER_ICONS", addLauncherIcons.toString()); - - String wxs = StandardBundlerParam.isRuntimeInstaller(params) ? - MSI_PROJECT_TEMPLATE_SERVER_JRE : MSI_PROJECT_TEMPLATE; - - try (Writer w = Files.newBufferedWriter( - getConfig_ProjectFile(params).toPath())) { - String content = preprocessTextResource( - getConfig_ProjectFile(params).getName(), - I18N.getString("resource.wix-config-file"), - wxs, data, VERBOSE.fetchFrom(params), - RESOURCE_DIR.fetchFrom(params)); - w.write(content); + try (InputStream is = getResourceAsStream("main.wxs")) { + Files.copy(is, Paths.get( + getConfig_ProjectFile(params).getAbsolutePath())); } - return true; + + return data; } private int id; private int compId; private final static String LAUNCHER_ID = "LauncherId"; - private static final String CA_BLOCK = - "\n" + - ""; - - private static final String INVALID_INSTALL_DIR_DLG_BLOCK = - "\n" + - "\n" + - "1\n" + - "\n" + - "\n" + - "1\n" + - "\n" + - "\n" + - "" + I18N.getString("message.install.dir.exist") + "\n" + - "\n" + - ""; - - /** - * Overrides the dialog sequence in built-in dialog set "WixUI_InstallDir" - * to exclude license dialog - */ - private static final String TWEAK_FOR_EXCLUDING_LICENSE = - " 1\n" - + " 1\n"; - - private static final String CHECK_INSTALL_DLG_CTRL = - " 1\n" - + " INSTALLDIR_VALID=\"0\"\n" - + " INSTALLDIR_VALID=\"1\"\n"; - - // Required upgrade element for installers which support major upgrade (when user - // specifies --win-upgrade-uuid). We will allow downgrades. - private static final String UPGRADE_BLOCK = - ""; - - private String getUpgradeBlock(Map params) { - if (UPGRADE_UUID.getIsDefaultValue()) { - return ""; - } else { - return UPGRADE_BLOCK; - } - } - - /** - * Creates UI element using WiX built-in dialog sets - * - WixUI_InstallDir/WixUI_Minimal. - * The dialog sets are the closest to what we want to implement. - * - * WixUI_Minimal for license dialog only - * WixUI_InstallDir for installdir dialog only or for both - * installdir/license dialogs - */ - private String getUIBlock(Map params) throws IOException { - String uiBlock = ""; // UI-less element - - // Copy CA dll to include with installer - if (INSTALLDIR_CHOOSER.fetchFrom(params)) { - File helper = new File(CONFIG_ROOT.fetchFrom(params), "wixhelper.dll"); - try (InputStream is_lib = getResourceAsStream("wixhelper.dll")) { - Files.copy(is_lib, helper.toPath()); - } - } - - if (INSTALLDIR_CHOOSER.fetchFrom(params)) { - boolean enableTweakForExcludingLicense = - (getLicenseFile(params) == null); - uiBlock = " \n" - + " \n" - + (enableTweakForExcludingLicense ? - TWEAK_FOR_EXCLUDING_LICENSE : "") - + CHECK_INSTALL_DLG_CTRL; - } else if (getLicenseFile(params) != null) { - uiBlock = " \n"; - } - - return uiBlock; - } - private void walkFileTree(Map params, File root, PrintStream out, String prefix) { List dirs = new ArrayList<>(); @@ -936,15 +926,7 @@ } } - String getRegistryRoot(Map params) { - if (MSI_SYSTEM_WIDE.fetchFrom(params)) { - return "HKLM"; - } else { - return "HKCU"; - } - } - - boolean prepareContentList(Map params) + void prepareContentList(Map params) throws FileNotFoundException { File f = new File( CONFIG_ROOT.fetchFrom(params), MSI_PROJECT_CONTENT_FILE); @@ -1024,14 +1006,13 @@ for (int j = 0; j < compId; j++) { out.println(" "); } - // component is defined in the template.wsx + // component is defined in the main.wsx out.println( " "); out.println(" "); out.println(""); } - return true; } private File getConfig_ProjectFile(Map params) { @@ -1039,38 +1020,21 @@ APP_NAME.fetchFrom(params) + ".wxs"); } - private String getLicenseFile(Map params) { - String licenseFile = LICENSE_FILE.fetchFrom(params); - if (licenseFile != null) { - File lfile = new File(licenseFile); - File destFile = new File(CONFIG_ROOT.fetchFrom(params), - lfile.getName()); - String filePath = destFile.getAbsolutePath(); - if (filePath.contains(" ")) { - return "\"" + filePath + "\""; - } else { - return filePath; - } - } - - return null; + private Map prepareWiXConfig( + Map params) throws IOException { + prepareContentList(params); + prepareIconsFile(params); + return prepareMainProjectFile(params); } - private boolean prepareWiXConfig( - Map params) throws IOException { - return prepareMainProjectFile(params) && prepareContentList(params); - - } - private final static String MSI_PROJECT_TEMPLATE = "template.wxs"; - private final static String MSI_PROJECT_TEMPLATE_SERVER_JRE = - "template.jre.wxs"; private final static String MSI_PROJECT_CONTENT_FILE = "bundle.wxi"; - private File buildMSI(Map params, File outdir) + private File buildMSI(Map params, + Map wixVars, File outdir) throws IOException { File tmpDir = new File(TEMP_ROOT.fetchFrom(params), "tmp"); File candleOut = new File( - tmpDir, APP_NAME.fetchFrom(params) +".wixobj"); + tmpDir, APP_NAME.fetchFrom(params) + ".wixobj"); File msiOut = new File( outdir, INSTALLER_FILE_NAME.fetchFrom(params) + ".msi"); @@ -1079,28 +1043,30 @@ msiOut.getParentFile().mkdirs(); - // run candle - ProcessBuilder pb = new ProcessBuilder( + List commandLine = new ArrayList<>(Arrays.asList( TOOL_CANDLE_EXECUTABLE.fetchFrom(params), "-nologo", getConfig_ProjectFile(params).getAbsolutePath(), "-ext", "WixUtilExtension", - "-out", candleOut.getAbsolutePath()); + "-out", candleOut.getAbsolutePath())); + for(Map.Entry wixVar: wixVars.entrySet()) { + String v = "-d" + wixVar.getKey() + "=" + wixVar.getValue(); + commandLine.add(v); + } + ProcessBuilder pb = new ProcessBuilder(commandLine); pb = pb.directory(WIN_APP_IMAGE.fetchFrom(params)); IOUtils.exec(pb); Log.verbose(MessageFormat.format(I18N.getString( "message.generating-msi"), msiOut.getAbsolutePath())); - boolean enableLicenseUI = (getLicenseFile(params) != null); + boolean enableLicenseUI = (LICENSE_FILE.fetchFrom(params) != null); boolean enableInstalldirUI = INSTALLDIR_CHOOSER.fetchFrom(params); - List commandLine = new ArrayList<>(); + commandLine = new ArrayList<>(); commandLine.add(TOOL_LIGHT_EXECUTABLE.fetchFrom(params)); - if (enableLicenseUI) { - commandLine.add("-dWixUILicenseRtf="+getLicenseFile(params)); - } + commandLine.add("-nologo"); commandLine.add("-spdb"); commandLine.add("-sice:60"); @@ -1110,9 +1076,13 @@ commandLine.add("WixUtilExtension"); if (enableLicenseUI || enableInstalldirUI) { commandLine.add("-ext"); - commandLine.add("WixUIExtension.dll"); + commandLine.add("WixUIExtension"); } + commandLine.add("-loc"); + commandLine.add(new File(CONFIG_ROOT.fetchFrom(params), I18N.getString( + "resource.wxl-file-name")).getAbsolutePath()); + // Only needed if we using CA dll, so Wix can find it if (enableInstalldirUI) { commandLine.add("-b"); diff -r 05e411fc4b77 -r a477b26bf888 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/MsiInstallerStrings_en.wxl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/MsiInstallerStrings_en.wxl Thu Jun 13 19:32:24 2019 -0400 @@ -0,0 +1,4 @@ + + + The folder [APPLICATIONFOLDER] already exist. Would you like to install to that folder anyway? + diff -r 05e411fc4b77 -r a477b26bf888 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/MsiInstallerStrings_ja.wxl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/MsiInstallerStrings_ja.wxl Thu Jun 13 19:32:24 2019 -0400 @@ -0,0 +1,4 @@ + + + The folder [APPLICATIONFOLDER] already exist. Would you like to install to that folder anyway? + diff -r 05e411fc4b77 -r a477b26bf888 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/MsiInstallerStrings_zh_CN.wxl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/MsiInstallerStrings_zh_CN.wxl Thu Jun 13 19:32:24 2019 -0400 @@ -0,0 +1,4 @@ + + + The folder [APPLICATIONFOLDER] already exist. Would you like to install to that folder anyway? + diff -r 05e411fc4b77 -r a477b26bf888 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties Thu Jun 13 19:04:29 2019 -0400 +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources.properties Thu Jun 13 19:32:24 2019 -0400 @@ -37,7 +37,7 @@ resource.inno-setup-project-file=Inno Setup project file resource.setup-icon=setup dialog icon resource.post-install-script=script to run after application image is populated -resource.wix-config-file=WiX config file +resource.wxl-file-name=MsiInstallerStrings_en.wxl error.parameters-null=Parameters map is null. error.parameters-null.advice=Pass in a non-null parameters map. @@ -82,6 +82,5 @@ message.generating-msi=Generating MSI: {0}. message.light-file-string=WiX light tool set to {0}. message.candle-file-string=WiX candle tool set to {0}. -message.install.dir.exist=The folder [APPLICATIONFOLDER] already exist. Whould you like to install to that folder anyway? message.invalid.install.dir=Warning: Invalid install directory {0}. Install directory should be a relative sub-path under the default installation location such as "Program Files". Defaulting to application name "{1}". diff -r 05e411fc4b77 -r a477b26bf888 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_ja.properties --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_ja.properties Thu Jun 13 19:04:29 2019 -0400 +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_ja.properties Thu Jun 13 19:32:24 2019 -0400 @@ -37,7 +37,7 @@ resource.inno-setup-project-file=Inno Setup project file resource.setup-icon=setup dialog icon resource.post-install-script=script to run after application image is populated -resource.wix-config-file=WiX config file +resource.wxl-file-name=MsiInstallerStrings_ja.wxl error.parameters-null=Parameters map is null. error.parameters-null.advice=Pass in a non-null parameters map. @@ -82,6 +82,5 @@ message.generating-msi=Generating MSI: {0}. message.light-file-string=WiX light tool set to {0}. message.candle-file-string=WiX candle tool set to {0}. -message.install.dir.exist=The folder [APPLICATIONFOLDER] already exist. Whould you like to install to that folder anyway? message.invalid.install.dir=Warning: Invalid install directory {0}. Install directory should be a relative sub-path under the default installation location such as "Program Files". Defaulting to application name "{1}". diff -r 05e411fc4b77 -r a477b26bf888 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_zh_CN.properties --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_zh_CN.properties Thu Jun 13 19:04:29 2019 -0400 +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/WinResources_zh_CN.properties Thu Jun 13 19:32:24 2019 -0400 @@ -37,7 +37,7 @@ resource.inno-setup-project-file=Inno Setup project file resource.setup-icon=setup dialog icon resource.post-install-script=script to run after application image is populated -resource.wix-config-file=WiX config file +resource.wxl-file-name=MsiInstallerStrings_zh_CN.wxl error.parameters-null=Parameters map is null. error.parameters-null.advice=Pass in a non-null parameters map. @@ -82,6 +82,5 @@ message.generating-msi=Generating MSI: {0}. message.light-file-string=WiX light tool set to {0}. message.candle-file-string=WiX candle tool set to {0}. -message.install.dir.exist=The folder [APPLICATIONFOLDER] already exist. Whould you like to install to that folder anyway? message.invalid.install.dir=Warning: Invalid install directory {0}. Install directory should be a relative sub-path under the default installation location such as "Program Files". Defaulting to application name "{1}". diff -r 05e411fc4b77 -r a477b26bf888 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/main.wxs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/main.wxs Thu Jun 13 19:32:24 2019 -0400 @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + 1 + + + !(loc.message.install.dir.exist) + + + + + + + + 1 + INSTALLDIR_VALID="0" + INSTALLDIR_VALID="1" + + + + 1 + 1 + + + + + + + + + + + + + + + + + + diff -r 05e411fc4b77 -r a477b26bf888 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.jre.wxs --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.jre.wxs Thu Jun 13 19:04:29 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - - - - - -UPGRADE_BLOCK - - - - - - - - - - WIX36_ONLY_START - - WIX36_ONLY_END - - - -UI_BLOCK - - diff -r 05e411fc4b77 -r a477b26bf888 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.wxs --- a/src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/template.wxs Thu Jun 13 19:04:29 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ - - - - - - UPGRADE_BLOCK - - - - - - - - - - WIX36_ONLY_START - - WIX36_ONLY_END - - - - CA_BLOCK - - INVALID_INSTALL_DIR_DLG_BLOCK - UI_BLOCK - - - - ADD_LAUNCHER_ICONS - - diff -r 05e411fc4b77 -r a477b26bf888 test/jdk/tools/jpackage/createinstaller/windows/base/JPackageCreateInstallerRuntimeBase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/tools/jpackage/createinstaller/windows/base/JPackageCreateInstallerRuntimeBase.java Thu Jun 13 19:32:24 2019 -0400 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class JPackageCreateInstallerRuntimeBase { + + private static String TEST_NAME; + private static String EXT; + private static String OUTPUT; + private static String[] CMD; + + private static void copyResults() throws Exception { + List files = new ArrayList<>(); + files.add(OUTPUT); + JPackageInstallerHelper.copyTestResults(files); + } + + private static void testCreateInstaller() throws Exception { + JPackageHelper.executeCLI(true, CMD); + JPackageInstallerHelper.validateOutput(OUTPUT); + copyResults(); + } + + private static void verifyInstall() throws Exception { + // NOP by design. + } + + private static void verifyUnInstall() throws Exception { + String folderPath = JPackagePath.getWinInstallFolder(TEST_NAME); + File folder = new File(folderPath); + if (folder.exists()) { + throw new AssertionError("Error: " + folder.getAbsolutePath() + " exist"); + } + } + + private static void init(String name, String ext) { + TEST_NAME = name; + EXT = ext; + OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT; + CMD = new String[]{ + "create-installer", + "--installer-type", EXT, + "--output", "output", + "--name", TEST_NAME, + "--runtime-image", System.getProperty("java.home")}; + } + + public static void run(String name, String ext) throws Exception { + init(name, ext); + + if (JPackageInstallerHelper.isVerifyInstall()) { + verifyInstall(); + } else if (JPackageInstallerHelper.isVerifyUnInstall()) { + verifyUnInstall(); + } else { + testCreateInstaller(); + } + } +} diff -r 05e411fc4b77 -r a477b26bf888 test/jdk/tools/jpackage/createinstaller/windows/exe/JPackageCreateInstallerRuntimeTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/tools/jpackage/createinstaller/windows/exe/JPackageCreateInstallerRuntimeTest.java Thu Jun 13 19:32:24 2019 -0400 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.invoke.MethodHandles; + +/* + * @test + * @summary jpackage create installer test + * @library ../../../helpers + * @library ../base + * @build JPackageHelper + * @build JPackagePath + * @build JPackageInstallerHelper + * @build JPackageCreateInstallerRuntimeBase + * @requires (os.family == "windows") + * @modules jdk.jpackage + * @ignore + * @run main/othervm -Xmx512m JPackageCreateInstallerRuntimeTest + */ +public class JPackageCreateInstallerRuntimeTest { + + private static final String TEST_NAME = MethodHandles.lookup().lookupClass().getName(); + private static final String EXT = "exe"; + + public static void main(String[] args) throws Exception { + JPackageCreateInstallerRuntimeBase.run(TEST_NAME, EXT); + } +} diff -r 05e411fc4b77 -r a477b26bf888 test/jdk/tools/jpackage/createinstaller/windows/exe/install.bat --- a/test/jdk/tools/jpackage/createinstaller/windows/exe/install.bat Thu Jun 13 19:04:29 2019 -0400 +++ b/test/jdk/tools/jpackage/createinstaller/windows/exe/install.bat Thu Jun 13 19:32:24 2019 -0400 @@ -13,4 +13,5 @@ JPackageCreateInstallerWinUpgradeUUIDTest-2.0.exe JPackageCreateInstallerInstallDirTest-1.0.exe JPackageCreateInstallerFileAssociationsInstallDirTest-1.0.exe +JPackageCreateInstallerRuntimeTest-1.0.exe PAUSE diff -r 05e411fc4b77 -r a477b26bf888 test/jdk/tools/jpackage/createinstaller/windows/exe/uninstall.bat --- a/test/jdk/tools/jpackage/createinstaller/windows/exe/uninstall.bat Thu Jun 13 19:04:29 2019 -0400 +++ b/test/jdk/tools/jpackage/createinstaller/windows/exe/uninstall.bat Thu Jun 13 19:32:24 2019 -0400 @@ -10,4 +10,5 @@ "%ProgramFiles%\JPackageCreateInstallerWinUpgradeUUIDTest\unins000.exe" "%ProgramFiles%\TestVendor\JPackageCreateInstallerInstallDirTestDir\unins000.exe" "%ProgramFiles%\TestVendor\JPackageCreateInstallerFileAssociationsInstallDirTestDir\unins000.exe" +"%ProgramFiles%\JPackageCreateInstallerRuntimeTest\unins000.exe" PAUSE \ No newline at end of file diff -r 05e411fc4b77 -r a477b26bf888 test/jdk/tools/jpackage/createinstaller/windows/msi/JPackageCreateInstallerRuntimeTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/tools/jpackage/createinstaller/windows/msi/JPackageCreateInstallerRuntimeTest.java Thu Jun 13 19:32:24 2019 -0400 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.invoke.MethodHandles; + +/* + * @test + * @summary jpackage create installer test + * @library ../../../helpers + * @library ../base + * @build JPackageHelper + * @build JPackagePath + * @build JPackageInstallerHelper + * @build JPackageCreateInstallerRuntimeBase + * @requires (os.family == "windows") + * @modules jdk.jpackage + * @ignore + * @run main/othervm -Xmx512m JPackageCreateInstallerRuntimeTest + */ +public class JPackageCreateInstallerRuntimeTest { + + private static final String TEST_NAME = MethodHandles.lookup().lookupClass().getName(); + private static final String EXT = "msi"; + + public static void main(String[] args) throws Exception { + JPackageCreateInstallerRuntimeBase.run(TEST_NAME, EXT); + } +} diff -r 05e411fc4b77 -r a477b26bf888 test/jdk/tools/jpackage/createinstaller/windows/msi/install.bat --- a/test/jdk/tools/jpackage/createinstaller/windows/msi/install.bat Thu Jun 13 19:04:29 2019 -0400 +++ b/test/jdk/tools/jpackage/createinstaller/windows/msi/install.bat Thu Jun 13 19:32:24 2019 -0400 @@ -13,4 +13,5 @@ JPackageCreateInstallerWinUpgradeUUIDTest-2.0.msi JPackageCreateInstallerInstallDirTest-1.0.msi JPackageCreateInstallerFileAssociationsInstallDirTest-1.0.msi +JPackageCreateInstallerRuntimeTest-1.0.msi PAUSE diff -r 05e411fc4b77 -r a477b26bf888 test/jdk/tools/jpackage/createinstaller/windows/msi/uninstall.bat --- a/test/jdk/tools/jpackage/createinstaller/windows/msi/uninstall.bat Thu Jun 13 19:04:29 2019 -0400 +++ b/test/jdk/tools/jpackage/createinstaller/windows/msi/uninstall.bat Thu Jun 13 19:32:24 2019 -0400 @@ -10,4 +10,5 @@ MSIEXEC /uninstall JPackageCreateInstallerWinUpgradeUUIDTest-2.0.msi MSIEXEC /uninstall JPackageCreateInstallerInstallDirTest-1.0.msi MSIEXEC /uninstall JPackageCreateInstallerFileAssociationsInstallDirTest-1.0.msi +MSIEXEC /uninstall JPackageCreateInstallerRuntimeTest-1.0.msi PAUSE \ No newline at end of file