Skip to content

8319457: Update jpackage to support WiX v4 and v5 on Windows #19318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1bd04b4
Can detect Wix v4 and v5.
alexeysemenyukoracle May 16, 2024
fb0e2ee
SimplePackageTest is a pass with manual "wix convert" on main.wxs, ov…
alexeysemenyukoracle May 16, 2024
f78ebef
SimplePackageTest is a pass without manual tweaks
alexeysemenyukoracle May 17, 2024
1bdfd64
WiX4 doesn't accept localization IDs with dots (.). Rename them
alexeysemenyukoracle May 18, 2024
e5ab4d9
Use the same xslt for all types of wix3 sources to be converted
alexeysemenyukoracle May 18, 2024
9184222
Fix Wix4 shortcut xml element output
alexeysemenyukoracle May 18, 2024
e473865
Reuse WixSourceConverter#ResourceGroup
alexeysemenyukoracle May 18, 2024
2186169
Fix issue caused by failed test exercising --windows-per-user-install…
alexeysemenyukoracle May 18, 2024
e67d1c3
Major tests pass with WiX4
alexeysemenyukoracle May 18, 2024
d90e042
Log WiX4 post-processing of unpacked msi
alexeysemenyukoracle May 18, 2024
e8f43ee
DottedVersion refactored. Old parsing code used "==" to test equality…
alexeysemenyukoracle May 19, 2024
aa0200c
Detect WiX3 full set of tools (candle.exe and light.exe) or WiX4 wix.…
alexeysemenyukoracle May 19, 2024
9fcc668
Add missing "--add-opens jdk.jpackage/jdk.jpackage.internal=ALL-UNNAM…
alexeysemenyukoracle May 19, 2024
1b35d20
Fix InstallDirTest.testCommon test failure
alexeysemenyukoracle May 19, 2024
6b510e1
WinL10nTest is a pass
alexeysemenyukoracle May 20, 2024
8cb8fbb
Fix "warning WIX5436: Using DirectoryRef to reference the standard di…
alexeysemenyukoracle May 21, 2024
51b4c0c
Got rid of Wix36 WiX toolset type
alexeysemenyukoracle May 21, 2024
4f2f8e4
Merge branch 'master' into JDK-8319457
alexeysemenyukoracle May 29, 2024
f846a43
Fix issue with running jtreg tests when wix.exe is not available in t…
alexeysemenyukoracle May 30, 2024
74407c8
Don't suppress jpackage output when it is detecting what packaging to…
alexeysemenyukoracle May 30, 2024
4e19e8b
Merge branch 'master' into JDK-8319457
alexeysemenyukoracle May 31, 2024
00d7cc6
Rollback unneeded change
alexeysemenyukoracle Jun 3, 2024
5fded0b
Revert "Rollback unneeded change"
alexeysemenyukoracle Jun 3, 2024
3302aa0
Ensure WiX source converter works with the default JDK XSLT processor…
alexeysemenyukoracle Jun 3, 2024
5e97c4d
Support the use of custom wix source converter
alexeysemenyukoracle Jun 3, 2024
fbb9f41
Revert "Revert "Rollback unneeded change""
alexeysemenyukoracle Jun 3, 2024
3690488
Merge branch 'master' into JDK-8319457
alexeysemenyukoracle Jun 4, 2024
99aac32
EOLs restored
alexeysemenyukoracle Jun 4, 2024
782d121
EOLs restored
alexeysemenyukoracle Jun 4, 2024
cbf7d31
Fix issue with overwriting custom l10n file in the resource directory…
alexeysemenyukoracle Jun 4, 2024
af8fb68
WixSourceConverter#applyTo should do what OverridableResource#saveToF…
alexeysemenyukoracle Jun 4, 2024
899470e
Unify "switch(wixVersion) ..." expressions. Always throw IllegalArgum…
alexeysemenyukoracle Jun 6, 2024
d446973
Add WiX v5 to "error.no-wix-tools"
alexeysemenyukoracle Jun 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion make/modules/jdk.jpackage/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ DISABLED_WARNINGS_java += dangling-doc-comments

