mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-19 04:13:07 +00:00
8334319: Missing keys in jpackage resource bundle
Reviewed-by: naoto, almatvee
This commit is contained in:
parent
8a3c100c54
commit
ba158edd81
@ -333,14 +333,7 @@ public class WinMsiBundler extends AbstractBundler {
|
||||
|
||||
FileAssociation.verify(FileAssociation.fetchFrom(params));
|
||||
|
||||
var serviceInstallerResource = initServiceInstallerResource(params);
|
||||
if (serviceInstallerResource != null) {
|
||||
if (!Files.exists(serviceInstallerResource.getExternalPath())) {
|
||||
throw new ConfigException(I18N.getString(
|
||||
"error.missing-service-installer"), I18N.getString(
|
||||
"error.missing-service-installer.advice"));
|
||||
}
|
||||
}
|
||||
initServiceInstallerResource(params);
|
||||
|
||||
return true;
|
||||
} catch (RuntimeException re) {
|
||||
@ -407,11 +400,15 @@ public class WinMsiBundler extends AbstractBundler {
|
||||
ensureByMutationFileIsRTF(destFile);
|
||||
}
|
||||
|
||||
var serviceInstallerResource = initServiceInstallerResource(params);
|
||||
if (serviceInstallerResource != null) {
|
||||
var serviceInstallerPath = serviceInstallerResource.getExternalPath();
|
||||
params.put(SERVICE_INSTALLER.getID(), new InstallableFile(
|
||||
serviceInstallerPath, serviceInstallerPath.getFileName()));
|
||||
try {
|
||||
var serviceInstallerResource = initServiceInstallerResource(params);
|
||||
if (serviceInstallerResource != null) {
|
||||
var serviceInstallerPath = serviceInstallerResource.getExternalPath();
|
||||
params.put(SERVICE_INSTALLER.getID(), new InstallableFile(
|
||||
serviceInstallerPath, serviceInstallerPath.getFileName()));
|
||||
}
|
||||
} catch (ConfigException ex) {
|
||||
throw new PackagerException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -763,7 +760,7 @@ public class WinMsiBundler extends AbstractBundler {
|
||||
}
|
||||
|
||||
private static OverridableResource initServiceInstallerResource(
|
||||
Map<String, ? super Object> params) {
|
||||
Map<String, ? super Object> params) throws ConfigException {
|
||||
if (StandardBundlerParam.isRuntimeInstaller(params)) {
|
||||
// Runtime installer doesn't install launchers,
|
||||
// service installer not needed
|
||||
@ -781,12 +778,16 @@ public class WinMsiBundler extends AbstractBundler {
|
||||
var result = createResource(null, params)
|
||||
.setPublicName("service-installer.exe")
|
||||
.setSourceOrder(OverridableResource.Source.External);
|
||||
if (result.getResourceDir() == null) {
|
||||
return null;
|
||||
if (result.getResourceDir() != null) {
|
||||
result.setExternal(result.getResourceDir().resolve(result.getPublicName()));
|
||||
|
||||
if (Files.exists(result.getExternalPath())) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return result.setExternal(result.getResourceDir().resolve(
|
||||
result.getPublicName()));
|
||||
throw new ConfigException(I18N.getString("error.missing-service-installer"),
|
||||
I18N.getString("error.missing-service-installer.advice"));
|
||||
}
|
||||
|
||||
private Path installerIcon;
|
||||
|
||||
@ -57,6 +57,8 @@ error.unlock-resource=Failed to unlock: {0}
|
||||
error.read-wix-l10n-file=Failed to parse {0} file
|
||||
error.extract-culture-from-wix-l10n-file=Failed to read value of culture from {0} file
|
||||
error.short-path-conv-fail=Failed to get short version of "{0}" path
|
||||
error.missing-service-installer='service-installer.exe' service installer not found in the resource directory
|
||||
error.missing-service-installer.advice=Add 'service-installer.exe' service installer to the resource directory
|
||||
|
||||
message.icon-not-ico=The specified icon "{0}" is not an ICO file and will not be used. The default icon will be used in it's place.
|
||||
message.potential.windows.defender.issue=Warning: Windows Defender may prevent jpackage from functioning. If there is an issue, it can be addressed by either disabling realtime monitoring, or adding an exclusion for the directory "{0}".
|
||||
|
||||
@ -56,7 +56,12 @@ public enum JPackageStringBundle {
|
||||
}
|
||||
|
||||
private String getFormattedString(String key, Object[] args) {
|
||||
return MessageFormat.format(getString(key), args);
|
||||
var str = getString(key);
|
||||
if (args.length != 0) {
|
||||
return MessageFormat.format(str, args);
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
public CannedFormattedString cannedFormattedString(String key, String ... args) {
|
||||
|
||||
@ -31,7 +31,10 @@ import jdk.jpackage.test.Annotations.Test;
|
||||
import jdk.jpackage.test.CannedFormattedString;
|
||||
import jdk.jpackage.test.JPackageCommand;
|
||||
import jdk.jpackage.test.JPackageStringBundle;
|
||||
import jdk.jpackage.test.PackageTest;
|
||||
import jdk.jpackage.test.RunnablePackageTest;
|
||||
import jdk.jpackage.test.TKit;
|
||||
import static jdk.internal.util.OperatingSystem.WINDOWS;
|
||||
|
||||
/*
|
||||
* @test
|
||||
@ -113,14 +116,9 @@ public final class ErrorTest {
|
||||
public static void test(String javaAppDesc, String[] jpackageArgs,
|
||||
String[] removeArgs, CannedFormattedString... expectedErrors) {
|
||||
// Init default jpackage test command line.
|
||||
var cmd = JPackageCommand.helloAppImage(javaAppDesc)
|
||||
// Disable default logic adding `--verbose` option
|
||||
// to jpackage command line.
|
||||
// It will affect jpackage error messages if the command line is malformed.
|
||||
.ignoreDefaultVerbose(true)
|
||||
// Ignore external runtime as it will interfer
|
||||
// with jpackage arguments in this test.
|
||||
.ignoreDefaultRuntime(true);
|
||||
var cmd = JPackageCommand.helloAppImage(javaAppDesc);
|
||||
|
||||
defaultInit(cmd, expectedErrors);
|
||||
|
||||
// Add arguments if requested.
|
||||
Optional.ofNullable(jpackageArgs).ifPresent(cmd::addArguments);
|
||||
@ -129,13 +127,42 @@ public final class ErrorTest {
|
||||
Optional.ofNullable(removeArgs).map(List::of).ifPresent(
|
||||
args -> args.forEach(cmd::removeArgumentWithValue));
|
||||
|
||||
cmd.execute(1);
|
||||
}
|
||||
|
||||
@Test(ifOS = WINDOWS)
|
||||
public static void testWinService() {
|
||||
|
||||
CannedFormattedString[] expectedErrors = new CannedFormattedString[] {
|
||||
JPackageStringBundle.MAIN.cannedFormattedString("error.missing-service-installer"),
|
||||
JPackageStringBundle.MAIN.cannedFormattedString("error.missing-service-installer.advice")
|
||||
};
|
||||
|
||||
new PackageTest().configureHelloApp()
|
||||
.addInitializer(cmd -> {
|
||||
defaultInit(cmd, expectedErrors);
|
||||
cmd.addArgument("--launcher-as-service");
|
||||
})
|
||||
.setExpectedExitCode(1)
|
||||
.run(RunnablePackageTest.Action.CREATE);
|
||||
}
|
||||
|
||||
private static void defaultInit(JPackageCommand cmd, CannedFormattedString... expectedErrors) {
|
||||
|
||||
// Disable default logic adding `--verbose` option
|
||||
// to jpackage command line.
|
||||
// It will affect jpackage error messages if the command line is malformed.
|
||||
cmd.ignoreDefaultVerbose(true);
|
||||
|
||||
// Ignore external runtime as it will interfer
|
||||
// with jpackage arguments in this test.
|
||||
cmd.ignoreDefaultRuntime(true);
|
||||
|
||||
// Configure jpackage output verifier to look up the list of provided
|
||||
// errors in the order they specified.
|
||||
// errors in the order they are specified.
|
||||
cmd.validateOutput(Stream.of(expectedErrors)
|
||||
.map(CannedFormattedString::getValue)
|
||||
.map(TKit::assertTextStream)
|
||||
.reduce(TKit.TextStreamVerifier::andThen).get());
|
||||
|
||||
cmd.execute(1);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user