Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,11 @@ private Map<String, String> prepareMainProjectFile(
}

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

createResource("main.wxs", params)
Expand Down Expand Up @@ -563,16 +563,36 @@ private Path buildMSI(Map<String, ? super Object> params,
wixPipeline.addLightOptions("-sice:ICE91");
}

final Path primaryWxlFile = CONFIG_ROOT.fetchFrom(params).resolve(
I18N.getString("resource.wxl-file-name")).toAbsolutePath();

wixPipeline.addLightOptions("-loc", primaryWxlFile.toString());
// 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(
custom.getFileName().toString())))
.peek(custom -> Log.verbose(MessageFormat.format(
I18N.getString("message.using-custom-resource"),
String.format("[%s]", I18N.getString("resource.wxl-file")),
custom.getFileName().toString())))
.toList();

// 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
for (var wxl : primaryWxlFiles) {
wixPipeline.addLightOptions("-loc", wxl.toAbsolutePath().normalize().toString());
}

List<String> cultures = new ArrayList<>();
for (var wxl : getCustomWxlFiles(params)) {
wixPipeline.addLightOptions("-loc", wxl.toAbsolutePath().toString());
for (var wxl : customWxlFiles) {
wixPipeline.addLightOptions("-loc", wxl.toAbsolutePath().normalize().toString());
cultures.add(getCultureFromWxlFile(wxl));
}

// Append a primary culture bases on runtime locale.
final Path primaryWxlFile = CONFIG_ROOT.fetchFrom(params).resolve(
I18N.getString("resource.wxl-file-name"));
cultures.add(getCultureFromWxlFile(primaryWxlFile));

// Build ordered list of unique cultures.
Expand All @@ -586,18 +606,18 @@ private Path buildMSI(Map<String, ? super Object> params,
return msiOut;
}

private static List<Path> getCustomWxlFiles(Map<String, ? super Object> params)
throws IOException {
Path resourceDir = RESOURCE_DIR.fetchFrom(params);
if (resourceDir == null) {
private static List<Path> getWxlFilesFromDir(Map<String, ? super Object> params,
StandardBundlerParam<Path> pathParam) throws IOException {
Path dir = pathParam.fetchFrom(params);
if (dir == null) {
return Collections.emptyList();
}

final String glob = "glob:**/*.wxl";
final PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher(
glob);

try (var walk = Files.walk(resourceDir, 1)) {
try (var walk = Files.walk(dir, 1)) {
return walk
.filter(Files::isReadable)
.filter(pathMatcher::matches)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version = '1.0' encoding = 'utf-8'?>
<WixLocalization Culture="de" xmlns="http://schemas.microsoft.com/wix/2006/localization" Codepage="1252">
<WixLocalization Culture="de-de" xmlns="http://schemas.microsoft.com/wix/2006/localization" Codepage="1252">
<String Id="message.install.dir.exist">Der Ordner [INSTALLDIR] ist bereits vorhanden. Möchten Sie diesen Ordner trotzdem installieren?</String>
<String Id="MainFeatureTitle">Hauptfeature</String>
<String Id="DowngradeErrorMessage">Eine höhere Version von [ProductName] ist bereits installiert. Downgrades sind deaktiviert. Setup wird jetzt beendet.</String>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version = '1.0' encoding = 'utf-8'?>
<WixLocalization Culture="ja" xmlns="http://schemas.microsoft.com/wix/2006/localization" Codepage="932">
<WixLocalization Culture="ja-jp" xmlns="http://schemas.microsoft.com/wix/2006/localization" Codepage="932">
<String Id="message.install.dir.exist">フォルダ[INSTALLDIR]はすでに存在します。そのフォルダにインストールしますか?</String>
<String Id="MainFeatureTitle">主な機能</String>
<String Id="DowngradeErrorMessage">[ProductName]のより上位のバージョンがすでにインストールされています。ダウングレードは無効です。セットアップを終了します。</String>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version = '1.0' encoding = 'utf-8'?>
<WixLocalization Culture="zh-CN" xmlns="http://schemas.microsoft.com/wix/2006/localization" Codepage="936">
<WixLocalization Culture="zh-cn" xmlns="http://schemas.microsoft.com/wix/2006/localization" Codepage="936">
<String Id="message.install.dir.exist">文件夹 [INSTALLDIR] 已存在。是否仍要安装到该文件夹?</String>
<String Id="MainFeatureTitle">主要功能</String>
<String Id="DowngradeErrorMessage">已安装更高版本的 [ProductName]。降级已禁用。现在将退出安装。</String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ resource.executable-properties-template=Template for creating executable propert
resource.setup-icon=setup dialog icon
resource.post-app-image-script=script to run after application image is populated
resource.post-msi-script=script to run after msi file for exe installer is created
resource.wxl-file=WiX localization file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be added to all WinResources*.properties files.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. We have a discussion of how l10n files should be changed at #9753. Can you confirm that if some property is missing in a resource bundle its value is picked from the English resource bundle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just pushed the commit with EN entries for all files before reading the latest comment. I'll verify the behaviour with .wxl and .properties files and will comment in this issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe for the .properties case, modifications for the localized files are not required, as ResourceBundles fall back to the root (English) bundle.

resource.wxl-file-name=MsiInstallerStrings_en.wxl
resource.main-wix-file=Main WiX project file
resource.overrides-wix-file=Overrides WiX project file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ resource.executable-properties-template=Vorlage f\u00FCr das Erstellen der ausf\
resource.setup-icon=Symbol f\u00FCr Dialogfeld "Setup"
resource.post-app-image-script=Auszuf\u00FChrendes Skript nach dem Auff\u00FCllen des Anwendungsimages
resource.post-msi-script=Auszuf\u00FChrendes Skript nach dem Erstellen der MSI-Datei f\u00FCr das EXE-Installationsprogramm
resource.wxl-file-name=MsiInstallerStrings_en.wxl
resource.wxl-file-name=MsiInstallerStrings_de.wxl
resource.main-wix-file=Haupt-WiX-Projektdatei
resource.overrides-wix-file=\u00DCberschreibt WiX-Projektdatei
resource.shortcutpromptdlg-wix-file=Dialogfeld f\u00FCr Verkn\u00FCpfungs-Prompt der WiX-Projektdatei
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ resource.executable-properties-template=\u5B9F\u884C\u53EF\u80FD\u306A\u30D7\u30
resource.setup-icon=\u8A2D\u5B9A\u30C0\u30A4\u30A2\u30ED\u30B0\u30FB\u30A2\u30A4\u30B3\u30F3
resource.post-app-image-script=\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u30FB\u30A4\u30E1\u30FC\u30B8\u3092\u79FB\u5165\u3057\u305F\u5F8C\u306B\u5B9F\u884C\u3059\u308B\u30B9\u30AF\u30EA\u30D7\u30C8
resource.post-msi-script=exe\u30A4\u30F3\u30B9\u30C8\u30FC\u30E9\u306Emsi\u30D5\u30A1\u30A4\u30EB\u304C\u4F5C\u6210\u3055\u308C\u305F\u5F8C\u306B\u5B9F\u884C\u3059\u308B\u30B9\u30AF\u30EA\u30D7\u30C8
resource.wxl-file-name=MsiInstallerStrings_en.wxl
resource.wxl-file-name=MsiInstallerStrings_ja.wxl
resource.main-wix-file=\u30E1\u30A4\u30F3WiX\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB
resource.overrides-wix-file=WiX\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB\u306E\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9
resource.shortcutpromptdlg-wix-file=\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8\u30FB\u30D7\u30ED\u30F3\u30D7\u30C8\u30FB\u30C0\u30A4\u30A2\u30ED\u30B0WiX\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u30FB\u30D5\u30A1\u30A4\u30EB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ resource.executable-properties-template=\u7528\u4E8E\u521B\u5EFA\u53EF\u6267\u88
resource.setup-icon=\u8BBE\u7F6E\u5BF9\u8BDD\u6846\u56FE\u6807
resource.post-app-image-script=\u8981\u5728\u586B\u5145\u5E94\u7528\u7A0B\u5E8F\u6620\u50CF\u4E4B\u540E\u8FD0\u884C\u7684\u811A\u672C
resource.post-msi-script=\u5728\u4E3A exe \u5B89\u88C5\u7A0B\u5E8F\u521B\u5EFA msi \u6587\u4EF6\u4E4B\u540E\u8981\u8FD0\u884C\u7684\u811A\u672C
resource.wxl-file-name=MsiInstallerStrings_en.wxl
resource.wxl-file-name=MsiInstallerStrings_zh_CN.wxl
resource.main-wix-file=\u4E3B WiX \u9879\u76EE\u6587\u4EF6
resource.overrides-wix-file=\u8986\u76D6 WiX \u9879\u76EE\u6587\u4EF6
resource.shortcutpromptdlg-wix-file=\u5FEB\u6377\u65B9\u5F0F\u63D0\u793A\u5BF9\u8BDD\u6846 WiX \u9879\u76EE\u6587\u4EF6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ private static Path getInstallationSubDirectory(JPackageCommand cmd) {
return Path.of(cmd.getArgumentValue("--install-dir", cmd::name));
}

// Tests have problems on windows where path in the temp dir are too long
// for the wix tools. We can't use a tempDir outside the TKit's WorkDir, so
// we minimize both the tempRoot directory name (above) and the tempDir name
// (below) to the extension part (which is necessary to differenciate between
// the multiple PackageTypes that will be run for one JPackageCommand).
// It might be beter if the whole work dir name was shortened from:
// jtreg_open_test_jdk_tools_jpackage_share_jdk_jpackage_tests_BasicTest_java.
public static Path getTempDirectory(JPackageCommand cmd, Path tempRoot) {
String ext = cmd.outputBundle().getFileName().toString();
int i = ext.lastIndexOf(".");
if (i > 0 && i < (ext.length() - 1)) {
ext = ext.substring(i+1);
}
return tempRoot.resolve(ext);
}

private static void runMsiexecWithRetries(Executor misexec) {
Executor.Result result = null;
for (int attempt = 0; attempt < 8; ++attempt) {
Expand Down
21 changes: 4 additions & 17 deletions test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.Annotations.Parameter;

import static jdk.jpackage.test.WindowsHelper.getTempDirectory;

/*
* @test
* @summary jpackage basic testing
Expand Down Expand Up @@ -273,29 +275,14 @@ public void testAddModules(String... addModulesArg) {
@Parameter("false")
public void testTemp(boolean withExistingTempDir) throws IOException {
final Path tempRoot = TKit.createTempDirectory("tmp");
// This Test has problems on windows where path in the temp dir are too long
// for the wix tools. We can't use a tempDir outside the TKit's WorkDir, so
// we minimize both the tempRoot directory name (above) and the tempDir name
// (below) to the extension part (which is necessary to differenciate between
// the multiple PackageTypes that will be run for one JPackageCommand).
// It might be beter if the whole work dir name was shortened from:
// jtreg_open_test_jdk_tools_jpackage_share_jdk_jpackage_tests_BasicTest_java.
Function<JPackageCommand, Path> getTempDir = cmd -> {
String ext = cmd.outputBundle().getFileName().toString();
int i = ext.lastIndexOf(".");
if (i > 0 && i < (ext.length() - 1)) {
ext = ext.substring(i+1);
}
return tempRoot.resolve(ext);
};

Supplier<PackageTest> createTest = () -> {
return new PackageTest()
.configureHelloApp()
// Force save of package bundle in test work directory.
.addInitializer(JPackageCommand::setDefaultInputOutput)
.addInitializer(cmd -> {
Path tempDir = getTempDir.apply(cmd);
Path tempDir = getTempDirectory(cmd, tempRoot);
if (withExistingTempDir) {
Files.createDirectories(tempDir);
} else {
Expand All @@ -308,7 +295,7 @@ public void testTemp(boolean withExistingTempDir) throws IOException {
createTest.get()
.addBundleVerifier(cmd -> {
// Check jpackage actually used the supplied directory.
Path tempDir = getTempDir.apply(cmd);
Path tempDir = getTempDirectory(cmd, tempRoot);
TKit.assertNotEquals(0, tempDir.toFile().list().length,
String.format(
"Check jpackage wrote some data in the supplied temporary directory [%s]",
Expand Down
Loading