COPY += .gif .png .txt .spec .script .prerm .preinst \
.postrm .postinst .list .sh .desktop .copyright .control .plist .template \
.icns .scpt .wxs .wxl .wxi .ico .bmp .tiff .service
.icns .scpt .wxs .wxl .wxi .ico .bmp .tiff .service .xsl

CLEAN += .properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, 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
Expand Down Expand Up @@ -67,6 +67,7 @@
import static jdk.jpackage.internal.StandardBundlerParam.TEMP_ROOT;
import static jdk.jpackage.internal.StandardBundlerParam.VENDOR;
import static jdk.jpackage.internal.StandardBundlerParam.VERSION;
import jdk.jpackage.internal.WixToolset.WixToolsetType;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
Expand Down Expand Up @@ -253,7 +254,7 @@ public String getBundleType() {
public boolean supported(boolean platformInstaller) {
try {
if (wixToolset == null) {
wixToolset = WixTool.toolset();
wixToolset = WixTool.createToolset();
}
return true;
} catch (ConfigException ce) {
Expand Down Expand Up @@ -300,7 +301,7 @@ public boolean validate(Map<String, ? super Object> params)
appImageBundler.validate(params);

if (wixToolset == null) {
wixToolset = WixTool.toolset();
wixToolset = WixTool.createToolset();
}

try {
Expand All @@ -309,16 +310,17 @@ public boolean validate(Map<String, ? super Object> params)
throw new ConfigException(ex);
}

for (var toolInfo: wixToolset.values()) {
for (var tool : wixToolset.getType().getTools()) {
Log.verbose(MessageFormat.format(I18N.getString(
"message.tool-version"), toolInfo.path.getFileName(),
toolInfo.version));
"message.tool-version"), wixToolset.getToolPath(tool).
getFileName(), wixToolset.getVersion()));
}

wixFragments.forEach(wixFragment -> wixFragment.setWixVersion(
wixToolset.get(WixTool.Light).version));
wixFragments.forEach(wixFragment -> wixFragment.setWixVersion(wixToolset.getVersion(),
wixToolset.getType()));

wixFragments.get(0).logWixFeatures();
wixFragments.stream().map(WixFragmentBuilder::getLoggableWixFeatures).flatMap(
List::stream).distinct().toList().forEach(Log::verbose);

/********* validate bundle parameters *************/

Expand Down Expand Up @@ -512,22 +514,6 @@ private Map<String, String> prepareMainProjectFile(
data.put("JpIsSystemWide", "yes");
}

// Copy standard l10n files.
for (String loc : Arrays.asList("de", "en", "ja", "zh_CN")) {
String fname = "MsiInstallerStrings_" + loc + ".wxl";
createResource(fname, params)
.setCategory(I18N.getString("resource.wxl-file"))
.saveToFile(configDir.resolve(fname));
}

createResource("main.wxs", params)
.setCategory(I18N.getString("resource.main-wix-file"))
.saveToFile(configDir.resolve("main.wxs"));

createResource("overrides.wxi", params)
.setCategory(I18N.getString("resource.overrides-wix-file"))
.saveToFile(configDir.resolve("overrides.wxi"));

return data;
}

Expand All @@ -542,13 +528,11 @@ private Path buildMSI(Map<String, ? super Object> params,
.toString()));

WixPipeline wixPipeline = new WixPipeline()
.setToolset(wixToolset.entrySet().stream().collect(
Collectors.toMap(
entry -> entry.getKey(),
entry -> entry.getValue().path)))
.setWixObjDir(TEMP_ROOT.fetchFrom(params).resolve("wixobj"))
.setWorkDir(WIN_APP_IMAGE.fetchFrom(params))
.addSource(CONFIG_ROOT.fetchFrom(params).resolve("main.wxs"), wixVars);
.setToolset(wixToolset)
.setWixObjDir(TEMP_ROOT.fetchFrom(params).resolve("wixobj"))
.setWorkDir(WIN_APP_IMAGE.fetchFrom(params))
.addSource(CONFIG_ROOT.fetchFrom(params).resolve("main.wxs"),
wixVars);

