< prev index next >
src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WinMsiBundler.java
Print this page
*** 242,266 ****
return null;
}
}
@Override
! public boolean validate(Map<String, ? super Object> p)
throws UnsupportedPlatformException, ConfigException {
try {
! if (p == null) throw new ConfigException(
I18N.getString("error.parameters-null"),
I18N.getString("error.parameters-null.advice"));
// run basic validation to ensure requirements are met
// we are not interested in return code, only possible exception
! APP_BUNDLER.fetchFrom(p).validate(p);
String candleVersion =
! findToolVersion(TOOL_CANDLE_EXECUTABLE.fetchFrom(p));
String lightVersion =
! findToolVersion(TOOL_LIGHT_EXECUTABLE.fetchFrom(p));
// WiX 3.0+ is required
String minVersion = "3.0";
boolean bad = false;
--- 242,266 ----
return null;
}
}
@Override
! public boolean validate(Map<String, ? super Object> params)
throws UnsupportedPlatformException, ConfigException {
try {
! if (params == null) throw new ConfigException(
I18N.getString("error.parameters-null"),
I18N.getString("error.parameters-null.advice"));
// run basic validation to ensure requirements are met
// we are not interested in return code, only possible exception
! APP_BUNDLER.fetchFrom(params).validate(params);
String candleVersion =
! findToolVersion(TOOL_CANDLE_EXECUTABLE.fetchFrom(params));
String lightVersion =
! findToolVersion(TOOL_LIGHT_EXECUTABLE.fetchFrom(params));
// WiX 3.0+ is required
String minVersion = "3.0";
boolean bad = false;
*** 283,298 ****
I18N.getString("error.no-wix-tools.advice"));
}
if (!VersionExtractor.isLessThan(lightVersion, "3.6")) {
Log.verbose(I18N.getString("message.use-wix36-features"));
! p.put(CAN_USE_WIX36.getID(), Boolean.TRUE);
}
/********* validate bundle parameters *************/
! String version = PRODUCT_VERSION.fetchFrom(p);
if (!isVersionStringValid(version)) {
throw new ConfigException(
MessageFormat.format(I18N.getString(
"error.version-string-wrong-format"), version),
MessageFormat.format(I18N.getString(
--- 283,298 ----
I18N.getString("error.no-wix-tools.advice"));
}
if (!VersionExtractor.isLessThan(lightVersion, "3.6")) {
Log.verbose(I18N.getString("message.use-wix36-features"));
! params.put(CAN_USE_WIX36.getID(), Boolean.TRUE);
}
/********* validate bundle parameters *************/
! String version = PRODUCT_VERSION.fetchFrom(params);
if (!isVersionStringValid(version)) {
throw new ConfigException(
MessageFormat.format(I18N.getString(
"error.version-string-wrong-format"), version),
MessageFormat.format(I18N.getString(
*** 300,310 ****
PRODUCT_VERSION.getID()));
}
// only one mime type per association, at least one file extension
List<Map<String, ? super Object>> associations =
! FILE_ASSOCIATIONS.fetchFrom(p);
if (associations != null) {
for (int i = 0; i < associations.size(); i++) {
Map<String, ? super Object> assoc = associations.get(i);
List<String> mimes = FA_CONTENT_TYPE.fetchFrom(assoc);
if (mimes.size() > 1) {
--- 300,310 ----
PRODUCT_VERSION.getID()));
}
// only one mime type per association, at least one file extension
List<Map<String, ? super Object>> associations =
! FILE_ASSOCIATIONS.fetchFrom(params);
if (associations != null) {
for (int i = 0; i < associations.size(); i++) {
Map<String, ? super Object> assoc = associations.get(i);
List<String> mimes = FA_CONTENT_TYPE.fetchFrom(assoc);
if (mimes.size() > 1) {
*** 376,415 ****
}
return true;
}
! private boolean prepareProto(Map<String, ? super Object> p)
throws PackagerException, IOException {
! File appImage = StandardBundlerParam.getPredefinedAppImage(p);
File appDir = null;
// we either have an application image or need to build one
if (appImage != null) {
! appDir = new File(
! MSI_IMAGE_DIR.fetchFrom(p), APP_NAME.fetchFrom(p));
// copy everything from appImage dir into appDir/name
IOUtils.copyRecursive(appImage.toPath(), appDir.toPath());
} else {
! appDir = APP_BUNDLER.fetchFrom(p).doBundle(p,
! MSI_IMAGE_DIR.fetchFrom(p), true);
}
! p.put(WIN_APP_IMAGE.getID(), appDir);
! String licenseFile = LICENSE_FILE.fetchFrom(p);
if (licenseFile != null) {
// need to copy license file to the working directory and convert to rtf if needed
File lfile = new File(licenseFile);
! File destFile = new File(CONFIG_ROOT.fetchFrom(p), lfile.getName());
IOUtils.copyFile(lfile, destFile);
ensureByMutationFileIsRTF(destFile);
}
// copy file association icons
List<Map<String, ? super Object>> fileAssociations =
! FILE_ASSOCIATIONS.fetchFrom(p);
for (Map<String, ? super Object> fa : fileAssociations) {
File icon = FA_ICON.fetchFrom(fa); // TODO FA_ICON_ICO
if (icon == null) {
continue;
}
--- 376,416 ----
}
return true;
}
! private boolean prepareProto(Map<String, ? super Object> params)
throws PackagerException, IOException {
! File appImage = StandardBundlerParam.getPredefinedAppImage(params);
File appDir = null;
// we either have an application image or need to build one
if (appImage != null) {
! appDir = new File(MSI_IMAGE_DIR.fetchFrom(params),
! APP_NAME.fetchFrom(params));
// copy everything from appImage dir into appDir/name
IOUtils.copyRecursive(appImage.toPath(), appDir.toPath());
} else {
! appDir = APP_BUNDLER.fetchFrom(params).doBundle(params,
! MSI_IMAGE_DIR.fetchFrom(params), true);
}
! params.put(WIN_APP_IMAGE.getID(), appDir);
! String licenseFile = LICENSE_FILE.fetchFrom(params);
if (licenseFile != null) {
// need to copy license file to the working directory and convert to rtf if needed
File lfile = new File(licenseFile);
! File destFile = new File(CONFIG_ROOT.fetchFrom(params),
! lfile.getName());
IOUtils.copyFile(lfile, destFile);
ensureByMutationFileIsRTF(destFile);
}
// copy file association icons
List<Map<String, ? super Object>> fileAssociations =
! FILE_ASSOCIATIONS.fetchFrom(params);
for (Map<String, ? super Object> fa : fileAssociations) {
File icon = FA_ICON.fetchFrom(fa); // TODO FA_ICON_ICO
if (icon == null) {
continue;
}
*** 426,436 ****
}
return appDir != null;
}
! public File bundle(Map<String, ? super Object> p, File outdir)
throws PackagerException {
if (!outdir.isDirectory() && !outdir.mkdirs()) {
throw new PackagerException("error.cannot-create-output-dir",
outdir.getAbsolutePath());
}
--- 427,437 ----
}
return appDir != null;
}
! public File bundle(Map<String, ? super Object> params, File outdir)
throws PackagerException {
if (!outdir.isDirectory() && !outdir.mkdirs()) {
throw new PackagerException("error.cannot-create-output-dir",
outdir.getAbsolutePath());
}
*** 438,473 ****
throw new PackagerException("error.cannot-write-to-output-dir",
outdir.getAbsolutePath());
}
// validate we have valid tools before continuing
! String light = TOOL_LIGHT_EXECUTABLE.fetchFrom(p);
! String candle = TOOL_CANDLE_EXECUTABLE.fetchFrom(p);
if (light == null || !new File(light).isFile() ||
candle == null || !new File(candle).isFile()) {
Log.verbose(MessageFormat.format(
I18N.getString("message.light-file-string"), light));
Log.verbose(MessageFormat.format(
I18N.getString("message.candle-file-string"), candle));
throw new PackagerException("error.no-wix-tools");
}
! File imageDir = MSI_IMAGE_DIR.fetchFrom(p);
try {
imageDir.mkdirs();
! boolean menuShortcut = MENU_HINT.fetchFrom(p);
! boolean desktopShortcut = SHORTCUT_HINT.fetchFrom(p);
if (!menuShortcut && !desktopShortcut) {
// both can not be false - user will not find the app
Log.verbose(I18N.getString("message.one-shortcut-required"));
! p.put(MENU_HINT.getID(), true);
}
! if (prepareProto(p) && prepareWiXConfig(p)
! && prepareBasicProjectConfig(p)) {
! File configScriptSrc = getConfig_Script(p);
if (configScriptSrc.exists()) {
// we need to be running post script in the image folder
// NOTE: Would it be better to generate it to the image
// folder and save only if "verbose" is requested?
--- 439,474 ----
throw new PackagerException("error.cannot-write-to-output-dir",
outdir.getAbsolutePath());
}
// validate we have valid tools before continuing
! String light = TOOL_LIGHT_EXECUTABLE.fetchFrom(params);
! String candle = TOOL_CANDLE_EXECUTABLE.fetchFrom(params);
if (light == null || !new File(light).isFile() ||
candle == null || !new File(candle).isFile()) {
Log.verbose(MessageFormat.format(
I18N.getString("message.light-file-string"), light));
Log.verbose(MessageFormat.format(
I18N.getString("message.candle-file-string"), candle));
throw new PackagerException("error.no-wix-tools");
}
! File imageDir = MSI_IMAGE_DIR.fetchFrom(params);
try {
imageDir.mkdirs();
! boolean menuShortcut = MENU_HINT.fetchFrom(params);
! boolean desktopShortcut = SHORTCUT_HINT.fetchFrom(params);
if (!menuShortcut && !desktopShortcut) {
// both can not be false - user will not find the app
Log.verbose(I18N.getString("message.one-shortcut-required"));
! params.put(MENU_HINT.getID(), true);
}
! if (prepareProto(params) && prepareWiXConfig(params)
! && prepareBasicProjectConfig(params)) {
! File configScriptSrc = getConfig_Script(params);
if (configScriptSrc.exists()) {
// we need to be running post script in the image folder
// NOTE: Would it be better to generate it to the image
// folder and save only if "verbose" is requested?
*** 479,489 ****
Log.verbose(MessageFormat.format(
I18N.getString("message.running-wsh-script"),
configScript.getAbsolutePath()));
IOUtils.run("wscript", configScript);
}
! return buildMSI(p, outdir);
}
return null;
} catch (IOException ex) {
Log.verbose(ex);
throw new PackagerException(ex);
--- 480,490 ----
Log.verbose(MessageFormat.format(
I18N.getString("message.running-wsh-script"),
configScript.getAbsolutePath()));
IOUtils.run("wscript", configScript);
}
! return buildMSI(params, outdir);
}
return null;
} catch (IOException ex) {
Log.verbose(ex);
throw new PackagerException(ex);
*** 1036,1050 ****
private File getConfig_ProjectFile(Map<String, ? super Object> params) {
return new File(CONFIG_ROOT.fetchFrom(params),
APP_NAME.fetchFrom(params) + ".wxs");
}
! private String getLicenseFile(Map<String, ? super Object> p) {
! String licenseFile = LICENSE_FILE.fetchFrom(p);
if (licenseFile != null) {
File lfile = new File(licenseFile);
! File destFile = new File(CONFIG_ROOT.fetchFrom(p), lfile.getName());
String filePath = destFile.getAbsolutePath();
if (filePath.contains(" ")) {
return "\"" + filePath + "\"";
} else {
return filePath;
--- 1037,1052 ----
private File getConfig_ProjectFile(Map<String, ? super Object> params) {
return new File(CONFIG_ROOT.fetchFrom(params),
APP_NAME.fetchFrom(params) + ".wxs");
}
! private String getLicenseFile(Map<String, ? super Object> 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;
< prev index next >