8245831: Unify code parsing version strings on Mac and Windows
Reviewed-by: herrick, almatvee
This commit is contained in:
parent
9e43496c42
commit
1d4bd253e4
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package jdk.incubator.jpackage.internal;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
|
||||
final class CFBundleVersion {
|
||||
/**
|
||||
* Parse the given string as OSX CFBundleVersion.
|
||||
* CFBundleVersion (String - iOS, OS X) specifies the build version number of
|
||||
* the bundle, which identifies an iteration (released or unreleased) of the
|
||||
* bundle. The build version number should be a string comprised of at most three
|
||||
* non-negative, period-separated integers with the first integer being greater
|
||||
* than zero.
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
static DottedVersion of(String value) {
|
||||
DottedVersion ver = new DottedVersion(value);
|
||||
|
||||
BigInteger[] components = ver.getComponents();
|
||||
if (components.length > 3) {
|
||||
throw new IllegalArgumentException(I18N.getString(
|
||||
"message.version-string-too-many-components"));
|
||||
}
|
||||
|
||||
if (BigInteger.ZERO.equals(components[0])) {
|
||||
throw new IllegalArgumentException(I18N.getString(
|
||||
"message.version-string-first-number-not-zero"));
|
||||
}
|
||||
|
||||
return ver;
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package jdk.incubator.jpackage.internal;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* EnumeratedBundlerParams<T>
|
||||
*
|
||||
* Contains key-value pairs (elements) where keys are "displayable"
|
||||
* keys which the IDE can display/choose and values are "identifier" values
|
||||
* which can be stored in parameters' map.
|
||||
*
|
||||
* For instance the Mac has a predefined set of categories which can be applied
|
||||
* to LSApplicationCategoryType which is required for the mac app store.
|
||||
*
|
||||
* The following example illustrates a simple usage of
|
||||
* the MAC_CATEGORY parameter:
|
||||
*
|
||||
* <pre>{@code
|
||||
* Set<String> keys = MAC_CATEGORY.getDisplayableKeys();
|
||||
*
|
||||
* String key = getLastValue(keys); // get last value for example
|
||||
*
|
||||
* String value = MAC_CATEGORY.getValueForDisplayableKey(key);
|
||||
* params.put(MAC_CATEGORY.getID(), value);
|
||||
* }</pre>
|
||||
*
|
||||
*/
|
||||
class EnumeratedBundlerParam<T> extends BundlerParamInfo<T> {
|
||||
// Not sure if this is the correct order, my idea is that from IDE
|
||||
// perspective the string to display to the user is the key and then the
|
||||
// value is some type of object (although probably a String in most cases)
|
||||
private final Map<String, T> elements;
|
||||
private final boolean strict;
|
||||
|
||||
EnumeratedBundlerParam(String id, Class<T> valueType,
|
||||
Function<Map<String, ? super Object>, T> defaultValueFunction,
|
||||
BiFunction<String, Map<String, ? super Object>, T> stringConverter,
|
||||
Map<String, T> elements, boolean strict) {
|
||||
this.id = id;
|
||||
this.valueType = valueType;
|
||||
this.defaultValueFunction = defaultValueFunction;
|
||||
this.stringConverter = stringConverter;
|
||||
this.elements = elements;
|
||||
this.strict = strict;
|
||||
}
|
||||
|
||||
boolean isInPossibleValues(T value) {
|
||||
return elements.values().contains(value);
|
||||
}
|
||||
|
||||
// Having the displayable values as the keys seems a bit wacky
|
||||
Set<String> getDisplayableKeys() {
|
||||
return Collections.unmodifiableSet(elements.keySet());
|
||||
}
|
||||
|
||||
// mapping from a "displayable" key to an "identifier" value.
|
||||
T getValueForDisplayableKey(String displayableKey) {
|
||||
return elements.get(displayableKey);
|
||||
}
|
||||
|
||||
boolean isStrict() {
|
||||
return strict;
|
||||
}
|
||||
|
||||
boolean isLoose() {
|
||||
return !isStrict();
|
||||
}
|
||||
|
||||
}
|
@ -51,20 +51,6 @@ public class MacAppBundler extends AbstractImageBundler {
|
||||
params -> null,
|
||||
(s, p) -> s);
|
||||
|
||||
public static final BundlerParamInfo<String> MAC_CF_BUNDLE_VERSION =
|
||||
new StandardBundlerParam<>(
|
||||
"mac.CFBundleVersion",
|
||||
String.class,
|
||||
p -> {
|
||||
String s = VERSION.fetchFrom(p);
|
||||
if (validCFBundleVersion(s)) {
|
||||
return s;
|
||||
} else {
|
||||
return "100";
|
||||
}
|
||||
},
|
||||
(s, p) -> s);
|
||||
|
||||
public static final BundlerParamInfo<String> DEFAULT_ICNS_ICON =
|
||||
new StandardBundlerParam<>(
|
||||
".mac.default.icns",
|
||||
@ -99,60 +85,18 @@ public class MacAppBundler extends AbstractImageBundler {
|
||||
new StandardBundlerParam<>(
|
||||
Arguments.CLIOptions.MAC_BUNDLE_SIGNING_PREFIX.getId(),
|
||||
String.class,
|
||||
params -> IDENTIFIER.fetchFrom(params) + ".",
|
||||
params -> getIdentifier(params) + ".",
|
||||
(s, p) -> s);
|
||||
|
||||
public static boolean validCFBundleVersion(String v) {
|
||||
// CFBundleVersion (String - iOS, OS X) specifies the build version
|
||||
// number of the bundle, which identifies an iteration (released or
|
||||
// unreleased) of the bundle. The build version number should be a
|
||||
// string comprised of three non-negative, period-separated integers
|
||||
// with the first integer being greater than zero. The string should
|
||||
// only contain numeric (0-9) and period (.) characters. Leading zeros
|
||||
// are truncated from each integer and will be ignored (that is,
|
||||
// 1.02.3 is equivalent to 1.2.3). This key is not localizable.
|
||||
static String getIdentifier(Map<String, ? super Object> params) {
|
||||
String s = MAIN_CLASS.fetchFrom(params);
|
||||
if (s == null) return null;
|
||||
|
||||
if (v == null) {
|
||||
return false;
|
||||
int idx = s.lastIndexOf(".");
|
||||
if (idx >= 1) {
|
||||
return s.substring(0, idx);
|
||||
}
|
||||
|
||||
String p[] = v.split("\\.");
|
||||
if (p.length > 3 || p.length < 1) {
|
||||
Log.verbose(I18N.getString(
|
||||
"message.version-string-too-many-components"));
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
BigInteger n = new BigInteger(p[0]);
|
||||
if (BigInteger.ONE.compareTo(n) > 0) {
|
||||
Log.verbose(I18N.getString(
|
||||
"message.version-string-first-number-not-zero"));
|
||||
return false;
|
||||
}
|
||||
if (p.length > 1) {
|
||||
n = new BigInteger(p[1]);
|
||||
if (BigInteger.ZERO.compareTo(n) > 0) {
|
||||
Log.verbose(I18N.getString(
|
||||
"message.version-string-no-negative-numbers"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (p.length > 2) {
|
||||
n = new BigInteger(p[2]);
|
||||
if (BigInteger.ZERO.compareTo(n) > 0) {
|
||||
Log.verbose(I18N.getString(
|
||||
"message.version-string-no-negative-numbers"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException ne) {
|
||||
Log.verbose(I18N.getString("message.version-string-numbers-only"));
|
||||
Log.verbose(ne);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -179,10 +123,12 @@ public class MacAppBundler extends AbstractImageBundler {
|
||||
}
|
||||
|
||||
// validate short version
|
||||
if (!validCFBundleVersion(MAC_CF_BUNDLE_VERSION.fetchFrom(params))) {
|
||||
throw new ConfigException(
|
||||
I18N.getString("error.invalid-cfbundle-version"),
|
||||
I18N.getString("error.invalid-cfbundle-version.advice"));
|
||||
try {
|
||||
String version = VERSION.fetchFrom(params);
|
||||
CFBundleVersion.of(version);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new ConfigException(ex.getMessage(), I18N.getString(
|
||||
"error.invalid-cfbundle-version.advice"), ex);
|
||||
}
|
||||
|
||||
// reject explicitly set sign to true and no valid signature key
|
||||
|
@ -110,29 +110,7 @@ public class MacAppImageBuilder extends AbstractAppImageBuilder {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
identifier = IDENTIFIER.fetchFrom(params);
|
||||
if (identifier != null) {
|
||||
return identifier;
|
||||
}
|
||||
// the IDENTIFIER (above) will default to derive from
|
||||
// the main-class, in case there is no main-class
|
||||
// (such as runtime installer) revert to the name.
|
||||
// any of these could be invalid, so check later.
|
||||
return APP_NAME.fetchFrom(params);
|
||||
},
|
||||
(s, p) -> s);
|
||||
|
||||
public static final BundlerParamInfo<String> MAC_CF_BUNDLE_VERSION =
|
||||
new StandardBundlerParam<>(
|
||||
"mac.CFBundleVersion",
|
||||
String.class,
|
||||
p -> {
|
||||
String s = VERSION.fetchFrom(p);
|
||||
if (validCFBundleVersion(s)) {
|
||||
return s;
|
||||
} else {
|
||||
return "100";
|
||||
}
|
||||
return MacAppBundler.getIdentifier(params);
|
||||
},
|
||||
(s, p) -> s);
|
||||
|
||||
@ -188,59 +166,6 @@ public class MacAppImageBuilder extends AbstractAppImageBuilder {
|
||||
Files.copy(in, dstFile);
|
||||
}
|
||||
|
||||
public static boolean validCFBundleVersion(String v) {
|
||||
// CFBundleVersion (String - iOS, OS X) specifies the build version
|
||||
// number of the bundle, which identifies an iteration (released or
|
||||
// unreleased) of the bundle. The build version number should be a
|
||||
// string comprised of three non-negative, period-separated integers
|
||||
// with the first integer being greater than zero. The string should
|
||||
// only contain numeric (0-9) and period (.) characters. Leading zeros
|
||||
// are truncated from each integer and will be ignored (that is,
|
||||
// 1.02.3 is equivalent to 1.2.3). This key is not localizable.
|
||||
|
||||
if (v == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String p[] = v.split("\\.");
|
||||
if (p.length > 3 || p.length < 1) {
|
||||
Log.verbose(I18N.getString(
|
||||
"message.version-string-too-many-components"));
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
BigInteger n = new BigInteger(p[0]);
|
||||
if (BigInteger.ONE.compareTo(n) > 0) {
|
||||
Log.verbose(I18N.getString(
|
||||
"message.version-string-first-number-not-zero"));
|
||||
return false;
|
||||
}
|
||||
if (p.length > 1) {
|
||||
n = new BigInteger(p[1]);
|
||||
if (BigInteger.ZERO.compareTo(n) > 0) {
|
||||
Log.verbose(I18N.getString(
|
||||
"message.version-string-no-negative-numbers"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (p.length > 2) {
|
||||
n = new BigInteger(p[2]);
|
||||
if (BigInteger.ZERO.compareTo(n) > 0) {
|
||||
Log.verbose(I18N.getString(
|
||||
"message.version-string-no-negative-numbers"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException ne) {
|
||||
Log.verbose(I18N.getString("message.version-string-numbers-only"));
|
||||
Log.verbose(ne);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getAppDir() {
|
||||
return appDir;
|
||||
@ -469,16 +394,10 @@ public class MacAppImageBuilder extends AbstractAppImageBuilder {
|
||||
MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params));
|
||||
data.put("DEPLOY_BUNDLE_NAME",
|
||||
getBundleName(params));
|
||||
data.put("DEPLOY_BUNDLE_COPYRIGHT",
|
||||
COPYRIGHT.fetchFrom(params) != null ?
|
||||
COPYRIGHT.fetchFrom(params) : "Unknown");
|
||||
data.put("DEPLOY_BUNDLE_COPYRIGHT", COPYRIGHT.fetchFrom(params));
|
||||
data.put("DEPLOY_LAUNCHER_NAME", getLauncherName(params));
|
||||
data.put("DEPLOY_BUNDLE_SHORT_VERSION",
|
||||
VERSION.fetchFrom(params) != null ?
|
||||
VERSION.fetchFrom(params) : "1.0.0");
|
||||
data.put("DEPLOY_BUNDLE_CFBUNDLE_VERSION",
|
||||
MAC_CF_BUNDLE_VERSION.fetchFrom(params) != null ?
|
||||
MAC_CF_BUNDLE_VERSION.fetchFrom(params) : "100");
|
||||
data.put("DEPLOY_BUNDLE_SHORT_VERSION", VERSION.fetchFrom(params));
|
||||
data.put("DEPLOY_BUNDLE_CFBUNDLE_VERSION", VERSION.fetchFrom(params));
|
||||
|
||||
boolean hasMainJar = MAIN_JAR.fetchFrom(params) != null;
|
||||
boolean hasMainModule =
|
||||
|
@ -29,7 +29,6 @@ store.bundler.name=Mac App Store Ready Bundler
|
||||
dmg.bundler.name=Mac DMG Package
|
||||
pkg.bundler.name=Mac PKG Package
|
||||
|
||||
error.invalid-cfbundle-version=Invalid CFBundleVersion: [{0}]
|
||||
error.invalid-cfbundle-version.advice=Set a compatible 'appVersion' or set a 'mac.CFBundleVersion'. Valid versions are one to three integers separated by dots.
|
||||
error.explicit-sign-no-cert=Signature explicitly requested but no signing certificate found
|
||||
error.explicit-sign-no-cert.advice=Specify a valid mac-signing-key-user-name and mac-signing-keychain
|
||||
@ -64,8 +63,6 @@ message.preparing-info-plist=Preparing Info.plist: {0}.
|
||||
message.icon-not-icns= The specified icon "{0}" is not an ICNS file and will not be used. The default icon will be used in it's place.
|
||||
message.version-string-too-many-components=Version sting may have between 1 and 3 numbers: 1, 1.2, 1.2.3.
|
||||
message.version-string-first-number-not-zero=The first number in a CFBundleVersion cannot be zero or negative.
|
||||
message.version-string-no-negative-numbers=Negative numbers are not allowed in version strings.
|
||||
message.version-string-numbers-only=Version strings can consist of only numbers and up to two dots.
|
||||
message.creating-association-with-null-extension=Creating association with null extension.
|
||||
message.ignoring.symlink=Warning: codesign is skipping the symlink {0}.
|
||||
message.already.signed=File already signed: {0}.
|
||||
|
@ -29,7 +29,6 @@ store.bundler.name=Mac App Store\u306E\u6E96\u5099\u5B8C\u4E86\u30D0\u30F3\u30C9
|
||||
dmg.bundler.name=Mac DMG\u30D1\u30C3\u30B1\u30FC\u30B8
|
||||
pkg.bundler.name=Mac PKG\u30D1\u30C3\u30B1\u30FC\u30B8
|
||||
|
||||
error.invalid-cfbundle-version=\u7121\u52B9\u306ACFBundleVersion: [{0}]
|
||||
error.invalid-cfbundle-version.advice=\u4E92\u63DB\u6027\u306E\u3042\u308B'appVersion'\u3092\u8A2D\u5B9A\u3059\u308B\u304B\u3001'mac.CFBundleVersion'\u3092\u8A2D\u5B9A\u3057\u307E\u3059\u3002\u6709\u52B9\u306A\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u3001\u30C9\u30C3\u30C8\u3067\u533A\u5207\u3089\u308C\u305F1\u304B\u30893\u3064\u306E\u6574\u6570\u3067\u3059\u3002
|
||||
error.explicit-sign-no-cert=Signature explicitly requested but no signing certificate found
|
||||
error.explicit-sign-no-cert.advice=Specify a valid mac-signing-key-user-name and mac-signing-keychain
|
||||
@ -65,8 +64,6 @@ message.preparing-info-plist=Info.plist\u3092\u6E96\u5099\u3057\u3066\u3044\u307
|
||||
message.icon-not-icns= \u6307\u5B9A\u3057\u305F\u30A2\u30A4\u30B3\u30F3"{0}"\u306FICNS\u30D5\u30A1\u30A4\u30EB\u3067\u306F\u306A\u304F\u3001\u4F7F\u7528\u3055\u308C\u307E\u305B\u3093\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u30FB\u30A2\u30A4\u30B3\u30F3\u304C\u305D\u306E\u4F4D\u7F6E\u306B\u4F7F\u7528\u3055\u308C\u307E\u3059\u3002
|
||||
message.version-string-too-many-components=\u30D0\u30FC\u30B8\u30E7\u30F3\u6587\u5B57\u5217\u306B\u306F\u30011\u30011.2\u30011.2.3\u306A\u30691\u304B\u30893\u306E\u6570\u5B57\u3092\u4F7F\u7528\u3067\u304D\u307E\u3059\u3002
|
||||
message.version-string-first-number-not-zero=CFBundleVersion\u306E\u6700\u521D\u306E\u6570\u5B57\u306F\u3001\u30BC\u30ED\u307E\u305F\u306F\u8CA0\u306E\u5024\u306B\u3067\u304D\u307E\u305B\u3093\u3002
|
||||
message.version-string-no-negative-numbers=\u30D0\u30FC\u30B8\u30E7\u30F3\u6587\u5B57\u5217\u306B\u8CA0\u306E\u6570\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093\u3002
|
||||
message.version-string-numbers-only=\u30D0\u30FC\u30B8\u30E7\u30F3\u6587\u5B57\u5217\u306F\u3001\u6570\u5B57\u30682\u3064\u307E\u3067\u306E\u30C9\u30C3\u30C8\u3067\u306E\u307F\u69CB\u6210\u3067\u304D\u307E\u3059\u3002
|
||||
message.creating-association-with-null-extension=null\u62E1\u5F35\u5B50\u3068\u306E\u95A2\u9023\u4ED8\u3051\u3092\u4F5C\u6210\u3057\u3066\u3044\u307E\u3059\u3002
|
||||
message.ignoring.symlink=\u8B66\u544A: codesign\u304Csymlink {0}\u3092\u30B9\u30AD\u30C3\u30D7\u3057\u3066\u3044\u307E\u3059
|
||||
message.already.signed=File already signed: {0}.
|
||||
|
@ -29,7 +29,6 @@ store.bundler.name=\u652F\u6301 Mac App Store \u7684\u6253\u5305\u7A0B\u5E8F
|
||||
dmg.bundler.name=Mac DMG \u7A0B\u5E8F\u5305
|
||||
pkg.bundler.name=Mac PKG \u7A0B\u5E8F\u5305
|
||||
|
||||
error.invalid-cfbundle-version=\u65E0\u6548\u7684 CFBundleVersion\uFF1A[{0}]
|
||||
error.invalid-cfbundle-version.advice=\u8BBE\u7F6E\u517C\u5BB9\u7684 'appVersion' \u6216\u8005\u8BBE\u7F6E 'mac.CFBundleVersion'\u3002\u6709\u6548\u7248\u672C\u5305\u542B\u4E00\u5230\u4E09\u4E2A\u7528\u70B9\u5206\u9694\u7684\u6574\u6570\u3002
|
||||
error.explicit-sign-no-cert=Signature explicitly requested but no signing certificate found
|
||||
error.explicit-sign-no-cert.advice=Specify a valid mac-signing-key-user-name and mac-signing-keychain
|
||||
@ -65,8 +64,6 @@ message.preparing-info-plist=\u6B63\u5728\u51C6\u5907 Info.plist: {0}\u3002
|
||||
message.icon-not-icns= \u6307\u5B9A\u7684\u56FE\u6807 "{0}" \u4E0D\u662F ICNS \u6587\u4EF6, \u4E0D\u4F1A\u4F7F\u7528\u3002\u5C06\u4F7F\u7528\u9ED8\u8BA4\u56FE\u6807\u4EE3\u66FF\u3002
|
||||
message.version-string-too-many-components=\u7248\u672C\u5B57\u7B26\u4E32\u53EF\u4EE5\u5305\u542B 1 \u5230 3 \u4E2A\u6570\u5B57: 1, 1.2, 1.2.3\u3002
|
||||
message.version-string-first-number-not-zero=CFBundleVersion \u4E2D\u7684\u7B2C\u4E00\u4E2A\u6570\u5B57\u4E0D\u80FD\u4E3A\u96F6\u6216\u8D1F\u6570\u3002
|
||||
message.version-string-no-negative-numbers=\u7248\u672C\u5B57\u7B26\u4E32\u4E2D\u4E0D\u5141\u8BB8\u4F7F\u7528\u8D1F\u6570\u3002
|
||||
message.version-string-numbers-only=\u7248\u672C\u5B57\u7B26\u4E32\u53EA\u80FD\u5305\u542B\u6570\u5B57\u548C\u6700\u591A\u4E24\u4E2A\u70B9\u3002
|
||||
message.creating-association-with-null-extension=\u6B63\u5728\u4F7F\u7528\u7A7A\u6269\u5C55\u540D\u521B\u5EFA\u5173\u8054\u3002
|
||||
message.ignoring.symlink=\u8B66\u544A: codesign \u6B63\u5728\u8DF3\u8FC7\u7B26\u53F7\u94FE\u63A5 {0}\u3002
|
||||
message.already.signed=File already signed: {0}.
|
||||
|
@ -104,7 +104,6 @@ public abstract class AbstractAppImageBuilder {
|
||||
out.println("app.name=" + APP_NAME.fetchFrom(params));
|
||||
out.println("app.version=" + VERSION.fetchFrom(params));
|
||||
out.println("app.runtime=" + getCfgRuntimeDir());
|
||||
out.println("app.identifier=" + IDENTIFIER.fetchFrom(params));
|
||||
out.println("app.classpath="
|
||||
+ getCfgClassPath(CLASSPATH.fetchFrom(params)));
|
||||
|
||||
|
@ -25,18 +25,21 @@
|
||||
|
||||
package jdk.incubator.jpackage.internal;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Dotted numeric version string.
|
||||
* E.g.: 1.0.37, 10, 0.5
|
||||
*/
|
||||
class DottedVersion implements Comparable<String> {
|
||||
final class DottedVersion implements Comparable<String> {
|
||||
|
||||
public DottedVersion(String version) {
|
||||
DottedVersion(String version) {
|
||||
greedy = true;
|
||||
components = parseVersionString(version, greedy);
|
||||
value = version;
|
||||
@ -48,49 +51,61 @@ class DottedVersion implements Comparable<String> {
|
||||
value = version;
|
||||
}
|
||||
|
||||
public static DottedVersion greedy(String version) {
|
||||
static DottedVersion greedy(String version) {
|
||||
return new DottedVersion(version);
|
||||
}
|
||||
|
||||
public static DottedVersion lazy(String version) {
|
||||
static DottedVersion lazy(String version) {
|
||||
return new DottedVersion(version, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(String o) {
|
||||
int result = 0;
|
||||
int[] otherComponents = parseVersionString(o, greedy);
|
||||
for (int i = 0; i < Math.min(components.length, otherComponents.length)
|
||||
BigInteger[] otherComponents = parseVersionString(o, greedy);
|
||||
for (int i = 0; i < Math.max(components.length, otherComponents.length)
|
||||
&& result == 0; ++i) {
|
||||
result = components[i] - otherComponents[i];
|
||||
}
|
||||
final BigInteger x;
|
||||
if (i < components.length) {
|
||||
x = components[i];
|
||||
} else {
|
||||
x = BigInteger.ZERO;
|
||||
}
|
||||
|
||||
if (result == 0) {
|
||||
result = components.length - otherComponents.length;
|
||||
final BigInteger y;
|
||||
if (i < otherComponents.length) {
|
||||
y = otherComponents[i];
|
||||
} else {
|
||||
y = BigInteger.ZERO;
|
||||
}
|
||||
result = x.compareTo(y);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int[] parseVersionString(String version, boolean greedy) {
|
||||
private static BigInteger[] parseVersionString(String version, boolean greedy) {
|
||||
Objects.requireNonNull(version);
|
||||
if (version.isEmpty()) {
|
||||
if (!greedy) {
|
||||
return new int[] {0};
|
||||
return new BigInteger[] {BigInteger.ZERO};
|
||||
}
|
||||
throw new IllegalArgumentException("Version may not be empty string");
|
||||
throw new IllegalArgumentException(I18N.getString(
|
||||
"error.version-string-empty"));
|
||||
}
|
||||
|
||||
int lastNotZeroIdx = -1;
|
||||
List<Integer> components = new ArrayList<>();
|
||||
List<BigInteger> components = new ArrayList<>();
|
||||
for (var component : version.split("\\.", -1)) {
|
||||
if (component.isEmpty()) {
|
||||
if (!greedy) {
|
||||
break;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Version [%s] contains a zero lenght component", version));
|
||||
throw new IllegalArgumentException(MessageFormat.format(
|
||||
I18N.getString(
|
||||
"error.version-string-zero-length-component"),
|
||||
version));
|
||||
}
|
||||
|
||||
if (!DIGITS.matcher(component).matches()) {
|
||||
@ -99,23 +114,27 @@ class DottedVersion implements Comparable<String> {
|
||||
break;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Version [%s] contains invalid component [%s]", version,
|
||||
component));
|
||||
throw new IllegalArgumentException(MessageFormat.format(
|
||||
I18N.getString(
|
||||
"error.version-string-invalid-component"),
|
||||
version, component));
|
||||
}
|
||||
|
||||
final int num;
|
||||
final BigInteger num;
|
||||
try {
|
||||
num = Integer.parseInt(component);
|
||||
num = new BigInteger(component);
|
||||
} catch (NumberFormatException ex) {
|
||||
if (!greedy) {
|
||||
break;
|
||||
}
|
||||
|
||||
throw ex;
|
||||
throw new IllegalArgumentException(MessageFormat.format(
|
||||
I18N.getString(
|
||||
"error.version-string-invalid-component"),
|
||||
version, component));
|
||||
}
|
||||
|
||||
if (num != 0) {
|
||||
if (num != BigInteger.ZERO) {
|
||||
lastNotZeroIdx = components.size();
|
||||
}
|
||||
components.add(num);
|
||||
@ -127,9 +146,10 @@ class DottedVersion implements Comparable<String> {
|
||||
}
|
||||
|
||||
if (components.isEmpty()) {
|
||||
components.add(0);
|
||||
components.add(BigInteger.ZERO);
|
||||
}
|
||||
return components.stream().mapToInt(Integer::intValue).toArray();
|
||||
return components.stream()
|
||||
.collect(Collectors.toList()).toArray(BigInteger[]::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,11 +157,11 @@ class DottedVersion implements Comparable<String> {
|
||||
return value;
|
||||
}
|
||||
|
||||
int[] getComponents() {
|
||||
BigInteger[] getComponents() {
|
||||
return components;
|
||||
}
|
||||
|
||||
final private int[] components;
|
||||
final private BigInteger[] components;
|
||||
final private String value;
|
||||
final private boolean greedy;
|
||||
|
||||
|
@ -308,23 +308,6 @@ class StandardBundlerParam<T> extends BundlerParamInfo<T> {
|
||||
(s, p) -> null
|
||||
);
|
||||
|
||||
static final StandardBundlerParam<String> IDENTIFIER =
|
||||
new StandardBundlerParam<>(
|
||||
"identifier.default",
|
||||
String.class,
|
||||
params -> {
|
||||
String s = MAIN_CLASS.fetchFrom(params);
|
||||
if (s == null) return null;
|
||||
|
||||
int idx = s.lastIndexOf(".");
|
||||
if (idx >= 1) {
|
||||
return s.substring(0, idx);
|
||||
}
|
||||
return s;
|
||||
},
|
||||
(s, p) -> s
|
||||
);
|
||||
|
||||
static final StandardBundlerParam<Boolean> BIND_SERVICES =
|
||||
new StandardBundlerParam<>(
|
||||
Arguments.CLIOptions.BIND_SERVICES.getId(),
|
||||
|
@ -43,6 +43,10 @@ message.bundle-created=Succeeded in building {0} package
|
||||
message.module-version=Using version "{0}" from module "{1}" as application version
|
||||
message.module-class=Using class "{0}" from module "{1}" as application main class
|
||||
|
||||
error.version-string-empty="Version may not be empty string"
|
||||
error.version-string-zero-length-component="Version [{0}] contains a zero length component"
|
||||
error.version-string-invalid-component="Version [{0}] contains invalid component [{1}]"
|
||||
|
||||
error.cannot-create-output-dir=Destination directory {0} cannot be created
|
||||
error.cannot-write-to-output-dir=Destination directory {0} is not writable
|
||||
error.root-exists=Error: Application destination directory {0} already exists
|
||||
|
@ -43,6 +43,10 @@ message.bundle-created={0}\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u4F5C\u6210\u306B
|
||||
message.module-version=\u30E2\u30B8\u30E5\u30FC\u30EB"{1}"\u306E\u30D0\u30FC\u30B8\u30E7\u30F3"{0}"\u3092\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3\u3068\u3057\u3066\u4F7F\u7528
|
||||
message.module-class=\u30E2\u30B8\u30E5\u30FC\u30EB"{1}"\u306E\u30AF\u30E9\u30B9"{0}"\u3092\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u30FB\u30E1\u30A4\u30F3\u30FB\u30AF\u30E9\u30B9\u3068\u3057\u3066\u4F7F\u7528
|
||||
|
||||
error.version-string-empty="Version may not be empty string"
|
||||
error.version-string-zero-length-component="Version [{0}] contains a zero length component"
|
||||
error.version-string-invalid-component="Version [{0}] contains invalid component [{1}]"
|
||||
|
||||
error.cannot-create-output-dir=\u5B9B\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u3092\u4F5C\u6210\u3067\u304D\u307E\u305B\u3093\u3002
|
||||
error.cannot-write-to-output-dir=\u5B9B\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u306F\u66F8\u8FBC\u307F\u4E0D\u53EF\u3067\u3059
|
||||
error.root-exists=\u30A8\u30E9\u30FC: \u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u306E\u5B9B\u5148\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA{0}\u306F\u3059\u3067\u306B\u5B58\u5728\u3057\u307E\u3059
|
||||
|
@ -43,6 +43,10 @@ message.bundle-created=\u5DF2\u6210\u529F\u5730\u6784\u5EFA {0} \u7A0B\u5E8F\u53
|
||||
message.module-version=\u6B63\u5728\u5C06\u6A21\u5757 "{1}" \u4E2D\u7684\u7248\u672C "{0}" \u7528\u4F5C\u5E94\u7528\u7A0B\u5E8F\u7248\u672C
|
||||
message.module-class=\u6B63\u5728\u5C06\u6A21\u5757 "{1}" \u4E2D\u7684\u7C7B "{0}" \u7528\u4F5C\u5E94\u7528\u7A0B\u5E8F\u4E3B\u7C7B
|
||||
|
||||
error.version-string-empty="Version may not be empty string"
|
||||
error.version-string-zero-length-component="Version [{0}] contains a zero length component"
|
||||
error.version-string-invalid-component="Version [{0}] contains invalid component [{1}]"
|
||||
|
||||
error.cannot-create-output-dir=\u65E0\u6CD5\u521B\u5EFA\u76EE\u6807\u76EE\u5F55 {0}
|
||||
error.cannot-write-to-output-dir=\u76EE\u6807\u76EE\u5F55 {0} \u4E0D\u53EF\u5199
|
||||
error.root-exists=\u9519\u8BEF\uFF1A\u5E94\u7528\u7A0B\u5E8F\u76EE\u6807\u76EE\u5F55 {0} \u5DF2\u5B58\u5728
|
||||
|
@ -26,10 +26,10 @@ package jdk.incubator.jpackage.internal;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.text.MessageFormat;
|
||||
@ -37,14 +37,12 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.ResourceBundle;
|
||||
import static jdk.incubator.jpackage.internal.OverridableResource.createResource;
|
||||
import static jdk.incubator.jpackage.internal.StandardBundlerParam.APP_NAME;
|
||||
import static jdk.incubator.jpackage.internal.StandardBundlerParam.COPYRIGHT;
|
||||
import static jdk.incubator.jpackage.internal.StandardBundlerParam.DESCRIPTION;
|
||||
import static jdk.incubator.jpackage.internal.StandardBundlerParam.ICON;
|
||||
import static jdk.incubator.jpackage.internal.StandardBundlerParam.TEMP_ROOT;
|
||||
import static jdk.incubator.jpackage.internal.StandardBundlerParam.VENDOR;
|
||||
import static jdk.incubator.jpackage.internal.StandardBundlerParam.VERSION;
|
||||
@ -150,8 +148,8 @@ final class ExecutableRebrander {
|
||||
}
|
||||
|
||||
private static String getFixedFileVersion(String value) {
|
||||
int[] versionComponents = DottedVersion.greedy(value).getComponents();
|
||||
int addComponentsCount = 4 - versionComponents.length;
|
||||
int addComponentsCount = 4
|
||||
- DottedVersion.greedy(value).getComponents().length;
|
||||
if (addComponentsCount > 0) {
|
||||
StringBuilder sb = new StringBuilder(value);
|
||||
do {
|
||||
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
package jdk.incubator.jpackage.internal;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
|
||||
final class MsiVersion {
|
||||
/**
|
||||
* Parse the given string as Windows MSI Product version.
|
||||
* https://msdn.microsoft.com/en-us/library/aa370859%28v=VS.85%29.aspx The
|
||||
* format of the string is as follows: major.minor.build. The first field is
|
||||
* the major version and has a maximum value of 255. The second field is the
|
||||
* minor version and has a maximum value of 255. The third field is called
|
||||
* the build version or the update version and has a maximum value of
|
||||
* 65,535.
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
static DottedVersion of(String value) {
|
||||
DottedVersion ver = new DottedVersion(value);
|
||||
|
||||
BigInteger[] components = ver.getComponents();
|
||||
if (components.length > 3) {
|
||||
throw new IllegalArgumentException(I18N.getString(
|
||||
"error.msi-product-version-too-many-components"));
|
||||
}
|
||||
|
||||
if (BigInteger.valueOf(255).compareTo(components[0]) < 0) {
|
||||
throw new IllegalArgumentException(I18N.getString(
|
||||
"error.msi-product-version-major-out-of-range"));
|
||||
}
|
||||
|
||||
if (components.length > 1 && BigInteger.valueOf(255).compareTo(
|
||||
components[1]) < 0) {
|
||||
throw new IllegalArgumentException(I18N.getString(
|
||||
"error.msi-product-version-minor-out-of-range"));
|
||||
}
|
||||
|
||||
if (components.length > 2 && BigInteger.valueOf(65535).compareTo(
|
||||
components[2]) < 0) {
|
||||
throw new IllegalArgumentException(I18N.getString(
|
||||
"error.msi-product-version-build-out-of-range"));
|
||||
}
|
||||
|
||||
return ver;
|
||||
}
|
||||
}
|
@ -248,14 +248,12 @@ public class WinMsiBundler extends AbstractBundler {
|
||||
|
||||
/********* 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(
|
||||
"error.version-string-wrong-format.advice"),
|
||||
PRODUCT_VERSION.getID()));
|
||||
try {
|
||||
String version = PRODUCT_VERSION.fetchFrom(params);
|
||||
MsiVersion.of(version);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new ConfigException(ex.getMessage(), I18N.getString(
|
||||
"error.version-string-wrong-format.advice"), ex);
|
||||
}
|
||||
|
||||
FileAssociation.verify(FileAssociation.fetchFrom(params));
|
||||
@ -270,57 +268,6 @@ public class WinMsiBundler extends AbstractBundler {
|
||||
}
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/aa370859%28v=VS.85%29.aspx
|
||||
// The format of the string is as follows:
|
||||
// major.minor.build
|
||||
// The first field is the major version and has a maximum value of 255.
|
||||
// The second field is the minor version and has a maximum value of 255.
|
||||
// The third field is called the build version or the update version and
|
||||
// has a maximum value of 65,535.
|
||||
static boolean isVersionStringValid(String v) {
|
||||
if (v == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String p[] = v.split("\\.");
|
||||
if (p.length > 3) {
|
||||
Log.verbose(I18N.getString(
|
||||
"message.version-string-too-many-components"));
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
int val = Integer.parseInt(p[0]);
|
||||
if (val < 0 || val > 255) {
|
||||
Log.verbose(I18N.getString(
|
||||
"error.version-string-major-out-of-range"));
|
||||
return false;
|
||||
}
|
||||
if (p.length > 1) {
|
||||
val = Integer.parseInt(p[1]);
|
||||
if (val < 0 || val > 255) {
|
||||
Log.verbose(I18N.getString(
|
||||
"error.version-string-minor-out-of-range"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (p.length > 2) {
|
||||
val = Integer.parseInt(p[2]);
|
||||
if (val < 0 || val > 65535) {
|
||||
Log.verbose(I18N.getString(
|
||||
"error.version-string-build-out-of-range"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException ne) {
|
||||
Log.verbose(I18N.getString("error.version-string-part-not-number"));
|
||||
Log.verbose(ne);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void prepareProto(Map<String, ? super Object> params)
|
||||
throws PackagerException, IOException {
|
||||
File appImage = StandardBundlerParam.getPredefinedAppImage(params);
|
||||
|
@ -40,12 +40,11 @@ resource.overrides-wix-file=Overrides WiX project file
|
||||
|
||||
error.no-wix-tools=Can not find WiX tools (light.exe, candle.exe)
|
||||
error.no-wix-tools.advice=Download WiX 3.0 or later from https://wixtoolset.org and add it to the PATH.
|
||||
error.version-string-wrong-format=Version string is not compatible with MSI rules [{0}]
|
||||
error.version-string-wrong-format.advice=Set the bundler argument "{0}" according to these rules: https://msdn.microsoft.com/en-us/library/aa370859%28v\=VS.85%29.aspx .
|
||||
error.version-string-major-out-of-range=Major version must be in the range [0, 255]
|
||||
error.version-string-build-out-of-range=Build part of version must be in the range [0, 65535]
|
||||
error.version-string-minor-out-of-range=Minor version must be in the range [0, 255]
|
||||
error.version-string-part-not-number=Failed to convert version component to int
|
||||
error.version-string-wrong-format.advice=Set value of --app-version parameter according to these rules: https://msdn.microsoft.com/en-us/library/aa370859%28v\=VS.85%29.aspx
|
||||
error.msi-product-version-too-many-components=Version sting may have between 1 and 3 components: 1, 1.2, 1.2.3.
|
||||
error.msi-product-version-major-out-of-range=Major version must be in the range [0, 255]
|
||||
error.msi-product-version-build-out-of-range=Build part of version must be in the range [0, 65535]
|
||||
error.msi-product-version-minor-out-of-range=Minor version must be in the range [0, 255]
|
||||
error.version-swap=Failed to update version information for {0}
|
||||
error.invalid-envvar=Invalid value of {0} environment variable
|
||||
|
||||
|
@ -40,12 +40,11 @@ resource.overrides-wix-file=WiX\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u30FB\u30D5\
|
||||
|
||||
error.no-wix-tools=WiX\u30C4\u30FC\u30EB(light.exe\u3001candle.exe)\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
|
||||
error.no-wix-tools.advice=WiX 3.0\u4EE5\u964D\u3092https://wixtoolset.org\u304B\u3089\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u3057\u3001PATH\u306B\u8FFD\u52A0\u3057\u307E\u3059\u3002
|
||||
error.version-string-wrong-format=\u30D0\u30FC\u30B8\u30E7\u30F3\u6587\u5B57\u5217\u306FMSI\u898F\u5247[{0}]\u3068\u4E92\u63DB\u6027\u304C\u3042\u308A\u307E\u305B\u3093
|
||||
error.version-string-wrong-format.advice=\u30D0\u30F3\u30C9\u30E9\u5F15\u6570"{0}"\u3092\u6B21\u306E\u898F\u5247\u306B\u5F93\u3063\u3066\u8A2D\u5B9A\u3057\u307E\u3059: https://msdn.microsoft.com/en-us/library/aa370859%28v=VS.85%29.aspx\u3002
|
||||
error.version-string-major-out-of-range=\u30E1\u30B8\u30E3\u30FC\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u7BC4\u56F2[0, 255]\u5185\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
|
||||
error.version-string-build-out-of-range=\u30D0\u30FC\u30B8\u30E7\u30F3\u306E\u30D3\u30EB\u30C9\u90E8\u5206\u306F\u7BC4\u56F2[0, 65535]\u5185\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
|
||||
error.version-string-minor-out-of-range=\u30DE\u30A4\u30CA\u30FC\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u7BC4\u56F2[0, 255]\u5185\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
|
||||
error.version-string-part-not-number=\u30D0\u30FC\u30B8\u30E7\u30F3\u30FB\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u306Eint\u3078\u306E\u5909\u63DB\u306B\u5931\u6557\u3057\u307E\u3057\u305F
|
||||
error.version-string-wrong-format.advice=Set value of --app-version parameter according to these rules: https://msdn.microsoft.com/en-us/library/aa370859%28v\=VS.85%29.aspx
|
||||
error.msi-product-version-too-many-components=Version sting may have between 1 and 3 components: 1, 1.2, 1.2.3.
|
||||
error.msi-product-version-major-out-of-range=\u30E1\u30B8\u30E3\u30FC\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u7BC4\u56F2[0, 255]\u5185\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
|
||||
error.msi-product-version-build-out-of-range=\u30D0\u30FC\u30B8\u30E7\u30F3\u306E\u30D3\u30EB\u30C9\u90E8\u5206\u306F\u7BC4\u56F2[0, 65535]\u5185\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
|
||||
error.msi-product-version-minor-out-of-range=\u30DE\u30A4\u30CA\u30FC\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u7BC4\u56F2[0, 255]\u5185\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
|
||||
error.version-swap={0}\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u306E\u66F4\u65B0\u306B\u5931\u6557\u3057\u307E\u3057\u305F
|
||||
error.invalid-envvar={0}\u74B0\u5883\u5909\u6570\u306E\u5024\u304C\u7121\u52B9\u3067\u3059
|
||||
|
||||
|
@ -40,12 +40,11 @@ resource.overrides-wix-file=\u8986\u76D6 WiX \u9879\u76EE\u6587\u4EF6
|
||||
|
||||
error.no-wix-tools=\u627E\u4E0D\u5230 WiX \u5DE5\u5177 (light.exe, candle.exe)
|
||||
error.no-wix-tools.advice=\u4ECE https://wixtoolset.org \u4E0B\u8F7D WiX 3.0 \u6216\u66F4\u9AD8\u7248\u672C\uFF0C\u7136\u540E\u5C06\u5176\u6DFB\u52A0\u5230 PATH\u3002
|
||||
error.version-string-wrong-format=\u7248\u672C\u5B57\u7B26\u4E32\u4E0D\u7B26\u5408 MSI \u89C4\u5219 [{0}]
|
||||
error.version-string-wrong-format.advice=\u6839\u636E\u4EE5\u4E0B\u89C4\u5219\u8BBE\u7F6E\u6253\u5305\u7A0B\u5E8F\u53C2\u6570 "{0}"\uFF1Ahttps://msdn.microsoft.com/en-us/library/aa370859%28v=VS.85%29.aspx\u3002
|
||||
error.version-string-major-out-of-range=\u4E3B\u7248\u672C\u5FC5\u987B\u4F4D\u4E8E [0, 255] \u8303\u56F4\u4E2D
|
||||
error.version-string-build-out-of-range=\u7248\u672C\u7684\u5DE5\u4F5C\u7248\u672C\u90E8\u5206\u5FC5\u987B\u4F4D\u4E8E [0, 65535] \u8303\u56F4\u4E2D
|
||||
error.version-string-minor-out-of-range=\u6B21\u7248\u672C\u5FC5\u987B\u4F4D\u4E8E [0, 255] \u8303\u56F4\u4E2D
|
||||
error.version-string-part-not-number=\u65E0\u6CD5\u5C06\u7248\u672C\u7EC4\u6210\u90E8\u5206\u8F6C\u6362\u4E3A\u6574\u6570
|
||||
error.version-string-wrong-format.advice=Set value of --app-version parameter according to these rules: https://msdn.microsoft.com/en-us/library/aa370859%28v\=VS.85%29.aspx .
|
||||
error.msi-product-version-too-many-components=Version sting may have between 1 and 3 components: 1, 1.2, 1.2.3.
|
||||
error.msi-product-version-major-out-of-range=\u4E3B\u7248\u672C\u5FC5\u987B\u4F4D\u4E8E [0, 255] \u8303\u56F4\u4E2D
|
||||
error.msi-product-version-build-out-of-range=\u7248\u672C\u7684\u5DE5\u4F5C\u7248\u672C\u90E8\u5206\u5FC5\u987B\u4F4D\u4E8E [0, 65535] \u8303\u56F4\u4E2D
|
||||
error.msi-product-version-minor-out-of-range=\u6B21\u7248\u672C\u5FC5\u987B\u4F4D\u4E8E [0, 255] \u8303\u56F4\u4E2D
|
||||
error.version-swap=\u65E0\u6CD5\u66F4\u65B0 {0} \u7684\u7248\u672C\u4FE1\u606F
|
||||
error.invalid-envvar={0} \u73AF\u5883\u53D8\u91CF\u7684\u503C\u65E0\u6548
|
||||
|
||||
|
@ -53,11 +53,14 @@ public class CompareDottedVersionTest {
|
||||
for (var greedy : List.of(true, false)) {
|
||||
data.addAll(List.of(new Object[][] {
|
||||
{ greedy, "00.0.0", "0", 0 },
|
||||
{ greedy, "00.0.0", "0.000", 0 },
|
||||
{ greedy, "0.035", "0.0035", 0 },
|
||||
{ greedy, "0.035", "0.0035.0", 0 },
|
||||
{ greedy, "1", "1", 0 },
|
||||
{ greedy, "2", "2.0", 0 },
|
||||
{ greedy, "2.00", "2.0", 0 },
|
||||
{ greedy, "1.2.3.4", "1.2.3.4.5", -1 },
|
||||
{ greedy, "1.2.3.4", "1.2.3.4.0.1", -1 },
|
||||
{ greedy, "34", "33", 1 },
|
||||
{ greedy, "34.0.78", "34.1.78", -1 }
|
||||
}));
|
||||
@ -70,7 +73,7 @@ public class CompareDottedVersionTest {
|
||||
{ false, "7+1", "7+4", 0 },
|
||||
{ false, "2+14", "2-14", 0 },
|
||||
{ false, "23.4.RC4", "23.3.RC10", 1 },
|
||||
{ false, "77.0", "77.99999999999999999999999999999999999999999999999", 0 },
|
||||
{ false, "77." + "9".repeat(1000), "77." + "9".repeat(1000 -1) + "8", 1 },
|
||||
}));
|
||||
|
||||
return data;
|
||||
|
@ -61,7 +61,8 @@ public class DottedVersionTest {
|
||||
"2.234.045",
|
||||
"2.234.0",
|
||||
"0",
|
||||
"0.1"
|
||||
"0.1",
|
||||
"9".repeat(1000)
|
||||
);
|
||||
|
||||
final List<String> validLazyStrings;
|
||||
@ -82,7 +83,7 @@ public class DottedVersionTest {
|
||||
"+1",
|
||||
"-1",
|
||||
"-0",
|
||||
"1234567890123456789012345678901234567890"
|
||||
"+0"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class InvalidDottedVersionTest {
|
||||
"+1",
|
||||
"-1",
|
||||
"-0",
|
||||
"1234567890123456789012345678901234567890"
|
||||
"+0"
|
||||
).map(version -> new Object[] { version }).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package jdk.incubator.jpackage.internal;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.lang.reflect.Method;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class PlatformVersionTest {
|
||||
|
||||
public PlatformVersionTest(Function<String, DottedVersion> parser,
|
||||
String version, boolean valid) {
|
||||
this.parser = parser;
|
||||
this.version = version;
|
||||
this.valid = valid;
|
||||
}
|
||||
|
||||
@Parameters
|
||||
public static List<Object[]> data() {
|
||||
List<Object[]> data = new ArrayList<>();
|
||||
addTo(data, WIN_MSI_PRODUCT_VERSION_PARSER, true,
|
||||
"255",
|
||||
"0",
|
||||
"255.255",
|
||||
"255.255.65535",
|
||||
"1.0",
|
||||
"1",
|
||||
"01.02.6"
|
||||
);
|
||||
|
||||
addTo(data, WIN_MSI_PRODUCT_VERSION_PARSER, false,
|
||||
"256",
|
||||
"255.256",
|
||||
"255.255.65536",
|
||||
"1.2.3.4"
|
||||
);
|
||||
|
||||
addTo(data, MAC_CFBUNDLE_VERSION_PARSER, true,
|
||||
"1",
|
||||
"1.2",
|
||||
"1.2.3"
|
||||
);
|
||||
|
||||
addTo(data, MAC_CFBUNDLE_VERSION_PARSER, false,
|
||||
"0",
|
||||
"0.1",
|
||||
"1.2.3.4"
|
||||
);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private static void addTo(List<Object[]> data,
|
||||
Function<String, DottedVersion> parser, boolean valid,
|
||||
String... values) {
|
||||
if (parser != null) {
|
||||
data.addAll(Stream.of(values).map(version -> new Object[]{parser,
|
||||
version, valid}).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
@Rule
|
||||
public ExpectedException exceptionRule = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void testIt() {
|
||||
if (valid) {
|
||||
assertEquals(parser.apply(version).toString(), version);
|
||||
} else {
|
||||
exceptionRule.expect(IllegalArgumentException.class);
|
||||
parser.apply(version);
|
||||
}
|
||||
}
|
||||
|
||||
private final Function<String, DottedVersion> parser;
|
||||
private final String version;
|
||||
private final boolean valid;
|
||||
|
||||
private final static Function<String, DottedVersion> MAC_CFBUNDLE_VERSION_PARSER = findParser(
|
||||
"jdk.incubator.jpackage.internal.CFBundleVersion");
|
||||
private final static Function<String, DottedVersion> WIN_MSI_PRODUCT_VERSION_PARSER = findParser(
|
||||
"jdk.incubator.jpackage.internal.MsiVersion");
|
||||
|
||||
private static Function<String, DottedVersion> findParser(String className) {
|
||||
try {
|
||||
Method method = Class.forName(className).getDeclaredMethod("of",
|
||||
String.class);
|
||||
return (str) -> {
|
||||
try {
|
||||
return (DottedVersion) method.invoke(null, str);
|
||||
} catch (IllegalAccessException | IllegalArgumentException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} catch (InvocationTargetException ex) {
|
||||
Throwable causeEx = ex.getCause();
|
||||
if (causeEx instanceof RuntimeException) {
|
||||
throw (RuntimeException)causeEx;
|
||||
}
|
||||
throw new RuntimeException(causeEx);
|
||||
}
|
||||
};
|
||||
} catch (ClassNotFoundException e) {
|
||||
return null;
|
||||
} catch (SecurityException | NoSuchMethodException ex) {
|
||||
throw new IllegalArgumentException(ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,10 +24,12 @@
|
||||
package jdk.jpackage.tests;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import jdk.jpackage.test.Annotations.Parameters;
|
||||
import jdk.jpackage.test.Annotations.Test;
|
||||
import jdk.jpackage.test.JPackageCommand;
|
||||
import jdk.jpackage.test.PackageTest;
|
||||
import jdk.jpackage.test.TKit;
|
||||
|
||||
/*
|
||||
@ -45,7 +47,9 @@ public final class AppVersionTest {
|
||||
|
||||
@Parameters
|
||||
public static Collection input() {
|
||||
return List.of(new Object[][]{
|
||||
List<Object[]> data = new ArrayList<>();
|
||||
|
||||
data.addAll(List.of(new Object[][]{
|
||||
// Default jpackage version
|
||||
{"1.0", "Hello", null},
|
||||
{"1.0", "com.other/com.other.Hello", null},
|
||||
@ -63,21 +67,48 @@ public final class AppVersionTest {
|
||||
// Ignore version in jar if --app-version given
|
||||
{"7.5.81", "com.other/com.other.Hello@3.10.17", new String[]{
|
||||
"--app-version", "7.5.81"}}
|
||||
});
|
||||
}));
|
||||
|
||||
// These are invalid version strings.
|
||||
// Don't need to test all invalid input as this is handled in
|
||||
// PlatformVersionTest unit test
|
||||
if (TKit.isWindows()) {
|
||||
data.addAll(List.of(new Object[][]{
|
||||
{null, "Hello", new String[]{"--app-version", "256"}}
|
||||
}));
|
||||
} else if (TKit.isOSX()) {
|
||||
data.addAll(List.of(new Object[][]{
|
||||
{null, "Hello", new String[]{"--app-version", "0.2"}}
|
||||
}));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public AppVersionTest(String expectedVersion, String javaAppDesc,
|
||||
String[] jpackageArgs) {
|
||||
this.expectedVersion = expectedVersion;
|
||||
|
||||
cmd = JPackageCommand.helloAppImage(javaAppDesc);
|
||||
if (jpackageArgs != null) {
|
||||
cmd.addArguments(jpackageArgs);
|
||||
}
|
||||
this.javaAppDesc = javaAppDesc;
|
||||
this.jpackageArgs = jpackageArgs;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
if (expectedVersion == null) {
|
||||
new PackageTest()
|
||||
.setExpectedExitCode(1)
|
||||
.configureHelloApp(javaAppDesc)
|
||||
.addInitializer(cmd -> {
|
||||
cmd.addArguments(jpackageArgs);
|
||||
})
|
||||
.run();
|
||||
return;
|
||||
}
|
||||
|
||||
JPackageCommand cmd = JPackageCommand.helloAppImage(javaAppDesc);
|
||||
if (jpackageArgs != null) {
|
||||
cmd.addArguments(jpackageArgs);
|
||||
}
|
||||
cmd.executeAndAssertHelloAppImageCreated();
|
||||
String actualVersion = cmd.readLaunherCfgFile().getValue("Application",
|
||||
"app.version");
|
||||
@ -86,5 +117,6 @@ public final class AppVersionTest {
|
||||
}
|
||||
|
||||
private final String expectedVersion;
|
||||
private final JPackageCommand cmd;
|
||||
private final String javaAppDesc;
|
||||
private final String[] jpackageArgs;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user