for (var wixFragment : wixFragments) {
wixFragment.configureWixPipeline(wixPipeline);
Expand All @@ -557,16 +541,41 @@ private Path buildMSI(Map<String, ? super Object> params,
Log.verbose(MessageFormat.format(I18N.getString(
"message.generating-msi"), msiOut.toAbsolutePath().toString()));

wixPipeline.addLightOptions("-sice:ICE27");
switch (wixToolset.getType()) {
case Wix3 -> {
wixPipeline.addLightOptions("-sice:ICE27");

if (!MSI_SYSTEM_WIDE.fetchFrom(params)) {
wixPipeline.addLightOptions("-sice:ICE91");
if (!MSI_SYSTEM_WIDE.fetchFrom(params)) {
wixPipeline.addLightOptions("-sice:ICE91");
}
}
}

final Path configDir = CONFIG_ROOT.fetchFrom(params);

var primaryWxlFiles = Stream.of("de", "en", "ja", "zh_CN").map(loc -> {
return configDir.resolve("MsiInstallerStrings_" + loc + ".wxl");
}).toList();

var wixResources = new WixSourceConverter.ResourceGroup(wixToolset.getType());

// Copy standard l10n files.
for (var path : primaryWxlFiles) {
var name = path.getFileName().toString();
wixResources.addResource(createResource(name, params).setPublicName(name).setCategory(
I18N.getString("resource.wxl-file")), path);
}

wixResources.addResource(createResource("main.wxs", params).setPublicName("main.wxs").
setCategory(I18N.getString("resource.main-wix-file")), configDir.resolve("main.wxs"));

wixResources.addResource(createResource("overrides.wxi", params).setPublicName(
"overrides.wxi").setCategory(I18N.getString("resource.overrides-wix-file")),
configDir.resolve("overrides.wxi"));

// Filter out custom l10n files that were already used to
// override primary l10n files. Ignore case filename comparison,
// both lists are expected to be short.
List<Path> primaryWxlFiles = getWxlFilesFromDir(params, CONFIG_ROOT);
List<Path> customWxlFiles = getWxlFilesFromDir(params, RESOURCE_DIR).stream()
.filter(custom -> primaryWxlFiles.stream().noneMatch(primary ->
primary.getFileName().toString().equalsIgnoreCase(
Expand All @@ -577,6 +586,17 @@ private Path buildMSI(Map<String, ? super Object> params,
custom.getFileName().toString())))
.toList();

// Copy custom l10n files.
for (var path : customWxlFiles) {
var name = path.getFileName().toString();
wixResources.addResource(createResource(name, params).setPublicName(name).
setSourceOrder(OverridableResource.Source.ResourceDir).setCategory(I18N.
getString("resource.wxl-file")), configDir.resolve(name));
}

// Save all WiX resources into config dir.
wixResources.saveResources();

// All l10n files are supplied to WiX with "-loc", but only
// Cultures from custom files and a single primary Culture are
// included into "-cultures" list
Expand All @@ -586,6 +606,7 @@ private Path buildMSI(Map<String, ? super Object> params,

List<String> cultures = new ArrayList<>();
for (var wxl : customWxlFiles) {
wxl = configDir.resolve(wxl.getFileName());
wixPipeline.addLightOptions("-loc", wxl.toAbsolutePath().normalize().toString());
cultures.add(getCultureFromWxlFile(wxl));
}
Expand All @@ -598,8 +619,17 @@ private Path buildMSI(Map<String, ? super Object> params,
// Build ordered list of unique cultures.
Set<String> uniqueCultures = new LinkedHashSet<>();
uniqueCultures.addAll(cultures);
wixPipeline.addLightOptions(uniqueCultures.stream().collect(
Collectors.joining(";", "-cultures:", "")));
switch (wixToolset.getType()) {
case Wix4 -> {
uniqueCultures.forEach(culture -> {
wixPipeline.addLightOptions("-culture", culture);
});
}
case Wix3 -> {
wixPipeline.addLightOptions(uniqueCultures.stream().collect(Collectors.joining(";",
"-cultures:", "")));
}
}

wixPipeline.buildMsi(msiOut.toAbsolutePath());

Expand Down Expand Up @@ -751,7 +781,7 @@ private static OverridableResource initServiceInstallerResource(
}

private Path installerIcon;
private Map<WixTool, WixTool.ToolInfo> wixToolset;
private WixToolset wixToolset;
private AppImageBundler appImageBundler;
private final List<WixFragmentBuilder> wixFragments;
}
Loading