8208522: removed unreferenced class and minor formatting of java source
Reviewed-by: almatvee
--- a/src/jdk.packager.services/share/classes/jdk/packager/services/UserJvmOptionsService.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager.services/share/classes/jdk/packager/services/UserJvmOptionsService.java Mon Aug 27 16:01:38 2018 -0400
@@ -50,7 +50,8 @@
* @return the instance of UserJvmOptionsService for your application.
*/
static UserJvmOptionsService getUserJVMDefaults() {
- ServiceLoader<UserJvmOptionsService> loader = ServiceLoader.load(UserJvmOptionsService.class);
+ ServiceLoader<UserJvmOptionsService> loader =
+ ServiceLoader.load(UserJvmOptionsService.class);
Iterator<UserJvmOptionsService> iter = loader.iterator();
if (iter.hasNext()) {
return iter.next();
--- a/src/jdk.packager.services/share/classes/jdk/packager/services/singleton/SingleInstanceImpl.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager.services/share/classes/jdk/packager/services/singleton/SingleInstanceImpl.java Mon Aug 27 16:01:38 2018 -0400
@@ -56,7 +56,8 @@
static final String SI_STOP = "javapackager.singleinstance.stop";
static final String SI_EOF = "javapackager.singleinstance.EOF";
- private final ArrayList<SingleInstanceListener> siListeners = new ArrayList<>();
+ private final ArrayList<SingleInstanceListener> siListeners =
+ new ArrayList<>();
private SingleInstanceServer siServer;
private static final SecureRandom random = new SecureRandom();
@@ -79,7 +80,8 @@
} else if (os.contains("mac") || os.contains("os x")) {
return System.getProperty("user.home")
+ "/Library/Application Support/Oracle/Java/Packager/tmp";
- } else if (os.contains("nix") || os.contains("nux") || os.contains("aix")) {
+ } else if (os.contains("nix") || os.contains("nux")
+ || os.contains("aix")) {
return System.getProperty("user.home") + "/.java/packager/tmp";
}
@@ -101,7 +103,8 @@
siServer = new SingleInstanceServer(id);
siServer.start();
} catch (Exception e) {
- SingleInstanceService.trace("addSingleInstanceListener failed");
+ SingleInstanceService.trace(
+ "addSingleInstanceListener failed");
SingleInstanceService.trace(e);
return; // didn't start
}
@@ -123,8 +126,10 @@
private final SingleInstanceServerRunnable runnable;
private final Thread thread;
- SingleInstanceServer(SingleInstanceServerRunnable runnable) throws IOException {
- thread = new Thread(null, runnable, "JavaPackagerSIThread", 0, false);
+ SingleInstanceServer(SingleInstanceServerRunnable runnable)
+ throws IOException {
+ thread = new Thread(null, runnable, "JavaPackagerSIThread",
+ 0, false);
thread.setDaemon(true);
this.runnable = runnable;
}
@@ -167,12 +172,14 @@
port = ss.getLocalPort();
SingleInstanceService.trace("server port at: " + port);
- // create the single instance file with canonical home and port number
+ // create the single instance file with canonical home and port num
createSingleInstanceFile(stringId, port);
}
- private String getSingleInstanceFilename(final String id, final int port) {
- String name = SI_FILEDIR + getSingleInstanceFilePrefix(id) + "_" + port;
+ private String getSingleInstanceFilename(final String id,
+ final int port) {
+ String name = SI_FILEDIR + getSingleInstanceFilePrefix(id)
+ + "_" + port;
SingleInstanceService.trace("getSingleInstanceFilename: " + name);
return name;
}
@@ -195,10 +202,11 @@
if (fList != null) {
String prefix = getSingleInstanceFilePrefix(id);
for (String file : fList) {
- // if file with the same prefix already exist, remove it
+ // if file with the same prefix exist, remove it
if (file.startsWith(prefix)) {
SingleInstanceService.trace(
- "file should be removed: " + SI_FILEDIR + file);
+ "file should be removed: "
+ + SI_FILEDIR + file);
new File(SI_FILEDIR + file).delete();
}
}
@@ -248,19 +256,24 @@
is = s.getInputStream();
// read first byte for encoding type
int encoding = is.read();
- if (encoding == SingleInstanceService.ENCODING_PLATFORM) {
+ if (encoding ==
+ SingleInstanceService.ENCODING_PLATFORM) {
charset = Charset.defaultCharset().name();
- } else if (encoding == SingleInstanceService.ENCODING_UNICODE) {
- charset = SingleInstanceService.ENCODING_UNICODE_NAME;
+ } else if (encoding ==
+ SingleInstanceService.ENCODING_UNICODE) {
+ charset =
+ SingleInstanceService.ENCODING_UNICODE_NAME;
} else {
- SingleInstanceService.trace("SingleInstanceImpl - unknown encoding");
+ SingleInstanceService.trace(
+ "SingleInstanceImpl - unknown encoding");
return null;
}
isr = new InputStreamReader(is, charset);
in = new BufferedReader(isr);
// first read the random number
line = in.readLine();
- if (line.equals(String.valueOf(randomNumber)) == false) {
+ if (line.equals(String.valueOf(randomNumber)) ==
+ false) {
// random number does not match
// should not happen
// shutdown server socket
@@ -276,12 +289,14 @@
// did not come first
SingleInstanceService.trace("recv: " + line);
if (line.equals(SI_MAGICWORD)) {
- SingleInstanceService.trace("got magic word.");
+ SingleInstanceService.trace(
+ "got magic word.");
while (true) {
// Get input string
try {
line = in.readLine();
- if (line != null && line.equals(SI_EOF)) {
+ if (line != null
+ && line.equals(SI_EOF)) {
// end of file reached
break;
} else {
@@ -291,7 +306,8 @@
SingleInstanceService.trace(ioe);
}
}
- arguments = recvArgs.toArray(new String[recvArgs.size()]);
+ arguments = recvArgs.toArray(
+ new String[recvArgs.size()]);
sendAck = true;
} else if (line.equals(SI_STOP)) {
// remove the SingleInstance file
@@ -307,17 +323,21 @@
// let the action listener handle the rest
for (String arg : arguments) {
SingleInstanceService.trace(
- "Starting new instance with arguments: arg:" + arg);
+ "Starting new instance with "
+ + "arguments: arg:" + arg);
}
performNewActivation(arguments);
// now the event is handled, we can send
// out the ACK
- SingleInstanceService.trace("sending out ACK");
+ SingleInstanceService.trace(
+ "sending out ACK");
if (s != null) {
- try (OutputStream os = s.getOutputStream();
- PrintStream ps = new PrintStream(os, true, charset)) {
+ try (OutputStream os =
+ s.getOutputStream();
+ PrintStream ps = new PrintStream(os,
+ true, charset)) {
// send OK (ACK)
ps.println(SI_ACK);
ps.flush();
@@ -397,10 +417,12 @@
PrintStream out = null;
OutputStream os = null;
try {
- socket = new Socket("127.0.0.1", siServer.getPort());
+ socket = new Socket("127.0.0.1",
+ siServer.getPort());
os = socket.getOutputStream();
byte[] encoding = new byte[1];
- encoding[0] = SingleInstanceService.ENCODING_PLATFORM;
+ encoding[0] =
+ SingleInstanceService.ENCODING_PLATFORM;
os.write(encoding);
String charset = Charset.defaultCharset().name();
out = new PrintStream(os, true, charset);
--- a/src/jdk.packager.services/share/classes/jdk/packager/services/singleton/SingleInstanceService.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager.services/share/classes/jdk/packager/services/singleton/SingleInstanceService.java Mon Aug 27 16:01:38 2018 -0400
@@ -87,7 +87,8 @@
*
* @param slistener the listener to handle the single instance behaviour.
*/
- public static void registerSingleInstance(SingleInstanceListener slistener) {
+ public static void registerSingleInstance(
+ SingleInstanceListener slistener) {
registerSingleInstance(slistener, false);
}
@@ -108,7 +109,7 @@
}
static void registerSingleInstanceForId(SingleInstanceListener slistener,
- String stringId, boolean setFileHandler) {
+ String stringId, boolean setFileHandler) {
// register SingleInstanceListener for given Id
instance = new SingleInstanceImpl();
instance.addSingleInstanceListener(slistener, stringId);
@@ -124,7 +125,8 @@
*
* @param slistener the listener for unregistering.
*/
- public static void unregisterSingleInstance(SingleInstanceListener slistener) {
+ public static void unregisterSingleInstance(
+ SingleInstanceListener slistener) {
instance.removeSingleInstanceListener(slistener);
}
@@ -146,9 +148,11 @@
try {
currPort = Integer.parseInt(
file.substring(file.lastIndexOf('_') + 1));
- trace("isServerRunning: " + file + ": port: " + currPort);
+ trace("isServerRunning: " + file
+ + ": port: " + currPort);
} catch (NumberFormatException nfe) {
- trace("isServerRunning: " + file + ": port parsing failed");
+ trace("isServerRunning: " + file
+ + ": port parsing failed");
trace(nfe);
return false;
}
@@ -157,11 +161,14 @@
File siFile = new File(SingleInstanceImpl.SI_FILEDIR, file);
// get random number from single instance file
- try (BufferedReader br = new BufferedReader(new FileReader(siFile))) {
+ try (BufferedReader br = new BufferedReader(
+ new FileReader(siFile))) {
randomNumberString = br.readLine();
- trace("isServerRunning: " + file + ": magic: " + randomNumberString);
+ trace("isServerRunning: " + file + ": magic: "
+ + randomNumberString);
} catch (IOException ioe ) {
- trace("isServerRunning: " + file + ": reading magic failed");
+ trace("isServerRunning: " + file
+ + ": reading magic failed");
trace(ioe);
}
trace("isServerRunning: " + file + ": setting id - OK");
--- a/src/jdk.packager.services/share/classes/jdk/packager/services/userjvmoptions/LauncherUserJvmOptions.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager.services/share/classes/jdk/packager/services/userjvmoptions/LauncherUserJvmOptions.java Mon Aug 27 16:01:38 2018 -0400
@@ -108,7 +108,8 @@
* @param options the keys for the User JVM Options
* @param values the values for the User JVM Options
*/
- private static native void _setUserJvmKeysAndValues(String[] options, String[] values);
+ private static native void _setUserJvmKeysAndValues(String[] options,
+ String[] values);
/**
* This lists the keys for all User JVM Options that will be used by the
@@ -143,12 +144,15 @@
for (Map.Entry<String, String> option : options.entrySet()) {
if (option.getKey() == null) {
throw new IllegalArgumentException(
- "For Launcher Backed UserJVMOptions keys in the UserJVMOptions map cannot be null.");
+ "For Launcher Backed UserJVMOptions keys in the "
+ + "UserJVMOptions map cannot be null.");
}
if (option.getValue() == null) {
throw new IllegalArgumentException(
- "For Launcher Backed UserJVMOptions values in the UserJVMOptions map cannot be null. "
- + " Keys are removed by absence, not by setting keys to null.");
+ "For Launcher Backed UserJVMOptions values in the "
+ + "UserJVMOptions map cannot be null. Keys are "
+ + "removed by absence, not by setting keys to null."
+ );
}
keys.add(option.getKey());
values.add(option.getValue());
--- a/src/jdk.packager.services/share/classes/jdk/packager/services/userjvmoptions/PreferencesUserJvmOptions.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager.services/share/classes/jdk/packager/services/userjvmoptions/PreferencesUserJvmOptions.java Mon Aug 27 16:01:38 2018 -0400
@@ -44,7 +44,7 @@
final public class PreferencesUserJvmOptions implements UserJvmOptionsService {
Preferences node = Preferences.userRoot().node(System.getProperty(
- "app.preferences.id").replace(".", "/")).node("JVMUserOptions");
+ "app.preferences.id").replace(".", "/")).node("JVMUserOptions");
@Override
public Map<String, String> getUserJVMOptions() {
@@ -78,6 +78,6 @@
@Override
public Map<String, String> getUserJVMOptionDefaults() {
throw new UnsupportedOperationException(
- "Preferences backed UserJvmOptions do not enumerate their defaults");
+ "Preferences backed UserJvmOptions do not enumerate their defaults");
}
}
--- a/src/jdk.packager/linux/classes/jdk/packager/internal/builders/linux/LinuxAppImageBuilder.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/linux/classes/jdk/packager/internal/builders/linux/LinuxAppImageBuilder.java Mon Aug 27 16:01:38 2018 -0400
@@ -58,8 +58,8 @@
public class LinuxAppImageBuilder extends AbstractAppImageBuilder {
- private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.builders.linux.LinuxAppImageBuilder");
+ private static final ResourceBundle I18N = ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.builders.linux.LinuxAppImageBuilder");
protected static final String LINUX_BUNDLER_PREFIX =
BUNDLER_PREFIX + "linux" + File.separator;
@@ -74,7 +74,8 @@
private final Map<String, ? super Object> params;
- public static final BundlerParamInfo<File> ICON_PNG = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> ICON_PNG =
+ new StandardBundlerParam<>(
I18N.getString("param.icon-png.name"),
I18N.getString("param.icon-png.description"),
"icon.png",
@@ -82,15 +83,18 @@
params -> {
File f = ICON.fetchFrom(params);
if (f != null && !f.getName().toLowerCase().endsWith(".png")) {
- Log.info(MessageFormat.format(I18N.getString("message.icon-not-png"), f));
+ Log.info(MessageFormat.format(I18N.getString(
+ "message.icon-not-png"), f));
return null;
}
return f;
},
(s, p) -> new File(s));
- public LinuxAppImageBuilder(Map<String, Object> config, Path imageOutDir) throws IOException {
- super(config, imageOutDir.resolve(APP_NAME.fetchFrom(config) + "/runtime"));
+ public LinuxAppImageBuilder(Map<String, Object> config, Path imageOutDir)
+ throws IOException {
+ super(config,
+ imageOutDir.resolve(APP_NAME.fetchFrom(config) + "/runtime"));
Objects.requireNonNull(imageOutDir);
@@ -100,13 +104,15 @@
this.resourcesDir = root.resolve("resources");
this.mdir = runtimeDir.resolve("lib");
this.params = new HashMap<>();
- config.entrySet().stream().forEach(e -> params.put(e.getKey().toString(), e.getValue()));
+ config.entrySet().stream().forEach(e -> params.put(
+ e.getKey().toString(), e.getValue()));
Files.createDirectories(appDir);
Files.createDirectories(runtimeDir);
Files.createDirectories(resourcesDir);
}
- public LinuxAppImageBuilder(String appName, Path imageOutDir) throws IOException {
+ public LinuxAppImageBuilder(String appName, Path imageOutDir)
+ throws IOException {
super(null, imageOutDir.resolve(appName));
Objects.requireNonNull(imageOutDir);
@@ -138,7 +144,8 @@
*/
private void setExecutable(Path file) {
try {
- Set<PosixFilePermission> perms = Files.getPosixFilePermissions(file);
+ Set<PosixFilePermission> perms =
+ Files.getPosixFilePermissions(file);
perms.add(PosixFilePermission.OWNER_EXECUTE);
perms.add(PosixFilePermission.GROUP_EXECUTE);
perms.add(PosixFilePermission.OTHERS_EXECUTE);
@@ -148,9 +155,10 @@
}
}
- private static void createUtf8File(File file, String content) throws IOException {
+ private static void createUtf8File(File file, String content)
+ throws IOException {
try (OutputStream fout = new FileOutputStream(file);
- Writer output = new OutputStreamWriter(fout, "UTF-8")) {
+ Writer output = new OutputStreamWriter(fout, "UTF-8")) {
output.write(content);
}
}
@@ -189,7 +197,8 @@
}
// create the secondary launchers, if any
- List<Map<String, ? super Object>> entryPoints = StandardBundlerParam.SECONDARY_LAUNCHERS.fetchFrom(params);
+ List<Map<String, ? super Object>> entryPoints =
+ StandardBundlerParam.SECONDARY_LAUNCHERS.fetchFrom(params);
for (Map<String, ? super Object> entryPoint : entryPoints) {
Map<String, ? super Object> tmp = new HashMap<>(originalParams);
tmp.putAll(entryPoint);
@@ -214,7 +223,8 @@
@Override
public void prepareServerJreFiles() throws IOException {}
- private void createLauncherForEntryPoint(Map<String, ? super Object> p, Path rootDir) throws IOException {
+ private void createLauncherForEntryPoint(Map<String, ? super Object> p,
+ Path rootDir) throws IOException {
// Copy executable to Linux folder
Path executableFile = root.resolve(getLauncherName(p));
try (InputStream is_launcher = getResourceAsStream("papplauncher")) {
@@ -224,19 +234,22 @@
executableFile.toFile().setExecutable(true, false);
executableFile.toFile().setWritable(true, true);
- writeCfgFile(p, root.resolve(getLauncherCfgName(p)).toFile(), "$APPDIR/runtime");
+ writeCfgFile(p, root.resolve(getLauncherCfgName(p)).toFile(),
+ "$APPDIR/runtime");
}
private void copyIcon() throws IOException {
File icon = ICON_PNG.fetchFrom(params);
if (icon != null) {
- File iconTarget = new File(resourcesDir.toFile(), APP_FS_NAME.fetchFrom(params) + ".png");
+ File iconTarget = new File(resourcesDir.toFile(),
+ APP_FS_NAME.fetchFrom(params) + ".png");
IOUtils.copyFile(icon, iconTarget);
}
}
private void copyApplication() throws IOException {
- List<RelativeFileSet> appResourcesList = APP_RESOURCES_LIST.fetchFrom(params);
+ List<RelativeFileSet> appResourcesList =
+ APP_RESOURCES_LIST.fetchFrom(params);
if (appResourcesList == null) {
throw new RuntimeException("Null app resources?");
}
--- a/src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxAppBundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxAppBundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -59,13 +59,15 @@
public class LinuxAppBundler extends AbstractImageBundler {
private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.linux.LinuxAppBundler");
+ ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.linux.LinuxAppBundler");
protected static final String LINUX_BUNDLER_PREFIX =
BUNDLER_PREFIX + "linux" + File.separator;
private static final String EXECUTABLE_NAME = "JavaAppLauncher";
- public static final BundlerParamInfo<File> ICON_PNG = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> ICON_PNG =
+ new StandardBundlerParam<>(
I18N.getString("param.icon-png.name"),
I18N.getString("param.icon-png.description"),
"icon.png",
@@ -73,14 +75,16 @@
params -> {
File f = ICON.fetchFrom(params);
if (f != null && !f.getName().toLowerCase().endsWith(".png")) {
- Log.info(MessageFormat.format(I18N.getString("message.icon-not-png"), f));
+ Log.info(MessageFormat.format(
+ I18N.getString("message.icon-not-png"), f));
return null;
}
return f;
},
(s, p) -> new File(s));
- public static final BundlerParamInfo<URL> RAW_EXECUTABLE_URL = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<URL> RAW_EXECUTABLE_URL =
+ new StandardBundlerParam<>(
I18N.getString("param.raw-executable-url.name"),
I18N.getString("param.raw-executable-url.description"),
"linux.launcher.url",
@@ -99,7 +103,8 @@
//JRE README defines what is allowed to strip:
// http://www.oracle.com/technetwork/java/javase/jre-8-readme-2095710.html
//
- public static final BundlerParamInfo<Rule[]> LINUX_JRE_RULES = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<Rule[]> LINUX_JRE_RULES =
+ new StandardBundlerParam<>(
"",
"",
".linux.runtime.rules",
@@ -107,7 +112,8 @@
params -> new Rule[]{
Rule.prefixNeg("/bin"),
Rule.prefixNeg("/plugin"),
- //Rule.prefixNeg("/lib/ext"), //need some of jars there for https to work
+ //Rule.prefixNeg("/lib/ext"),
+ //need some of jars there for https to work
Rule.suffix("deploy.jar"), //take deploy.jar
Rule.prefixNeg("/lib/deploy"),
Rule.prefixNeg("/lib/desktop"),
@@ -116,14 +122,17 @@
(s, p) -> null
);
- public static final BundlerParamInfo<RelativeFileSet> LINUX_RUNTIME = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<RelativeFileSet> LINUX_RUNTIME =
+ new StandardBundlerParam<>(
I18N.getString("param.runtime.name"),
I18N.getString("param.runtime.description"),
BundleParams.PARAM_RUNTIME,
RelativeFileSet.class,
- params -> JreUtils.extractJreAsRelativeFileSet(System.getProperty("java.home"),
+ params -> JreUtils.extractJreAsRelativeFileSet(
+ System.getProperty("java.home"),
LINUX_JRE_RULES.fetchFrom(params)),
- (s, p) -> JreUtils.extractJreAsRelativeFileSet(s, LINUX_JRE_RULES.fetchFrom(p))
+ (s, p) -> JreUtils.extractJreAsRelativeFileSet(s,
+ LINUX_JRE_RULES.fetchFrom(p))
);
public static final BundlerParamInfo<String> LINUX_INSTALL_DIR =
@@ -158,7 +167,8 @@
);
@Override
- public boolean validate(Map<String, ? super Object> p) throws UnsupportedPlatformException, ConfigException {
+ public boolean validate(Map<String, ? super Object> p)
+ throws UnsupportedPlatformException, ConfigException {
try {
if (p == null) throw new ConfigException(
I18N.getString("error.parameters-null"),
@@ -175,7 +185,8 @@
}
//used by chained bundlers to reuse validation logic
- boolean doValidate(Map<String, ? super Object> p) throws UnsupportedPlatformException, ConfigException {
+ boolean doValidate(Map<String, ? super Object> p)
+ throws UnsupportedPlatformException, ConfigException {
if (Platform.getPlatform() != Platform.LINUX) {
throw new UnsupportedPlatformException();
}
@@ -195,7 +206,8 @@
return "app/" + APP_FS_NAME.fetchFrom(p) +".cfg";
}
- File doBundle(Map<String, ? super Object> p, File outputDirectory, boolean dependentTask) {
+ File doBundle(Map<String, ? super Object> p, File outputDirectory,
+ boolean dependentTask) {
if (Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) {
return doJreBundle(p, outputDirectory, dependentTask);
} else {
@@ -203,7 +215,8 @@
}
}
- private File doJreBundle(Map<String, ? super Object> p, File outputDirectory, boolean dependentTask) {
+ private File doJreBundle(Map<String, ? super Object> p,
+ File outputDirectory, boolean dependentTask) {
try {
File rootDirectory = createRoot(p, outputDirectory, dependentTask);
AbstractAppImageBuilder appBuilder = new LinuxAppImageBuilder(
@@ -226,10 +239,12 @@
}
}
- private File doAppBundle(Map<String, ? super Object> p, File outputDirectory, boolean dependentTask) {
+ private File doAppBundle(Map<String, ? super Object> p,
+ File outputDirectory, boolean dependentTask) {
try {
File rootDirectory = createRoot(p, outputDirectory, dependentTask);
- AbstractAppImageBuilder appBuilder = new LinuxAppImageBuilder(p, outputDirectory.toPath());
+ AbstractAppImageBuilder appBuilder = new LinuxAppImageBuilder(p,
+ outputDirectory.toPath());
if (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null ) {
JLinkBundlerHelper.execute(p, appBuilder);
} else {
@@ -266,11 +281,14 @@
rootDirectory.mkdirs();
if (!dependentTask) {
- Log.info(MessageFormat.format(I18N.getString("message.creating-bundle-location"), rootDirectory.getAbsolutePath()));
+ Log.info(MessageFormat.format(I18N.getString(
+ "message.creating-bundle-location"),
+ rootDirectory.getAbsolutePath()));
}
if (!p.containsKey(JLinkBundlerHelper.JLINK_BUILDER.getID())) {
- p.put(JLinkBundlerHelper.JLINK_BUILDER.getID(), "linuxapp-image-builder");
+ p.put(JLinkBundlerHelper.JLINK_BUILDER.getID(),
+ "linuxapp-image-builder");
}
return rootDirectory;
@@ -321,7 +339,8 @@
}
@Override
- public File execute(Map<String, ? super Object> params, File outputParentDir) {
+ public File execute(Map<String, ? super Object> params,
+ File outputParentDir) {
return doBundle(params, outputParentDir, false);
}
--- a/src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxDebBundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxDebBundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -45,14 +45,17 @@
import static jdk.packager.internal.StandardBundlerParam.*;
import static jdk.packager.internal.linux.LinuxAppBundler.ICON_PNG;
import static jdk.packager.internal.linux.LinuxAppBundler.LINUX_INSTALL_DIR;
-import static jdk.packager.internal.linux.LinuxAppBundler.LINUX_PACKAGE_DEPENDENCIES;
+import static
+ jdk.packager.internal.linux.LinuxAppBundler.LINUX_PACKAGE_DEPENDENCIES;
public class LinuxDebBundler extends AbstractBundler {
private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.linux.LinuxDebBundler");
+ ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.linux.LinuxDebBundler");
- public static final BundlerParamInfo<LinuxAppBundler> APP_BUNDLER = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<LinuxAppBundler> APP_BUNDLER =
+ new StandardBundlerParam<>(
I18N.getString("param.app-bundler.name"),
I18N.getString("param.app-bundler.description"),
"linux.app.bundler",
@@ -65,12 +68,14 @@
//
// Package names must consist only of lower case letters (a-z), digits (0-9),
// plus (+) and minus (-) signs, and periods (.).
- // They must be at least two characters long and must start with an alphanumeric character.
+ // They must be at least two characters long and
+ // must start with an alphanumeric character.
//
private static final Pattern DEB_BUNDLE_NAME_PATTERN =
Pattern.compile("^[a-z][a-z\\d\\+\\-\\.]+");
- public static final BundlerParamInfo<String> BUNDLE_NAME = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<String> BUNDLE_NAME =
+ new StandardBundlerParam<> (
I18N.getString("param.bundle-name.name"),
I18N.getString("param.bundle-name.description"),
Arguments.CLIOptions.LINUX_BUNDLE_NAME.getId(),
@@ -86,24 +91,28 @@
},
(s, p) -> {
if (!DEB_BUNDLE_NAME_PATTERN.matcher(s).matches()) {
- throw new IllegalArgumentException(
- new ConfigException(
- MessageFormat.format(I18N.getString("error.invalid-value-for-package-name"), s),
- I18N.getString("error.invalid-value-for-package-name.advice")));
+ throw new IllegalArgumentException(new ConfigException(
+ MessageFormat.format(I18N.getString(
+ "error.invalid-value-for-package-name"), s),
+ I18N.getString(
+ "error.invalid-value-for-package-name.advice")));
}
return s;
});
- public static final BundlerParamInfo<String> FULL_PACKAGE_NAME = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<String> FULL_PACKAGE_NAME =
+ new StandardBundlerParam<> (
I18N.getString("param.full-package-name.name"),
I18N.getString("param.full-package-name.description"),
"linux.deb.fullPackageName",
String.class,
- params -> BUNDLE_NAME.fetchFrom(params) + "-" + VERSION.fetchFrom(params),
+ params -> BUNDLE_NAME.fetchFrom(params) + "-"
+ + VERSION.fetchFrom(params),
(s, p) -> s);
- public static final BundlerParamInfo<File> CONFIG_ROOT = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> CONFIG_ROOT =
+ new StandardBundlerParam<>(
I18N.getString("param.config-root.name"),
I18N.getString("param.config-root.description"),
"configRoot",
@@ -111,7 +120,8 @@
params -> new File(BUILD_ROOT.fetchFrom(params), "linux"),
(s, p) -> new File(s));
- public static final BundlerParamInfo<File> DEB_IMAGE_DIR = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> DEB_IMAGE_DIR =
+ new StandardBundlerParam<>(
I18N.getString("param.image-dir.name"),
I18N.getString("param.image-dir.description"),
"linux.deb.imageDir",
@@ -119,11 +129,13 @@
params -> {
File imagesRoot = IMAGES_ROOT.fetchFrom(params);
if (!imagesRoot.exists()) imagesRoot.mkdirs();
- return new File(new File(imagesRoot, "linux-deb.image"), FULL_PACKAGE_NAME.fetchFrom(params));
+ return new File(new File(imagesRoot, "linux-deb.image"),
+ FULL_PACKAGE_NAME.fetchFrom(params));
},
(s, p) -> new File(s));
- public static final BundlerParamInfo<File> APP_IMAGE_ROOT = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> APP_IMAGE_ROOT =
+ new StandardBundlerParam<>(
I18N.getString("param.app-image-root.name"),
I18N.getString("param.app-image-root.description"),
"linux.deb.imageRoot",
@@ -134,7 +146,8 @@
},
(s, p) -> new File(s));
- public static final BundlerParamInfo<File> CONFIG_DIR = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> CONFIG_DIR =
+ new StandardBundlerParam<>(
I18N.getString("param.config-dir.name"),
I18N.getString("param.config-dir.description"),
"linux.deb.configDir",
@@ -142,7 +155,8 @@
params -> new File(DEB_IMAGE_DIR.fetchFrom(params), "DEBIAN"),
(s, p) -> new File(s));
- public static final BundlerParamInfo<String> EMAIL = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<String> EMAIL =
+ new StandardBundlerParam<> (
I18N.getString("param.maintainer-email.name"),
I18N.getString("param.maintainer-email.description"),
BundleParams.PARAM_EMAIL,
@@ -150,15 +164,18 @@
params -> "Unknown",
(s, p) -> s);
- public static final BundlerParamInfo<String> MAINTAINER = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<String> MAINTAINER =
+ new StandardBundlerParam<> (
I18N.getString("param.maintainer-name.name"),
I18N.getString("param.maintainer-name.description"),
Arguments.CLIOptions.LINUX_DEB_MAINTAINER.getId(),
String.class,
- params -> VENDOR.fetchFrom(params) + " <" + EMAIL.fetchFrom(params) + ">",
+ params -> VENDOR.fetchFrom(params) + " <"
+ + EMAIL.fetchFrom(params) + ">",
(s, p) -> s);
- public static final BundlerParamInfo<String> LICENSE_TEXT = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<String> LICENSE_TEXT =
+ new StandardBundlerParam<> (
I18N.getString("param.license-text.name"),
I18N.getString("param.license-text.description"),
"linux.deb.licenseText",
@@ -171,9 +188,12 @@
if (licenseFiles.size() > 0) {
String licFileStr = licenseFiles.get(0);
- for (RelativeFileSet rfs : APP_RESOURCES_LIST.fetchFrom(params)) {
+ for (RelativeFileSet rfs :
+ APP_RESOURCES_LIST.fetchFrom(params)) {
if (rfs.contains(licFileStr)) {
- return new String(IOUtils.readFully(new File(rfs.getBaseDirectory(), licFileStr)));
+ return new String(IOUtils.readFully(
+ new File(rfs.getBaseDirectory(),
+ licFileStr)));
}
}
}
@@ -186,7 +206,8 @@
},
(s, p) -> s);
- public static final BundlerParamInfo<String> XDG_FILE_PREFIX = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<String> XDG_FILE_PREFIX =
+ new StandardBundlerParam<> (
I18N.getString("param.xdg-prefix.name"),
I18N.getString("param.xdg-prefix.description"),
"linux.xdg-prefix",
@@ -214,11 +235,15 @@
private final static String DEFAULT_ICON = "javalogo_white_32.png";
private final static String DEFAULT_CONTROL_TEMPLATE = "template.control";
private final static String DEFAULT_PRERM_TEMPLATE = "template.prerm";
- private final static String DEFAULT_PREINSTALL_TEMPLATE = "template.preinst";
+ private final static String DEFAULT_PREINSTALL_TEMPLATE =
+ "template.preinst";
private final static String DEFAULT_POSTRM_TEMPLATE = "template.postrm";
- private final static String DEFAULT_POSTINSTALL_TEMPLATE = "template.postinst";
- private final static String DEFAULT_COPYRIGHT_TEMPLATE = "template.copyright";
- private final static String DEFAULT_DESKTOP_FILE_TEMPLATE = "template.desktop";
+ private final static String DEFAULT_POSTINSTALL_TEMPLATE =
+ "template.postinst";
+ private final static String DEFAULT_COPYRIGHT_TEMPLATE =
+ "template.copyright";
+ private final static String DEFAULT_DESKTOP_FILE_TEMPLATE =
+ "template.desktop";
public final static String TOOL_DPKG = "dpkg-deb";
@@ -232,16 +257,19 @@
ProcessBuilder pb = new ProcessBuilder(
toolName,
"--version");
- IOUtils.exec(pb, Log.isDebug(), true); //FIXME not interested in the output
+ // not interested in the output
+ IOUtils.exec(pb, Log.isDebug(), true);
} catch (Exception e) {
- Log.verbose(MessageFormat.format(I18N.getString("message.test-for-tool"), toolName, e.getMessage()));
+ Log.verbose(MessageFormat.format(I18N.getString(
+ "message.test-for-tool"), toolName, e.getMessage()));
return false;
}
return true;
}
@Override
- public boolean validate(Map<String, ? super Object> p) throws UnsupportedPlatformException, ConfigException {
+ public boolean validate(Map<String, ? super Object> p)
+ throws UnsupportedPlatformException, ConfigException {
try {
if (p == null) throw new ConfigException(
I18N.getString("error.parameters-null"),
@@ -251,17 +279,19 @@
//we are not interested in return code, only possible exception
APP_BUNDLER.fetchFrom(p).doValidate(p);
- //NOTE: Can we validate that the required tools are available before we start?
+ // NOTE: Can we validate that the required tools are available
+ // before we start?
if (!testTool(TOOL_DPKG, "1")){
- throw new ConfigException(
- MessageFormat.format(I18N.getString("error.tool-not-found"), TOOL_DPKG),
+ throw new ConfigException(MessageFormat.format(
+ I18N.getString("error.tool-not-found"), TOOL_DPKG),
I18N.getString("error.tool-not-found.advice"));
}
// validate license file, if used, exists in the proper place
if (p.containsKey(LICENSE_FILE.getID())) {
- List<RelativeFileSet> appResourcesList = APP_RESOURCES_LIST.fetchFrom(p);
+ List<RelativeFileSet> appResourcesList =
+ APP_RESOURCES_LIST.fetchFrom(p);
for (String license : LICENSE_FILE.fetchFrom(p)) {
boolean found = false;
for (RelativeFileSet appResources : appResourcesList) {
@@ -270,7 +300,8 @@
if (!found) {
throw new ConfigException(
I18N.getString("error.license-missing"),
- MessageFormat.format(I18N.getString("error.license-missing.advice"),
+ MessageFormat.format(I18N.getString(
+ "error.license-missing.advice"),
license));
}
}
@@ -279,19 +310,25 @@
}
// only one mime type per association, at least one file extention
- List<Map<String, ? super Object>> associations = FILE_ASSOCIATIONS.fetchFrom(p);
+ 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 == null || mimes.isEmpty()) {
+ String msgKey =
+ "error.no-content-types-for-file-association";
throw new ConfigException(
- MessageFormat.format(I18N.getString("error.no-content-types-for-file-association"), i),
- I18N.getString("error.no-content-types-for-file-association.advice"));
+ MessageFormat.format(I18N.getString(msgKey), i),
+ I18N.getString(msgKey + ".advise"));
+
} else if (mimes.size() > 1) {
+ String msgKey =
+ "error.too-many-content-types-for-file-association";
throw new ConfigException(
- MessageFormat.format(I18N.getString("error.too-many-content-types-for-file-association"), i),
- I18N.getString("error.too-many-content-types-for-file-association.advice"));
+ MessageFormat.format(I18N.getString(msgKey), i),
+ I18N.getString(msgKey + ".advise"));
}
}
}
@@ -322,10 +359,14 @@
//@Override
public File bundle(Map<String, ? super Object> p, File outdir) {
if (!outdir.isDirectory() && !outdir.mkdirs()) {
- throw new RuntimeException(MessageFormat.format(I18N.getString("error.cannot-create-output-dir"), outdir.getAbsolutePath()));
+ throw new RuntimeException(MessageFormat.format(
+ I18N.getString("error.cannot-create-output-dir"),
+ outdir.getAbsolutePath()));
}
if (!outdir.canWrite()) {
- throw new RuntimeException(MessageFormat.format(I18N.getString("error.cannot-write-to-output-dir"), outdir.getAbsolutePath()));
+ throw new RuntimeException(MessageFormat.format(
+ I18N.getString("error.cannot-write-to-output-dir"),
+ outdir.getAbsolutePath()));
}
//we want to create following structure
@@ -359,12 +400,16 @@
if (ECHO_MODE.fetchFrom(p)) {
saveConfigFiles(p);
}
- if (imageDir != null && PREDEFINED_APP_IMAGE.fetchFrom(p) == null &&
- (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null || !Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) && !Log.isDebug()) {
+ if (imageDir != null &&
+ PREDEFINED_APP_IMAGE.fetchFrom(p) == null &&
+ (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null ||
+ !Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) &&
+ !Log.isDebug()) {
IOUtils.deleteRecursive(imageDir);
} else if (imageDir != null) {
Log.info(MessageFormat.format(I18N.getString(
- "message.debug-working-directory"), imageDir.getAbsolutePath()));
+ "message.debug-working-directory"),
+ imageDir.getAbsolutePath()));
}
} catch (IOException ex) {
//noinspection ReturnInsideFinallyBlock
@@ -380,13 +425,15 @@
* This cannot be directly backport to 22u which is unfortunately built with 1.6
*/
private void setPermissions(File file, String permissions) {
- Set<PosixFilePermission> filePermissions = PosixFilePermissions.fromString(permissions);
+ Set<PosixFilePermission> filePermissions =
+ PosixFilePermissions.fromString(permissions);
try {
if (file.exists()) {
Files.setPosixFilePermissions(file.toPath(), filePermissions);
}
} catch (IOException ex) {
- Logger.getLogger(LinuxDebBundler.class.getName()).log(Level.SEVERE, null, ex);
+ Logger.getLogger(LinuxDebBundler.class.getName()).log(
+ Level.SEVERE, null, ex);
}
}
@@ -394,47 +441,64 @@
protected void saveConfigFiles(Map<String, ? super Object> params) {
try {
File configRoot = CONFIG_ROOT.fetchFrom(params);
- File rootDir = LinuxAppBundler.getRootDir(APP_IMAGE_ROOT.fetchFrom(params), params);
+ File rootDir = LinuxAppBundler.getRootDir(
+ APP_IMAGE_ROOT.fetchFrom(params), params);
if (getConfig_ControlFile(params).exists()) {
IOUtils.copyFile(getConfig_ControlFile(params),
- new File(configRoot, getConfig_ControlFile(params).getName()));
+ new File(configRoot,
+ getConfig_ControlFile(params).getName()));
}
if (getConfig_CopyrightFile(params).exists()) {
IOUtils.copyFile(getConfig_CopyrightFile(params),
- new File(configRoot, getConfig_CopyrightFile(params).getName()));
+ new File(configRoot,
+ getConfig_CopyrightFile(params).getName()));
}
if (getConfig_PreinstallFile(params).exists()) {
IOUtils.copyFile(getConfig_PreinstallFile(params),
- new File(configRoot, getConfig_PreinstallFile(params).getName()));
+ new File(configRoot,
+ getConfig_PreinstallFile(params).getName()));
}
if (getConfig_PrermFile(params).exists()) {
IOUtils.copyFile(getConfig_PrermFile(params),
- new File(configRoot, getConfig_PrermFile(params).getName()));
+ new File(configRoot,
+ getConfig_PrermFile(params).getName()));
}
if (getConfig_PostinstallFile(params).exists()) {
IOUtils.copyFile(getConfig_PostinstallFile(params),
- new File(configRoot, getConfig_PostinstallFile(params).getName()));
+ new File(configRoot,
+ getConfig_PostinstallFile(params).getName()));
}
if (getConfig_PostrmFile(params).exists()) {
IOUtils.copyFile(getConfig_PostrmFile(params),
- new File(configRoot, getConfig_PostrmFile(params).getName()));
+ new File(configRoot,
+ getConfig_PostrmFile(params).getName()));
}
if (getConfig_DesktopShortcutFile(rootDir, params).exists()) {
IOUtils.copyFile(getConfig_DesktopShortcutFile(rootDir, params),
- new File(configRoot, getConfig_DesktopShortcutFile(rootDir, params).getName()));
+ new File(configRoot,
+ getConfig_DesktopShortcutFile(rootDir,
+ params).getName()));
}
- for (Map<String, ? super Object> secondaryLauncher : SECONDARY_LAUNCHERS.fetchFrom(params)) {
- if (getConfig_DesktopShortcutFile(rootDir, secondaryLauncher).exists()) {
- IOUtils.copyFile(getConfig_DesktopShortcutFile(rootDir, secondaryLauncher),
- new File(configRoot, getConfig_DesktopShortcutFile(rootDir, secondaryLauncher).getName()));
+ for (Map<String, ? super Object> secondaryLauncher :
+ SECONDARY_LAUNCHERS.fetchFrom(params)) {
+ if (getConfig_DesktopShortcutFile(rootDir,
+ secondaryLauncher).exists()) {
+ IOUtils.copyFile(
+ getConfig_DesktopShortcutFile(rootDir,
+ secondaryLauncher),
+ new File(configRoot, getConfig_DesktopShortcutFile(
+ rootDir, secondaryLauncher).getName()));
}
}
if (getConfig_IconFile(rootDir, params).exists()) {
IOUtils.copyFile(getConfig_IconFile(rootDir, params),
- new File(configRoot, getConfig_IconFile(rootDir, params).getName()));
+ new File(configRoot,
+ getConfig_IconFile(rootDir, params).getName()));
}
- Log.info(MessageFormat.format(I18N.getString("message.config-save-location"), configRoot.getAbsolutePath()));
+ Log.info(MessageFormat.format(
+ I18N.getString("message.config-save-location"),
+ configRoot.getAbsolutePath()));
} catch (IOException ioe) {
ioe.printStackTrace();
}
@@ -468,23 +532,27 @@
return count;
}
- private boolean prepareProjectConfig(Map<String, ? super Object> params) throws IOException {
+ private boolean prepareProjectConfig(Map<String, ? super Object> params)
+ throws IOException {
Map<String, String> data = createReplacementData(params);
- File rootDir = LinuxAppBundler.getRootDir(APP_IMAGE_ROOT.fetchFrom(params), params);
+ File rootDir = LinuxAppBundler.getRootDir(APP_IMAGE_ROOT.fetchFrom(
+ params), params);
File iconTarget = getConfig_IconFile(rootDir, params);
File icon = ICON_PNG.fetchFrom(params);
if (!Arguments.CREATE_JRE_INSTALLER.fetchFrom(params)) {
// prepare installer icon
if (icon == null || !icon.exists()) {
- fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX + iconTarget.getName(),
+ fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + iconTarget.getName(),
I18N.getString("resource.menu-icon"),
DEFAULT_ICON,
iconTarget,
VERBOSE.fetchFrom(params),
DROP_IN_RESOURCES_ROOT.fetchFrom(params));
} else {
- fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX + iconTarget.getName(),
+ fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + iconTarget.getName(),
I18N.getString("resource.menu-icon"),
icon,
iconTarget,
@@ -495,16 +563,23 @@
StringBuilder installScripts = new StringBuilder();
StringBuilder removeScripts = new StringBuilder();
- for (Map<String, ? super Object> secondaryLauncher : SECONDARY_LAUNCHERS.fetchFrom(params)) {
- Map<String, String> secondaryLauncherData = createReplacementData(secondaryLauncher);
- secondaryLauncherData.put("APPLICATION_FS_NAME", data.get("APPLICATION_FS_NAME"));
+ for (Map<String, ? super Object> secondaryLauncher :
+ SECONDARY_LAUNCHERS.fetchFrom(params)) {
+ Map<String, String> secondaryLauncherData =
+ createReplacementData(secondaryLauncher);
+ secondaryLauncherData.put("APPLICATION_FS_NAME",
+ data.get("APPLICATION_FS_NAME"));
secondaryLauncherData.put("DESKTOP_MIMES", "");
if (!Arguments.CREATE_JRE_INSTALLER.fetchFrom(params)) {
// prepare desktop shortcut
- Writer w = new BufferedWriter(new FileWriter(getConfig_DesktopShortcutFile(rootDir, secondaryLauncher)));
+ Writer w = new BufferedWriter(new FileWriter(
+ getConfig_DesktopShortcutFile(
+ rootDir, secondaryLauncher)));
String content = preprocessTextResource(
- LinuxAppBundler.LINUX_BUNDLER_PREFIX + getConfig_DesktopShortcutFile(rootDir, secondaryLauncher).getName(),
+ LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + getConfig_DesktopShortcutFile(rootDir,
+ secondaryLauncher).getName(),
I18N.getString("resource.menu-shortcut-descriptor"),
DEFAULT_DESKTOP_FILE_TEMPLATE,
secondaryLauncherData,
@@ -518,14 +593,16 @@
iconTarget = getConfig_IconFile(rootDir, secondaryLauncher);
icon = ICON_PNG.fetchFrom(secondaryLauncher);
if (icon == null || !icon.exists()) {
- fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX + iconTarget.getName(),
+ fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + iconTarget.getName(),
I18N.getString("resource.menu-icon"),
DEFAULT_ICON,
iconTarget,
VERBOSE.fetchFrom(params),
DROP_IN_RESOURCES_ROOT.fetchFrom(params));
} else {
- fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX + iconTarget.getName(),
+ fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + iconTarget.getName(),
I18N.getString("resource.menu-icon"),
icon,
iconTarget,
@@ -534,34 +611,41 @@
}
//postinst copying of desktop icon
- installScripts.append(" xdg-desktop-menu install --novendor ");
+ installScripts.append(
+ " xdg-desktop-menu install --novendor ");
installScripts.append(LINUX_INSTALL_DIR.fetchFrom(params));
installScripts.append("/");
installScripts.append(data.get("APPLICATION_FS_NAME"));
installScripts.append("/");
- installScripts.append(secondaryLauncherData.get("APPLICATION_LAUNCHER_FILENAME"));
+ installScripts.append(
+ secondaryLauncherData.get("APPLICATION_LAUNCHER_FILENAME"));
installScripts.append(".desktop\n");
//postrm cleanup of desktop icon
- removeScripts.append(" xdg-desktop-menu uninstall --novendor ");
+ removeScripts.append(
+ " xdg-desktop-menu uninstall --novendor ");
removeScripts.append(LINUX_INSTALL_DIR.fetchFrom(params));
removeScripts.append("/");
removeScripts.append(data.get("APPLICATION_FS_NAME"));
removeScripts.append("/");
- removeScripts.append(secondaryLauncherData.get("APPLICATION_LAUNCHER_FILENAME"));
+ removeScripts.append(
+ secondaryLauncherData.get("APPLICATION_LAUNCHER_FILENAME"));
removeScripts.append(".desktop\n");
}
data.put("SECONDARY_LAUNCHERS_INSTALL", installScripts.toString());
data.put("SECONDARY_LAUNCHERS_REMOVE", removeScripts.toString());
- List<Map<String, ? super Object>> associations = FILE_ASSOCIATIONS.fetchFrom(params);
+ List<Map<String, ? super Object>> associations =
+ FILE_ASSOCIATIONS.fetchFrom(params);
data.put("FILE_ASSOCIATION_INSTALL", "");
data.put("FILE_ASSOCIATION_REMOVE", "");
data.put("DESKTOP_MIMES", "");
if (associations != null) {
- String mimeInfoFile = XDG_FILE_PREFIX.fetchFrom(params) + "-MimeInfo.xml";
+ String mimeInfoFile = XDG_FILE_PREFIX.fetchFrom(params)
+ + "-MimeInfo.xml";
StringBuilder mimeInfo = new StringBuilder(
- "<?xml version=\"1.0\"?>\n<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n");
+ "<?xml version=\"1.0\"?>\n<mime-info xmlns="
+ + "'http://www.freedesktop.org/standards/shared-mime-info'>\n");
StringBuilder registrations = new StringBuilder();
StringBuilder deregistrations = new StringBuilder();
StringBuilder desktopMimes = new StringBuilder("MimeType=");
@@ -582,7 +666,8 @@
File faIcon = FA_ICON.fetchFrom(assoc); //TODO FA_ICON_PNG
List<String> extensions = FA_EXTENSIONS.fetchFrom(assoc);
if (extensions == null) {
- Log.info(I18N.getString("message.creating-association-with-null-extension"));
+ Log.info(I18N.getString(
+ "message.creating-association-with-null-extension"));
}
List<String> mimes = FA_CONTENT_TYPE.fetchFrom(assoc);
@@ -636,11 +721,17 @@
int size = getSquareSizeOfImage(faIcon);
if (size > 0) {
- File target = new File(rootDir, APP_FS_NAME.fetchFrom(params) + "_fa_" + faIcon.getName());
+ File target = new File(rootDir,
+ APP_FS_NAME.fetchFrom(params)
+ + "_fa_" + faIcon.getName());
IOUtils.copyFile(faIcon, target);
- //xdg-icon-resource install --context mimetypes --size 64 awesomeapp_fa_1.png application-x.vnd-awesome
- registrations.append(" xdg-icon-resource install --context mimetypes --size ")
+ // xdg-icon-resource install --context mimetypes
+ // --size 64 awesomeapp_fa_1.png
+ // application-x.vnd-awesome
+ registrations.append(
+ " xdg-icon-resource install "
+ + "--context mimetypes --size ")
.append(size)
.append(" ")
.append(LINUX_INSTALL_DIR.fetchFrom(params))
@@ -652,8 +743,12 @@
.append(dashMime)
.append("\n");
- //xdg-icon-resource uninstall --context mimetypes --size 64 awesomeapp_fa_1.png application-x.vnd-awesome
- deregistrations.append(" xdg-icon-resource uninstall --context mimetypes --size ")
+ //x dg-icon-resource uninstall --context mimetypes
+ // --size 64 awesomeapp_fa_1.png
+ // application-x.vnd-awesome
+ deregistrations.append(
+ " xdg-icon-resource uninstall "
+ + "--context mimetypes --size ")
.append(size)
.append(" ")
.append(LINUX_INSTALL_DIR.fetchFrom(params))
@@ -670,7 +765,8 @@
mimeInfo.append("</mime-info>");
if (addedEntry) {
- Writer w = new BufferedWriter(new FileWriter(new File(rootDir, mimeInfoFile)));
+ Writer w = new BufferedWriter(new FileWriter(
+ new File(rootDir, mimeInfoFile)));
w.write(mimeInfo.toString());
w.close();
data.put("FILE_ASSOCIATION_INSTALL", registrations.toString());
@@ -681,9 +777,12 @@
if (!Arguments.CREATE_JRE_INSTALLER.fetchFrom(params)) {
//prepare desktop shortcut
- Writer w = new BufferedWriter(new FileWriter(getConfig_DesktopShortcutFile(rootDir, params)));
+ Writer w = new BufferedWriter(new FileWriter(
+ getConfig_DesktopShortcutFile(rootDir, params)));
String content = preprocessTextResource(
- LinuxAppBundler.LINUX_BUNDLER_PREFIX + getConfig_DesktopShortcutFile(rootDir, params).getName(),
+ LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + getConfig_DesktopShortcutFile(
+ rootDir, params).getName(),
I18N.getString("resource.menu-shortcut-descriptor"),
DEFAULT_DESKTOP_FILE_TEMPLATE,
data,
@@ -693,9 +792,11 @@
w.close();
}
//prepare control file
- Writer w = new BufferedWriter(new FileWriter(getConfig_ControlFile(params)));
+ Writer w = new BufferedWriter(new FileWriter(
+ getConfig_ControlFile(params)));
String content = preprocessTextResource(
- LinuxAppBundler.LINUX_BUNDLER_PREFIX + getConfig_ControlFile(params).getName(),
+ LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + getConfig_ControlFile(params).getName(),
I18N.getString("resource.deb-control-file"),
DEFAULT_CONTROL_TEMPLATE,
data,
@@ -704,9 +805,11 @@
w.write(content);
w.close();
- w = new BufferedWriter(new FileWriter(getConfig_PreinstallFile(params)));
+ w = new BufferedWriter(new FileWriter(
+ getConfig_PreinstallFile(params)));
content = preprocessTextResource(
- LinuxAppBundler.LINUX_BUNDLER_PREFIX + getConfig_PreinstallFile(params).getName(),
+ LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + getConfig_PreinstallFile(params).getName(),
I18N.getString("resource.deb-preinstall-script"),
DEFAULT_PREINSTALL_TEMPLATE,
data,
@@ -718,7 +821,8 @@
w = new BufferedWriter(new FileWriter(getConfig_PrermFile(params)));
content = preprocessTextResource(
- LinuxAppBundler.LINUX_BUNDLER_PREFIX + getConfig_PrermFile(params).getName(),
+ LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + getConfig_PrermFile(params).getName(),
I18N.getString("resource.deb-prerm-script"),
DEFAULT_PRERM_TEMPLATE,
data,
@@ -730,7 +834,8 @@
w = new BufferedWriter(new FileWriter(getConfig_PostinstallFile(params)));
content = preprocessTextResource(
- LinuxAppBundler.LINUX_BUNDLER_PREFIX + getConfig_PostinstallFile(params).getName(),
+ LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + getConfig_PostinstallFile(params).getName(),
I18N.getString("resource.deb-postinstall-script"),
DEFAULT_POSTINSTALL_TEMPLATE,
data,
@@ -742,7 +847,8 @@
w = new BufferedWriter(new FileWriter(getConfig_PostrmFile(params)));
content = preprocessTextResource(
- LinuxAppBundler.LINUX_BUNDLER_PREFIX + getConfig_PostrmFile(params).getName(),
+ LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + getConfig_PostrmFile(params).getName(),
I18N.getString("resource.deb-postrm-script"),
DEFAULT_POSTRM_TEMPLATE,
data,
@@ -754,7 +860,8 @@
w = new BufferedWriter(new FileWriter(getConfig_CopyrightFile(params)));
content = preprocessTextResource(
- LinuxAppBundler.LINUX_BUNDLER_PREFIX + getConfig_CopyrightFile(params).getName(),
+ LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + getConfig_CopyrightFile(params).getName(),
I18N.getString("resource.deb-copyright-file"),
DEFAULT_COPYRIGHT_TEMPLATE,
data,
@@ -766,7 +873,8 @@
return true;
}
- private Map<String, String> createReplacementData(Map<String, ? super Object> params) {
+ private Map<String, String> createReplacementData(
+ Map<String, ? super Object> params) {
Map<String, String> data = new HashMap<>();
data.put("APPLICATION_NAME", APP_NAME.fetchFrom(params));
@@ -775,7 +883,8 @@
data.put("APPLICATION_VENDOR", VENDOR.fetchFrom(params));
data.put("APPLICATION_MAINTAINER", MAINTAINER.fetchFrom(params));
data.put("APPLICATION_VERSION", VERSION.fetchFrom(params));
- data.put("APPLICATION_LAUNCHER_FILENAME", APP_FS_NAME.fetchFrom(params));
+ data.put("APPLICATION_LAUNCHER_FILENAME",
+ APP_FS_NAME.fetchFrom(params));
data.put("INSTALLATION_DIRECTORY", LINUX_INSTALL_DIR.fetchFrom(params));
data.put("XDG_PREFIX", XDG_FILE_PREFIX.fetchFrom(params));
data.put("DEPLOY_BUNDLE_CATEGORY", CATEGORY.fetchFrom(params));
@@ -784,27 +893,33 @@
data.put("APPLICATION_COPYRIGHT", COPYRIGHT.fetchFrom(params));
data.put("APPLICATION_LICENSE_TEXT", LICENSE_TEXT.fetchFrom(params));
data.put("APPLICATION_ARCH", getArch());
- data.put("APPLICATION_INSTALLED_SIZE", Long.toString(getInstalledSizeKB(params)));
+ data.put("APPLICATION_INSTALLED_SIZE",
+ Long.toString(getInstalledSizeKB(params)));
String deps = LINUX_PACKAGE_DEPENDENCIES.fetchFrom(params);
- data.put("PACKAGE_DEPENDENCIES", deps.isEmpty() ? "" : "Depends: " + deps);
- data.put("CREATE_JRE_INSTALLER", Arguments.CREATE_JRE_INSTALLER.fetchFrom(params).toString());
+ data.put("PACKAGE_DEPENDENCIES",
+ deps.isEmpty() ? "" : "Depends: " + deps);
+ data.put("CREATE_JRE_INSTALLER",
+ Arguments.CREATE_JRE_INSTALLER.fetchFrom(params).toString());
return data;
}
- private File getConfig_DesktopShortcutFile(File rootDir, Map<String, ? super Object> params) {
+ private File getConfig_DesktopShortcutFile(File rootDir,
+ Map<String, ? super Object> params) {
return new File(rootDir,
APP_FS_NAME.fetchFrom(params) + ".desktop");
}
- private File getConfig_IconFile(File rootDir, Map<String, ? super Object> params) {
+ private File getConfig_IconFile(File rootDir,
+ Map<String, ? super Object> params) {
return new File(rootDir,
APP_FS_NAME.fetchFrom(params) + ".png");
}
private File getConfig_InitScriptFile(Map<String, ? super Object> params) {
- return new File(LinuxAppBundler.getRootDir(APP_IMAGE_ROOT.fetchFrom(params), params),
- BUNDLE_NAME.fetchFrom(params) + ".init");
+ return new File(LinuxAppBundler.getRootDir(
+ APP_IMAGE_ROOT.fetchFrom(params), params),
+ BUNDLE_NAME.fetchFrom(params) + ".init");
}
private File getConfig_ControlFile(Map<String, ? super Object> params) {
@@ -831,20 +946,25 @@
return new File(CONFIG_DIR.fetchFrom(params), "copyright");
}
- private File buildDeb(Map<String, ? super Object> params, File outdir) throws IOException {
- File outFile = new File(outdir, FULL_PACKAGE_NAME.fetchFrom(params)+".deb");
- Log.verbose(MessageFormat.format(I18N.getString("message.outputting-to-location"), outFile.getAbsolutePath()));
+ private File buildDeb(Map<String, ? super Object> params,
+ File outdir) throws IOException {
+ File outFile = new File(outdir,
+ FULL_PACKAGE_NAME.fetchFrom(params)+".deb");
+ Log.verbose(MessageFormat.format(I18N.getString(
+ "message.outputting-to-location"), outFile.getAbsolutePath()));
outFile.getParentFile().mkdirs();
//run dpkg
ProcessBuilder pb = new ProcessBuilder(
- "fakeroot", TOOL_DPKG, "-b", FULL_PACKAGE_NAME.fetchFrom(params),
+ "fakeroot", TOOL_DPKG, "-b",
+ FULL_PACKAGE_NAME.fetchFrom(params),
outFile.getAbsolutePath());
pb = pb.directory(DEB_IMAGE_DIR.fetchFrom(params).getParentFile());
IOUtils.exec(pb, ECHO_MODE.fetchFrom(params));
- Log.info(MessageFormat.format(I18N.getString("message.output-to-location"), outFile.getAbsolutePath()));
+ Log.info(MessageFormat.format(I18N.getString(
+ "message.output-to-location"), outFile.getAbsolutePath()));
return outFile;
}
@@ -892,7 +1012,8 @@
}
@Override
- public File execute(Map<String, ? super Object> params, File outputParentDir) {
+ public File execute(Map<String, ? super Object> params,
+ File outputParentDir) {
return bundle(params, outputParentDir);
}
--- a/src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxRpmBundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/linux/classes/jdk/packager/internal/linux/LinuxRpmBundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -44,14 +44,16 @@
import static jdk.packager.internal.StandardBundlerParam.*;
import static jdk.packager.internal.linux.LinuxAppBundler.LINUX_INSTALL_DIR;
-import static jdk.packager.internal.linux.LinuxAppBundler.LINUX_PACKAGE_DEPENDENCIES;
+import static
+ jdk.packager.internal.linux.LinuxAppBundler.LINUX_PACKAGE_DEPENDENCIES;
public class LinuxRpmBundler extends AbstractBundler {
- private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.linux.LinuxRpmBundler");
+ private static final ResourceBundle I18N = ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.linux.LinuxRpmBundler");
- public static final BundlerParamInfo<LinuxAppBundler> APP_BUNDLER = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<LinuxAppBundler> APP_BUNDLER =
+ new StandardBundlerParam<>(
I18N.getString("param.app-bundler.name"),
I18N.getString("param.app-bundler.description"),
"linux.app.bundler",
@@ -59,7 +61,8 @@
params -> new LinuxAppBundler(),
null);
- public static final BundlerParamInfo<File> RPM_IMAGE_DIR = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> RPM_IMAGE_DIR =
+ new StandardBundlerParam<>(
I18N.getString("param.image-dir.name"),
I18N.getString("param.image-dir.description"),
"linux.rpm.imageDir",
@@ -71,7 +74,8 @@
},
(s, p) -> new File(s));
- public static final BundlerParamInfo<File> CONFIG_ROOT = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> CONFIG_ROOT =
+ new StandardBundlerParam<>(
I18N.getString("param.config-root.name"),
I18N.getString("param.config-root.description"),
"configRoot",
@@ -82,15 +86,16 @@
// Fedora rules for package naming are used here
// https://fedoraproject.org/wiki/Packaging:NamingGuidelines?rd=Packaging/NamingGuidelines
//
- // all Fedora packages must be named using only the following ASCII characters.
- // These characters are displayed here:
+ // all Fedora packages must be named using only the following ASCII
+ // characters. These characters are displayed here:
//
// abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._+
//
private static final Pattern RPM_BUNDLE_NAME_PATTERN =
Pattern.compile("[a-z\\d\\+\\-\\.\\_]+", Pattern.CASE_INSENSITIVE);
- public static final BundlerParamInfo<String> BUNDLE_NAME = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<String> BUNDLE_NAME =
+ new StandardBundlerParam<> (
I18N.getString("param.bundle-name.name"),
I18N.getString("param.bundle-name.description"),
Arguments.CLIOptions.LINUX_BUNDLE_NAME.getId(),
@@ -106,10 +111,11 @@
},
(s, p) -> {
if (!RPM_BUNDLE_NAME_PATTERN.matcher(s).matches()) {
+ String msgKey = "error.invalid-value-for-package-name";
throw new IllegalArgumentException(
- new ConfigException(
- MessageFormat.format(I18N.getString("error.invalid-value-for-package-name"), s),
- I18N.getString("error.invalid-value-for-package-name.advice")));
+ new ConfigException(MessageFormat.format(
+ I18N.getString(msgKey), s),
+ I18N.getString(msgKey + ".advice")));
}
return s;
@@ -126,7 +132,8 @@
(s, p) -> s
);
- public static final BundlerParamInfo<String> XDG_FILE_PREFIX = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<String> XDG_FILE_PREFIX =
+ new StandardBundlerParam<> (
I18N.getString("param.xdg-prefix.name"),
I18N.getString("param.xdg-prefix.description"),
"linux.xdg-prefix",
@@ -164,9 +171,11 @@
}
public static boolean testTool(String toolName, double minVersion) {
- try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos)) {
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream(baos)) {
ProcessBuilder pb = new ProcessBuilder(toolName, "--version");
- IOUtils.exec(pb, Log.isDebug(), false, ps); //not interested in the output
+ IOUtils.exec(pb, Log.isDebug(), false, ps);
+ //not interested in the above's output
String content = new String(baos.toByteArray());
Pattern pattern = Pattern.compile(" (\\d+\\.\\d+)");
Matcher matcher = pattern.matcher(content);
@@ -179,13 +188,15 @@
return false;
}
} catch (Exception e) {
- Log.verbose(MessageFormat.format(I18N.getString("message.test-for-tool"), toolName, e.getMessage()));
+ Log.verbose(MessageFormat.format(I18N.getString(
+ "message.test-for-tool"), toolName, e.getMessage()));
return false;
}
}
@Override
- public boolean validate(Map<String, ? super Object> p) throws UnsupportedPlatformException, ConfigException {
+ public boolean validate(Map<String, ? super Object> p)
+ throws UnsupportedPlatformException, ConfigException {
try {
if (p == null) throw new ConfigException(
I18N.getString("error.parameters-null"),
@@ -197,7 +208,8 @@
// validate license file, if used, exists in the proper place
if (p.containsKey(LICENSE_FILE.getID())) {
- List<RelativeFileSet> appResourcesList = APP_RESOURCES_LIST.fetchFrom(p);
+ List<RelativeFileSet> appResourcesList =
+ APP_RESOURCES_LIST.fetchFrom(p);
for (String license : LICENSE_FILE.fetchFrom(p)) {
boolean found = false;
for (RelativeFileSet appResources : appResourcesList) {
@@ -206,8 +218,9 @@
if (!found) {
throw new ConfigException(
I18N.getString("error.license-missing"),
- MessageFormat.format(I18N.getString("error.license-missing.advice"),
- license));
+ MessageFormat.format(
+ I18N.getString("error.license-missing.advice"),
+ license));
}
}
}
@@ -224,19 +237,24 @@
}
// only one mime type per association, at least one file extension
- List<Map<String, ? super Object>> associations = FILE_ASSOCIATIONS.fetchFrom(p);
+ 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 == null || mimes.isEmpty()) {
+ String msgKey =
+ "error.no-content-types-for-file-association";
throw new ConfigException(
- MessageFormat.format(I18N.getString("error.no-content-types-for-file-association"), i),
- I18N.getString("error.no-content-types-for-file-association.advice"));
+ MessageFormat.format(I18N.getString(msgKey), i),
+ I18N.getString(msgKey + ".advice"));
} else if (mimes.size() > 1) {
+ String msgKey =
+ "error.no-content-types-for-file-association";
throw new ConfigException(
- MessageFormat.format(I18N.getString("error.too-many-content-types-for-file-association"), i),
- I18N.getString("error.too-many-content-types-for-file-association.advice"));
+ MessageFormat.format(I18N.getString(msgKey), i),
+ I18N.getString(msgKey + ".advice"));
}
}
}
@@ -266,10 +284,14 @@
public File bundle(Map<String, ? super Object> p, File outdir) {
if (!outdir.isDirectory() && !outdir.mkdirs()) {
- throw new RuntimeException(MessageFormat.format(I18N.getString("error.cannot-create-output-dir"), outdir.getAbsolutePath()));
+ throw new RuntimeException(MessageFormat.format(
+ I18N.getString("error.cannot-create-output-dir"),
+ outdir.getAbsolutePath()));
}
if (!outdir.canWrite()) {
- throw new RuntimeException(MessageFormat.format(I18N.getString("error.cannot-write-to-output-dir"), outdir.getAbsolutePath()));
+ throw new RuntimeException(MessageFormat.format(
+ I18N.getString("error.cannot-write-to-output-dir"),
+ outdir.getAbsolutePath()));
}
File imageDir = RPM_IMAGE_DIR.fetchFrom(p);
@@ -289,12 +311,16 @@
if (ECHO_MODE.fetchFrom(p)) {
saveConfigFiles(p);
}
- if (imageDir != null && PREDEFINED_APP_IMAGE.fetchFrom(p) == null &&
- (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null || !Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) && !Log.isDebug()) {
+ if (imageDir != null &&
+ PREDEFINED_APP_IMAGE.fetchFrom(p) == null &&
+ (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null ||
+ !Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) &&
+ !Log.isDebug()) {
IOUtils.deleteRecursive(imageDir);
} else if (imageDir != null) {
Log.info(MessageFormat.format(I18N.getString(
- "message.debug-working-directory"), imageDir.getAbsolutePath()));
+ "message.debug-working-directory"),
+ imageDir.getAbsolutePath()));
}
} catch (IOException ex) {
//noinspection ReturnInsideFinallyBlock
@@ -307,38 +333,46 @@
/*
* set permissions with a string like "rwxr-xr-x"
*
- * This cannot be directly backport to 22u which is unfortunately built with 1.6
+ * This cannot be directly backport to 22u which is built with 1.6
*/
private void setPermissions(File file, String permissions) {
- Set<PosixFilePermission> filePermissions = PosixFilePermissions.fromString(permissions);
+ Set<PosixFilePermission> filePermissions =
+ PosixFilePermissions.fromString(permissions);
try {
if (file.exists()) {
Files.setPosixFilePermissions(file.toPath(), filePermissions);
}
} catch (IOException ex) {
- Logger.getLogger(LinuxDebBundler.class.getName()).log(Level.SEVERE, null, ex);
+ Logger.getLogger(LinuxDebBundler.class.getName()).log(
+ Level.SEVERE, null, ex);
}
}
protected void saveConfigFiles(Map<String, ? super Object> params) {
try {
File configRoot = CONFIG_ROOT.fetchFrom(params);
- File rootDir = LinuxAppBundler.getRootDir(RPM_IMAGE_DIR.fetchFrom(params), params);
+ File rootDir = LinuxAppBundler.getRootDir(
+ RPM_IMAGE_DIR.fetchFrom(params), params);
if (getConfig_SpecFile(params).exists()) {
IOUtils.copyFile(getConfig_SpecFile(params),
- new File(configRoot, getConfig_SpecFile(params).getName()));
+ new File(configRoot,
+ getConfig_SpecFile(params).getName()));
}
if (getConfig_DesktopShortcutFile(rootDir, params).exists()) {
IOUtils.copyFile(getConfig_DesktopShortcutFile(rootDir, params),
- new File(configRoot, getConfig_DesktopShortcutFile(rootDir, params).getName()));
+ new File(configRoot, getConfig_DesktopShortcutFile(
+ rootDir, params).getName()));
}
if (getConfig_IconFile(rootDir, params).exists()) {
IOUtils.copyFile(getConfig_IconFile(rootDir, params),
- new File(configRoot, getConfig_IconFile(rootDir, params).getName()));
+ new File(configRoot,
+ getConfig_IconFile(rootDir, params).getName()));
}
- Log.info(MessageFormat.format(I18N.getString("message.config-save-location"), configRoot.getAbsolutePath()));
+ Log.info(MessageFormat.format(
+ I18N.getString("message.config-save-location"),
+ configRoot.getAbsolutePath()));
} catch (IOException ioe) {
ioe.printStackTrace();
}
@@ -360,23 +394,27 @@
return sb.toString();
}
- private boolean prepareProjectConfig(Map<String, ? super Object> params) throws IOException {
+ private boolean prepareProjectConfig(Map<String, ? super Object> params)
+ throws IOException {
Map<String, String> data = createReplacementData(params);
- File rootDir = LinuxAppBundler.getRootDir(RPM_IMAGE_DIR.fetchFrom(params), params);
+ File rootDir =
+ LinuxAppBundler.getRootDir(RPM_IMAGE_DIR.fetchFrom(params), params);
//prepare installer icon
File iconTarget = getConfig_IconFile(rootDir, params);
File icon = LinuxAppBundler.ICON_PNG.fetchFrom(params);
if (!Arguments.CREATE_JRE_INSTALLER.fetchFrom(params)) {
if (icon == null || !icon.exists()) {
- fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX + iconTarget.getName(),
+ fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + iconTarget.getName(),
I18N.getString("resource.menu-icon"),
DEFAULT_ICON,
iconTarget,
VERBOSE.fetchFrom(params),
DROP_IN_RESOURCES_ROOT.fetchFrom(params));
} else {
- fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX + iconTarget.getName(),
+ fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + iconTarget.getName(),
I18N.getString("resource.menu-icon"),
icon,
iconTarget,
@@ -387,16 +425,23 @@
StringBuilder installScripts = new StringBuilder();
StringBuilder removeScripts = new StringBuilder();
- for (Map<String, ? super Object> secondaryLauncher : SECONDARY_LAUNCHERS.fetchFrom(params)) {
- Map<String, String> secondaryLauncherData = createReplacementData(secondaryLauncher);
- secondaryLauncherData.put("APPLICATION_FS_NAME", data.get("APPLICATION_FS_NAME"));
+ for (Map<String, ? super Object> secondaryLauncher :
+ SECONDARY_LAUNCHERS.fetchFrom(params)) {
+ Map<String, String> secondaryLauncherData =
+ createReplacementData(secondaryLauncher);
+ secondaryLauncherData.put("APPLICATION_FS_NAME",
+ data.get("APPLICATION_FS_NAME"));
secondaryLauncherData.put("DESKTOP_MIMES", "");
//prepare desktop shortcut
- Writer w = new BufferedWriter(new FileWriter(getConfig_DesktopShortcutFile(rootDir, secondaryLauncher)));
+ Writer w = new BufferedWriter(new FileWriter(
+ getConfig_DesktopShortcutFile(rootDir, secondaryLauncher)));
String content = preprocessTextResource(
- LinuxAppBundler.LINUX_BUNDLER_PREFIX + getConfig_DesktopShortcutFile(rootDir, secondaryLauncher).getName(),
- I18N.getString("resource.menu-shortcut-descriptor"), DEFAULT_DESKTOP_FILE_TEMPLATE, secondaryLauncherData,
+ LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + getConfig_DesktopShortcutFile(rootDir,
+ secondaryLauncher).getName(),
+ I18N.getString("resource.menu-shortcut-descriptor"),
+ DEFAULT_DESKTOP_FILE_TEMPLATE, secondaryLauncherData,
VERBOSE.fetchFrom(params),
DROP_IN_RESOURCES_ROOT.fetchFrom(params));
w.write(content);
@@ -406,14 +451,16 @@
iconTarget = getConfig_IconFile(rootDir, secondaryLauncher);
icon = LinuxAppBundler.ICON_PNG.fetchFrom(secondaryLauncher);
if (icon == null || !icon.exists()) {
- fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX + iconTarget.getName(),
+ fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + iconTarget.getName(),
I18N.getString("resource.menu-icon"),
DEFAULT_ICON,
iconTarget,
VERBOSE.fetchFrom(params),
DROP_IN_RESOURCES_ROOT.fetchFrom(params));
} else {
- fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX + iconTarget.getName(),
+ fetchResource(LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + iconTarget.getName(),
I18N.getString("resource.menu-icon"),
icon,
iconTarget,
@@ -427,7 +474,8 @@
installScripts.append("/");
installScripts.append(data.get("APPLICATION_FS_NAME"));
installScripts.append("/");
- installScripts.append(secondaryLauncherData.get("APPLICATION_LAUNCHER_FILENAME"));
+ installScripts.append(secondaryLauncherData.get(
+ "APPLICATION_LAUNCHER_FILENAME"));
installScripts.append(".desktop\n");
//preun cleanup of desktop icon
@@ -436,7 +484,8 @@
removeScripts.append("/");
removeScripts.append(data.get("APPLICATION_FS_NAME"));
removeScripts.append("/");
- removeScripts.append(secondaryLauncherData.get("APPLICATION_LAUNCHER_FILENAME"));
+ removeScripts.append(secondaryLauncherData.get(
+ "APPLICATION_LAUNCHER_FILENAME"));
removeScripts.append(".desktop\n");
}
@@ -447,14 +496,17 @@
data.put("APP_CDS_CACHE", cdsScript.toString());
- List<Map<String, ? super Object>> associations = FILE_ASSOCIATIONS.fetchFrom(params);
+ List<Map<String, ? super Object>> associations =
+ FILE_ASSOCIATIONS.fetchFrom(params);
data.put("FILE_ASSOCIATION_INSTALL", "");
data.put("FILE_ASSOCIATION_REMOVE", "");
data.put("DESKTOP_MIMES", "");
if (associations != null) {
- String mimeInfoFile = XDG_FILE_PREFIX.fetchFrom(params) + "-MimeInfo.xml";
+ String mimeInfoFile = XDG_FILE_PREFIX.fetchFrom(params)
+ + "-MimeInfo.xml";
StringBuilder mimeInfo = new StringBuilder(
- "<?xml version=\"1.0\"?>\n<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n");
+ "<?xml version=\"1.0\"?>\n<mime-info xmlns="
+ +"'http://www.freedesktop.org/standards/shared-mime-info'>\n");
StringBuilder registrations = new StringBuilder();
StringBuilder deregistrations = new StringBuilder();
StringBuilder desktopMimes = new StringBuilder("MimeType=");
@@ -475,7 +527,8 @@
File faIcon = FA_ICON.fetchFrom(assoc); //TODO FA_ICON_PNG
List<String> extensions = FA_EXTENSIONS.fetchFrom(assoc);
if (extensions == null) {
- Log.info(I18N.getString("message.creating-association-with-null-extension"));
+ Log.info(I18N.getString(
+ "message.creating-association-with-null-extension"));
}
List<String> mimes = FA_CONTENT_TYPE.fetchFrom(assoc);
@@ -529,11 +582,16 @@
int size = getSquareSizeOfImage(faIcon);
if (size > 0) {
- File target = new File(rootDir, APP_FS_NAME.fetchFrom(params) + "_fa_" + faIcon.getName());
+ File target = new File(rootDir,
+ APP_FS_NAME.fetchFrom(params)
+ + "_fa_" + faIcon.getName());
IOUtils.copyFile(faIcon, target);
- //xdg-icon-resource install --context mimetypes --size 64 awesomeapp_fa_1.png application-x.vnd-awesome
- registrations.append("xdg-icon-resource install --context mimetypes --size ")
+ // xdg-icon-resource install --context mimetypes
+ // --size 64 awesomeapp_fa_1.png
+ // application-x.vnd-awesome
+ registrations.append(
+ "xdg-icon-resource install --context mimetypes --size ")
.append(size)
.append(" ")
.append(LINUX_INSTALL_DIR.fetchFrom(params))
@@ -545,8 +603,11 @@
.append(dashMime)
.append("\n");
- //xdg-icon-resource uninstall --context mimetypes --size 64 awesomeapp_fa_1.png application-x.vnd-awesome
- deregistrations.append("xdg-icon-resource uninstall --context mimetypes --size ")
+ // xdg-icon-resource uninstall --context mimetypes
+ // --size 64 awesomeapp_fa_1.png
+ // application-x.vnd-awesome
+ deregistrations.append(
+ "xdg-icon-resource uninstall --context mimetypes --size ")
.append(size)
.append(" ")
.append(LINUX_INSTALL_DIR.fetchFrom(params))
@@ -563,7 +624,8 @@
mimeInfo.append("</mime-info>");
if (addedEntry) {
- Writer w = new BufferedWriter(new FileWriter(new File(rootDir, mimeInfoFile)));
+ Writer w = new BufferedWriter(new FileWriter(
+ new File(rootDir, mimeInfoFile)));
w.write(mimeInfo.toString());
w.close();
data.put("FILE_ASSOCIATION_INSTALL", registrations.toString());
@@ -574,10 +636,14 @@
if (!Arguments.CREATE_JRE_INSTALLER.fetchFrom(params)) {
//prepare desktop shortcut
- Writer w = new BufferedWriter(new FileWriter(getConfig_DesktopShortcutFile(rootDir, params)));
+ Writer w = new BufferedWriter(new FileWriter(
+ getConfig_DesktopShortcutFile(rootDir, params)));
String content = preprocessTextResource(
- LinuxAppBundler.LINUX_BUNDLER_PREFIX + getConfig_DesktopShortcutFile(rootDir, params).getName(),
- I18N.getString("resource.menu-shortcut-descriptor"), DEFAULT_DESKTOP_FILE_TEMPLATE, data,
+ LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + getConfig_DesktopShortcutFile(rootDir,
+ params).getName(),
+ I18N.getString("resource.menu-shortcut-descriptor"),
+ DEFAULT_DESKTOP_FILE_TEMPLATE, data,
VERBOSE.fetchFrom(params),
DROP_IN_RESOURCES_ROOT.fetchFrom(params));
w.write(content);
@@ -585,10 +651,13 @@
}
//prepare spec file
- Writer w = new BufferedWriter(new FileWriter(getConfig_SpecFile(params)));
+ Writer w = new BufferedWriter(
+ new FileWriter(getConfig_SpecFile(params)));
String content = preprocessTextResource(
- LinuxAppBundler.LINUX_BUNDLER_PREFIX + getConfig_SpecFile(params).getName(),
- I18N.getString("resource.rpm-spec-file"), DEFAULT_SPEC_TEMPLATE, data,
+ LinuxAppBundler.LINUX_BUNDLER_PREFIX
+ + getConfig_SpecFile(params).getName(),
+ I18N.getString("resource.rpm-spec-file"),
+ DEFAULT_SPEC_TEMPLATE, data,
VERBOSE.fetchFrom(params),
DROP_IN_RESOURCES_ROOT.fetchFrom(params));
w.write(content);
@@ -597,7 +666,8 @@
return true;
}
- private Map<String, String> createReplacementData(Map<String, ? super Object> params) {
+ private Map<String, String> createReplacementData(
+ Map<String, ? super Object> params) {
Map<String, String> data = new HashMap<>();
data.put("APPLICATION_NAME", APP_NAME.fetchFrom(params));
@@ -605,7 +675,8 @@
data.put("APPLICATION_PACKAGE", BUNDLE_NAME.fetchFrom(params));
data.put("APPLICATION_VENDOR", VENDOR.fetchFrom(params));
data.put("APPLICATION_VERSION", VERSION.fetchFrom(params));
- data.put("APPLICATION_LAUNCHER_FILENAME", APP_FS_NAME.fetchFrom(params));
+ data.put("APPLICATION_LAUNCHER_FILENAME",
+ APP_FS_NAME.fetchFrom(params));
data.put("INSTALLATION_DIRECTORY", LINUX_INSTALL_DIR.fetchFrom(params));
data.put("XDG_PREFIX", XDG_FILE_PREFIX.fetchFrom(params));
data.put("DEPLOY_BUNDLE_CATEGORY", CATEGORY.fetchFrom(params)); //TODO rpm categories
@@ -614,17 +685,21 @@
data.put("APPLICATION_LICENSE_TYPE", LICENSE_TYPE.fetchFrom(params));
data.put("APPLICATION_LICENSE_FILE", getLicenseFileString(params));
String deps = LINUX_PACKAGE_DEPENDENCIES.fetchFrom(params);
- data.put("PACKAGE_DEPENDENCIES", deps.isEmpty() ? "" : "Requires: " + deps);
- data.put("CREATE_JRE_INSTALLER", Arguments.CREATE_JRE_INSTALLER.fetchFrom(params).toString());
+ data.put("PACKAGE_DEPENDENCIES",
+ deps.isEmpty() ? "" : "Requires: " + deps);
+ data.put("CREATE_JRE_INSTALLER",
+ Arguments.CREATE_JRE_INSTALLER.fetchFrom(params).toString());
return data;
}
- private File getConfig_DesktopShortcutFile(File rootDir, Map<String, ? super Object> params) {
+ private File getConfig_DesktopShortcutFile(File rootDir,
+ Map<String, ? super Object> params) {
return new File(rootDir,
APP_FS_NAME.fetchFrom(params) + ".desktop");
}
- private File getConfig_IconFile(File rootDir, Map<String, ? super Object> params) {
+ private File getConfig_IconFile(File rootDir,
+ Map<String, ? super Object> params) {
return new File(rootDir,
APP_FS_NAME.fetchFrom(params) + ".png");
}
@@ -634,8 +709,11 @@
APP_FS_NAME.fetchFrom(params) + ".spec");
}
- private File buildRPM(Map<String, ? super Object> params, File outdir) throws IOException {
- Log.verbose(MessageFormat.format(I18N.getString("message.outputting-bundle-location"), outdir.getAbsolutePath()));
+ private File buildRPM(Map<String, ? super Object> params,
+ File outdir) throws IOException {
+ Log.verbose(MessageFormat.format(I18N.getString(
+ "message.outputting-bundle-location"),
+ outdir.getAbsolutePath()));
File broot = new File(BUILD_ROOT.fetchFrom(params), "rmpbuildroot");
@@ -645,10 +723,14 @@
ProcessBuilder pb = new ProcessBuilder(
TOOL_RPMBUILD,
"-bb", getConfig_SpecFile(params).getAbsolutePath(),
-// "--define", "%__jar_repack %{nil}", //debug: improves build time (but will require unpack to install?)
- "--define", "%_sourcedir "+ RPM_IMAGE_DIR.fetchFrom(params).getAbsolutePath(),
- "--define", "%_rpmdir " + outdir.getAbsolutePath(), //save result to output dir
- "--define", "%_topdir " + broot.getAbsolutePath() //do not use other system directories to build as current user
+// "--define", "%__jar_repack %{nil}",
+//debug: improves build time (but will require unpack to install?)
+ "--define", "%_sourcedir "
+ + RPM_IMAGE_DIR.fetchFrom(params).getAbsolutePath(),
+ //save result to output dir
+ "--define", "%_rpmdir " + outdir.getAbsolutePath(),
+ //do not use other system directories to build as current user
+ "--define", "%_topdir " + broot.getAbsolutePath()
);
pb = pb.directory(RPM_IMAGE_DIR.fetchFrom(params));
IOUtils.exec(pb, ECHO_MODE.fetchFrom(params));
@@ -657,7 +739,9 @@
IOUtils.deleteRecursive(broot);
}
- Log.info(MessageFormat.format(I18N.getString("message.output-bundle-location"), outdir.getAbsolutePath()));
+ Log.info(MessageFormat.format(
+ I18N.getString("message.output-bundle-location"),
+ outdir.getAbsolutePath()));
// presume the result is the ".rpm" file with the newest modified time
// not the best solution, but it is the most reliable
@@ -666,7 +750,8 @@
File[] list = outdir.listFiles();
if (list != null) {
for (File f : list) {
- if (f.getName().endsWith(".rpm") && f.lastModified() > lastModified) {
+ if (f.getName().endsWith(".rpm") &&
+ f.lastModified() > lastModified) {
result = f;
lastModified = f.lastModified();
}
@@ -718,7 +803,8 @@
}
@Override
- public File execute(Map<String, ? super Object> params, File outputParentDir) {
+ public File execute(
+ Map<String, ? super Object> params, File outputParentDir) {
return bundle(params, outputParentDir);
}
--- a/src/jdk.packager/macosx/classes/jdk/packager/internal/builders/mac/MacAppImageBuilder.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/macosx/classes/jdk/packager/internal/builders/mac/MacAppImageBuilder.java Mon Aug 27 16:01:38 2018 -0400
@@ -75,14 +75,17 @@
public class MacAppImageBuilder extends AbstractAppImageBuilder {
private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.builders.mac.MacAppImageBuilder");
+ ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.builders.mac.MacAppImageBuilder");
private static final String EXECUTABLE_NAME = "JavaAppLauncher";
private static final String LIBRARY_NAME = "libpackager.dylib";
private static final String TEMPLATE_BUNDLE_ICON = "GenericApp.icns";
private static final String OS_TYPE_CODE = "APPL";
- private static final String TEMPLATE_INFO_PLIST_LITE = "Info-lite.plist.template";
- private static final String TEMPLATE_RUNTIME_INFO_PLIST = "Runtime-Info.plist.template";
+ private static final String TEMPLATE_INFO_PLIST_LITE =
+ "Info-lite.plist.template";
+ private static final String TEMPLATE_RUNTIME_INFO_PLIST =
+ "Runtime-Info.plist.template";
private final Path root;
private final Path contentsDir;
@@ -106,7 +109,8 @@
map.put("Finance", "public.app-category.finance");
map.put("Games", "public.app-category.games");
map.put("Graphics & Design", "public.app-category.graphics-design");
- map.put("Healthcare & Fitness", "public.app-category.healthcare-fitness");
+ map.put("Healthcare & Fitness",
+ "public.app-category.healthcare-fitness");
map.put("Lifestyle", "public.app-category.lifestyle");
map.put("Medical", "public.app-category.medical");
map.put("Music", "public.app-category.music");
@@ -144,10 +148,11 @@
return map;
}
- public static final BundlerParamInfo<Boolean> MAC_CONFIGURE_LAUNCHER_IN_PLIST =
- new StandardBundlerParam<>(
+ public static final BundlerParamInfo<Boolean>
+ MAC_CONFIGURE_LAUNCHER_IN_PLIST = new StandardBundlerParam<>(
I18N.getString("param.configure-launcher-in-plist"),
- I18N.getString("param.configure-launcher-in-plist.description"),
+ I18N.getString(
+ "param.configure-launcher-in-plist.description"),
"mac.configure-launcher-in-plist",
Boolean.class,
params -> Boolean.FALSE,
@@ -197,19 +202,22 @@
},
(s, p) -> s);
- public static final BundlerParamInfo<File> CONFIG_ROOT = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> CONFIG_ROOT =
+ new StandardBundlerParam<>(
I18N.getString("param.config-root.name"),
I18N.getString("param.config-root.description"),
"configRoot",
File.class,
params -> {
- File configRoot = new File(BUILD_ROOT.fetchFrom(params), "macosx");
+ File configRoot =
+ new File(BUILD_ROOT.fetchFrom(params), "macosx");
configRoot.mkdirs();
return configRoot;
},
(s, p) -> new File(s));
- public static final BundlerParamInfo<String> DEFAULT_ICNS_ICON = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<String> DEFAULT_ICNS_ICON =
+ new StandardBundlerParam<>(
I18N.getString("param.default-icon-icns"),
I18N.getString("param.default-icon-icns.description"),
".mac.default.icns",
@@ -217,7 +225,8 @@
params -> TEMPLATE_BUNDLE_ICON,
(s, p) -> s);
- public static final BundlerParamInfo<File> ICON_ICNS = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> ICON_ICNS =
+ new StandardBundlerParam<>(
I18N.getString("param.icon-icns.name"),
I18N.getString("param.icon-icns.description"),
"icon.icns",
@@ -225,7 +234,8 @@
params -> {
File f = ICON.fetchFrom(params);
if (f != null && !f.getName().toLowerCase().endsWith(".icns")) {
- Log.info(MessageFormat.format(I18N.getString("message.icon-not-icns"), f));
+ Log.info(MessageFormat.format(
+ I18N.getString("message.icon-not-icns"), f));
return null;
}
return f;
@@ -239,12 +249,15 @@
Arguments.CLIOptions.MAC_SIGN.getId(),
Boolean.class,
params -> false,
- // valueOf(null) is false, and we actually do want null in some cases
- (s, p) -> (s == null || "null".equalsIgnoreCase(s))? null : Boolean.valueOf(s)
+ // valueOf(null) is false, we actually do want null in some cases
+ (s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
+ null : Boolean.valueOf(s)
);
- public MacAppImageBuilder(Map<String, Object> config, Path imageOutDir) throws IOException {
- super(config, imageOutDir.resolve(APP_NAME.fetchFrom(config) + ".app/Contents/PlugIns/Java.runtime/Contents/Home"));
+ public MacAppImageBuilder(Map<String, Object> config, Path imageOutDir)
+ throws IOException {
+ super(config, imageOutDir.resolve(APP_NAME.fetchFrom(config)
+ + ".app/Contents/PlugIns/Java.runtime/Contents/Home"));
Objects.requireNonNull(imageOutDir);
@@ -290,7 +303,8 @@
// chmod ugo+x file
private void setExecutable(Path file) {
try {
- Set<PosixFilePermission> perms = Files.getPosixFilePermissions(file);
+ Set<PosixFilePermission> perms =
+ Files.getPosixFilePermissions(file);
perms.add(PosixFilePermission.OWNER_EXECUTE);
perms.add(PosixFilePermission.GROUP_EXECUTE);
perms.add(PosixFilePermission.OTHERS_EXECUTE);
@@ -300,7 +314,8 @@
}
}
- private static void createUtf8File(File file, String content) throws IOException {
+ private static void createUtf8File(File file, String content)
+ throws IOException {
try (OutputStream fout = new FileOutputStream(file);
Writer output = new OutputStreamWriter(fout, "UTF-8")) {
output.write(content);
@@ -328,27 +343,31 @@
String p[] = v.split("\\.");
if (p.length > 3 || p.length < 1) {
- Log.verbose(I18N.getString("message.version-string-too-many-components"));
+ 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"));
+ 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"));
+ 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"));
+ Log.verbose(I18N.getString(
+ "message.version-string-no-negative-numbers"));
return false;
}
}
@@ -386,7 +405,8 @@
executable.toFile().setExecutable(true, false);
// generate launcher config
- writeCfgFile(params, new File(root.toFile(), getLauncherCfgName(params)),
+ writeCfgFile(params,
+ new File(root.toFile(), getLauncherCfgName(params)),
"$APPDIR/PlugIns/Java.runtime");
// Copy class path entries to Java folder
@@ -394,16 +414,19 @@
/*********** Take care of "config" files *******/
File icon = ICON_ICNS.fetchFrom(params);
- InputStream in = locateResource("package/macosx/" + APP_NAME.fetchFrom(params) + ".icns",
+ InputStream in = locateResource(
+ "package/macosx/" + APP_NAME.fetchFrom(params) + ".icns",
"icon",
DEFAULT_ICNS_ICON.fetchFrom(params),
icon,
VERBOSE.fetchFrom(params),
DROP_IN_RESOURCES_ROOT.fetchFrom(params));
- Files.copy(in, resourcesDir.resolve(APP_NAME.fetchFrom(params) + ".icns"));
+ Files.copy(in,
+ resourcesDir.resolve(APP_NAME.fetchFrom(params) + ".icns"));
// copy file association icons
- for (Map<String, ? super Object> fa : FILE_ASSOCIATIONS.fetchFrom(params)) {
+ for (Map<String, ?
+ super Object> fa : FILE_ASSOCIATIONS.fetchFrom(params)) {
f = FA_ICON.fetchFrom(fa);
if (f != null && f.exists()) {
try (InputStream in2 = new FileInputStream(f)) {
@@ -428,7 +451,8 @@
writeInfoPlist(contentsDir.resolve("Info.plist").toFile());
// generate java runtime info.plist
- writeRuntimeInfoPlist(runtimeDir.resolve("Contents/Info.plist").toFile());
+ writeRuntimeInfoPlist(
+ runtimeDir.resolve("Contents/Info.plist").toFile());
// copy library
Path runtimeMacOSDir = Files.createDirectories(
@@ -438,13 +462,15 @@
}
private void sign() throws IOException {
- if (Optional.ofNullable(SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.TRUE)) {
+ if (Optional.ofNullable(
+ SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.TRUE)) {
try {
addNewKeychain(params);
} catch (InterruptedException e) {
Log.error(e.getMessage());
}
- String signingIdentity = DEVELOPER_ID_APP_SIGNING_KEY.fetchFrom(params);
+ String signingIdentity =
+ DEVELOPER_ID_APP_SIGNING_KEY.fetchFrom(params);
if (signingIdentity != null) {
signAppBundle(params, root, signingIdentity,
BUNDLE_ID_SIGNING_PREFIX.fetchFrom(params), null, null);
@@ -466,9 +492,11 @@
}
private void copyClassPathEntries(Path javaDirectory) throws IOException {
- List<RelativeFileSet> resourcesList = APP_RESOURCES_LIST.fetchFrom(params);
+ List<RelativeFileSet> resourcesList =
+ APP_RESOURCES_LIST.fetchFrom(params);
if (resourcesList == null) {
- throw new RuntimeException(I18N.getString("message.null-classpath"));
+ throw new RuntimeException(
+ I18N.getString("message.null-classpath"));
}
for (RelativeFileSet classPath : resourcesList) {
@@ -484,7 +512,8 @@
String bn = MAC_CF_BUNDLE_NAME.fetchFrom(params);
if (bn.length() > 16) {
Log.info(MessageFormat.format(I18N.getString(
- "message.bundle-name-too-long-warning"), MAC_CF_BUNDLE_NAME.getID(), bn));
+ "message.bundle-name-too-long-warning"),
+ MAC_CF_BUNDLE_NAME.getID(), bn));
}
return MAC_CF_BUNDLE_NAME.fetchFrom(params);
} else if (APP_NAME.fetchFrom(params) != null) {
@@ -522,10 +551,11 @@
}
private void writeInfoPlist(File file) throws IOException {
- Log.verbose(MessageFormat.format(I18N.getString("message.preparing-info-plist"), file.getAbsolutePath()));
+ Log.verbose(MessageFormat.format(I18N.getString(
+ "message.preparing-info-plist"), file.getAbsolutePath()));
//prepare config for exe
- //Note: do not need CFBundleDisplayName if we do not support localization
+ //Note: do not need CFBundleDisplayName if we don't support localization
Map<String, String> data = new HashMap<>();
data.put("DEPLOY_ICON_FILE", APP_NAME.fetchFrom(params) + ".icns");
data.put("DEPLOY_BUNDLE_IDENTIFIER",
@@ -533,33 +563,41 @@
data.put("DEPLOY_BUNDLE_NAME",
getBundleName(params));
data.put("DEPLOY_BUNDLE_COPYRIGHT",
- COPYRIGHT.fetchFrom(params) != null ? COPYRIGHT.fetchFrom(params) : "Unknown");
+ COPYRIGHT.fetchFrom(params) != null ?
+ COPYRIGHT.fetchFrom(params) : "Unknown");
data.put("DEPLOY_LAUNCHER_NAME", getLauncherName(params));
data.put("DEPLOY_JAVA_RUNTIME_NAME", "$APPDIR/PlugIns/Java.runtime");
data.put("DEPLOY_BUNDLE_SHORT_VERSION",
- VERSION.fetchFrom(params) != null ? VERSION.fetchFrom(params) : "1.0.0");
+ 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");
+ MAC_CF_BUNDLE_VERSION.fetchFrom(params) != null ?
+ MAC_CF_BUNDLE_VERSION.fetchFrom(params) : "100");
data.put("DEPLOY_BUNDLE_CATEGORY", MAC_CATEGORY.fetchFrom(params));
boolean hasMainJar = MAIN_JAR.fetchFrom(params) != null;
- boolean hasMainModule = StandardBundlerParam.MODULE.fetchFrom(params) != null;
+ boolean hasMainModule =
+ StandardBundlerParam.MODULE.fetchFrom(params) != null;
if (hasMainJar) {
- data.put("DEPLOY_MAIN_JAR_NAME", MAIN_JAR.fetchFrom(params).getIncludedFiles().iterator().next());
+ data.put("DEPLOY_MAIN_JAR_NAME", MAIN_JAR.fetchFrom(params).
+ getIncludedFiles().iterator().next());
}
else if (hasMainModule) {
- data.put("DEPLOY_MODULE_NAME", StandardBundlerParam.MODULE.fetchFrom(params));
+ data.put("DEPLOY_MODULE_NAME",
+ StandardBundlerParam.MODULE.fetchFrom(params));
}
- data.put("DEPLOY_PREFERENCES_ID", PREFERENCES_ID.fetchFrom(params).toLowerCase());
+ data.put("DEPLOY_PREFERENCES_ID",
+ PREFERENCES_ID.fetchFrom(params).toLowerCase());
StringBuilder sb = new StringBuilder();
List<String> jvmOptions = JVM_OPTIONS.fetchFrom(params);
- String newline = ""; //So we don't add unneccessary extra line after last append
+ String newline = ""; //So we don't add extra line after last append
for (String o : jvmOptions) {
- sb.append(newline).append(" <string>").append(o).append("</string>");
+ sb.append(newline).append(
+ " <string>").append(o).append("</string>");
newline = "\n";
}
@@ -595,11 +633,16 @@
newline = "";
sb = new StringBuilder();
- Map<String, String> overridableJVMOptions = USER_JVM_OPTIONS.fetchFrom(params);
+ Map<String, String> overridableJVMOptions =
+ USER_JVM_OPTIONS.fetchFrom(params);
for (Map.Entry<String, String> arg : overridableJVMOptions.entrySet()) {
sb.append(newline)
- .append(" <key>").append(arg.getKey()).append("</key>\n")
- .append(" <string>").append(arg.getValue()).append("</string>");
+ .append(" <key>")
+ .append(arg.getKey())
+ .append("</key>\n")
+ .append(" <string>")
+ .append(arg.getValue())
+ .append("</string>");
newline = "\n";
}
data.put("DEPLOY_JVM_USER_OPTIONS", sb.toString());
@@ -618,12 +661,14 @@
StringBuilder bundleDocumentTypes = new StringBuilder();
StringBuilder exportedTypes = new StringBuilder();
- for (Map<String, ? super Object> fileAssociation : FILE_ASSOCIATIONS.fetchFrom(params)) {
+ for (Map<String, ? super Object>
+ fileAssociation : FILE_ASSOCIATIONS.fetchFrom(params)) {
List<String> extensions = FA_EXTENSIONS.fetchFrom(fileAssociation);
if (extensions == null) {
- Log.info(I18N.getString("message.creating-association-with-null-extension"));
+ Log.info(I18N.getString(
+ "message.creating-association-with-null-extension"));
}
List<String> mimeTypes = FA_CONTENT_TYPE.fetchFrom(fileAssociation);
@@ -648,18 +693,22 @@
.append("</string>\n")
.append("\n")
.append(" <key>LSHandlerRank</key>\n")
- .append(" <string>Owner</string>\n") //TODO make a bundler arg
+ .append(" <string>Owner</string>\n")
+ // TODO make a bundler arg
.append("\n")
.append(" <key>CFBundleTypeRole</key>\n")
- .append(" <string>Editor</string>\n") // TODO make a bundler arg
+ .append(" <string>Editor</string>\n")
+ // TODO make a bundler arg
.append("\n")
.append(" <key>LSIsAppleDefaultForType</key>\n")
- .append(" <true/>\n") // TODO make a bundler arg
+ .append(" <true/>\n")
+ // TODO make a bundler arg
.append("\n");
if (icon != null && icon.exists()) {
//?
- bundleDocumentTypes.append(" <key>CFBundleTypeIconFile</key>\n")
+ bundleDocumentTypes
+ .append(" <key>CFBundleTypeIconFile</key>\n")
.append(" <string>")
.append(icon.getName())
.append("</string>\n");
@@ -678,7 +727,8 @@
.append("</string>\n")
.append(" <key>UTTypeConformsTo</key>\n")
.append(" <array>\n")
- .append(" <string>public.data</string>\n") //TODO expose this?
+ .append(" <string>public.data</string>\n")
+ //TODO expose this?
.append(" </array>\n")
.append("\n");
@@ -693,12 +743,15 @@
exportedTypes.append("\n")
.append(" <key>UTTypeTagSpecification</key>\n")
.append(" <dict>\n")
- //TODO expose via param? .append(" <key>com.apple.ostype</key>\n");
- //TODO expose via param? .append(" <string>ABCD</string>\n")
+ // TODO expose via param? .append(
+ // " <key>com.apple.ostype</key>\n");
+ // TODO expose via param? .append(
+ // " <string>ABCD</string>\n")
.append("\n");
if (extensions != null && !extensions.isEmpty()) {
- exportedTypes.append(" <key>public.filename-extension</key>\n")
+ exportedTypes.append(
+ " <key>public.filename-extension</key>\n")
.append(" <array>\n");
for (String ext : extensions) {
@@ -724,9 +777,11 @@
}
String associationData;
if (bundleDocumentTypes.length() > 0) {
- associationData = "\n <key>CFBundleDocumentTypes</key>\n <array>\n"
+ associationData =
+ "\n <key>CFBundleDocumentTypes</key>\n <array>\n"
+ bundleDocumentTypes.toString()
- + " </array>\n\n <key>UTExportedTypeDeclarations</key>\n <array>\n"
+ + " </array>\n\n"
+ + " <key>UTExportedTypeDeclarations</key>\n <array>\n"
+ exportedTypes.toString()
+ " </array>\n";
} else {
@@ -759,7 +814,8 @@
public static void addNewKeychain(Map<String, ? super Object> params)
throws IOException, InterruptedException {
if (Platform.getMajorVersion() < 10 ||
- (Platform.getMajorVersion() == 10 && Platform.getMinorVersion() < 12)) {
+ (Platform.getMajorVersion() == 10 &&
+ Platform.getMinorVersion() < 12)) {
// we need this for OS X 10.12+
return;
}
@@ -772,7 +828,8 @@
// get current keychain list
String keyChainPath = new File (keyChain).getAbsolutePath().toString();
List<String> keychainList = new ArrayList<>();
- int ret = IOUtils.getProcessOutput(keychainList, "security", "list-keychains");
+ int ret = IOUtils.getProcessOutput(
+ keychainList, "security", "list-keychains");
if (ret != 0) {
Log.error(I18N.getString("message.keychain.error"));
return;
@@ -807,9 +864,11 @@
IOUtils.exec(pb, ECHO_MODE.fetchFrom(params));
}
- public static void restoreKeychainList(Map<String, ? super Object> params) throws IOException{
+ public static void restoreKeychainList(Map<String, ? super Object> params)
+ throws IOException{
if (Platform.getMajorVersion() < 10 ||
- (Platform.getMajorVersion() == 10 && Platform.getMinorVersion() < 12)) {
+ (Platform.getMajorVersion() == 10 &&
+ Platform.getMinorVersion() < 12)) {
// we need this for OS X 10.12+
return;
}
@@ -829,7 +888,11 @@
IOUtils.exec(pb, ECHO_MODE.fetchFrom(params));
}
- public static void signAppBundle(Map<String, ? super Object> params, Path appLocation, String signingIdentity, String identifierPrefix, String entitlementsFile, String inheritedEntitlements) throws IOException {
+ public static void signAppBundle(
+ Map<String, ? super Object> params, Path appLocation,
+ String signingIdentity, String identifierPrefix,
+ String entitlementsFile, String inheritedEntitlements)
+ throws IOException {
AtomicReference<IOException> toThrow = new AtomicReference<>();
String appExecutable = "/Contents/MacOS/" + APP_NAME.fetchFrom(params);
String keyChain = SIGNING_KEYCHAIN.fetchFrom(params);
@@ -839,7 +902,8 @@
// fix permissions
.peek(path -> {
try {
- Set<PosixFilePermission> pfp = Files.getPosixFilePermissions(path);
+ Set<PosixFilePermission> pfp =
+ Files.getPosixFilePermissions(path);
if (!pfp.contains(PosixFilePermission.OWNER_WRITE)) {
pfp = EnumSet.copyOf(pfp);
pfp.add(PosixFilePermission.OWNER_WRITE);
@@ -850,9 +914,10 @@
}
})
.filter(p -> Files.isRegularFile(p) &&
- !(p.toString().contains("/Contents/MacOS/libjli.dylib")
- || p.toString().contains("/Contents/MacOS/JavaAppletPlugin")
- || p.toString().endsWith(appExecutable))
+ !(p.toString().contains("/Contents/MacOS/libjli.dylib")
+ || p.toString().contains(
+ "/Contents/MacOS/JavaAppletPlugin")
+ || p.toString().endsWith(appExecutable))
).forEach(p -> {
//noinspection ThrowableResultOfMethodCallIgnored
if (toThrow.get() != null) return;
@@ -860,23 +925,27 @@
// If p is a symlink then skip the signing process.
if (Files.isSymbolicLink(p)) {
if (VERBOSE.fetchFrom(params)) {
- Log.verbose(MessageFormat.format(I18N.getString("message.ignoring.symlink"), p.toString()));
+ Log.verbose(MessageFormat.format(I18N.getString(
+ "message.ignoring.symlink"), p.toString()));
}
}
else {
List<String> args = new ArrayList<>();
args.addAll(Arrays.asList("codesign",
"-s", signingIdentity, // sign with this key
- "--prefix", identifierPrefix, // use the identifier as a prefix
+ "--prefix", identifierPrefix,
+ // use the identifier as a prefix
"-vvvv"));
if (entitlementsFile != null &&
(p.toString().endsWith(".jar")
|| p.toString().endsWith(".dylib"))) {
args.add("--entitlements");
args.add(entitlementsFile); // entitlements
- } else if (inheritedEntitlements != null && Files.isExecutable(p)) {
+ } else if (inheritedEntitlements != null &&
+ Files.isExecutable(p)) {
args.add("--entitlements");
- args.add(inheritedEntitlements); // inherited entitlements for executable processes
+ args.add(inheritedEntitlements);
+ // inherited entitlements for executable processes
}
if (keyChain != null && !keyChain.isEmpty()) {
args.add("--keychain");
@@ -885,7 +954,8 @@
args.add(p.toString());
try {
- Set<PosixFilePermission> oldPermissions = Files.getPosixFilePermissions(p);
+ Set<PosixFilePermission> oldPermissions =
+ Files.getPosixFilePermissions(p);
File f = p.toFile();
f.setWritable(true, true);
@@ -913,7 +983,8 @@
List<String> args = new ArrayList<>();
args.addAll(Arrays.asList("codesign",
"-s", signingIdentity, // sign with this key
- "--prefix", identifierPrefix, // use the identifier as a prefix
+ "--prefix", identifierPrefix,
+ // use the identifier as a prefix
"-vvvv"));
if (keyChain != null && !keyChain.isEmpty()) {
args.add("--keychain");
@@ -926,13 +997,15 @@
args = new ArrayList<>();
args.addAll(Arrays.asList("codesign",
"-s", signingIdentity, // sign with this key
- "--prefix", identifierPrefix, // use the identifier as a prefix
+ "--prefix", identifierPrefix,
+ // use the identifier as a prefix
"-vvvv"));
if (keyChain != null && !keyChain.isEmpty()) {
args.add("--keychain");
args.add(keyChain);
}
- args.add(path.toString() + "/Contents/_CodeSignature/CodeResources");
+ args.add(path.toString()
+ + "/Contents/_CodeSignature/CodeResources");
pb = new ProcessBuilder(args);
IOUtils.exec(pb, ECHO_MODE.fetchFrom(params));
} catch (IOException e) {
@@ -976,7 +1049,8 @@
}
args.add(appLocation.toString());
- ProcessBuilder pb = new ProcessBuilder(args.toArray(new String[args.size()]));
+ ProcessBuilder pb =
+ new ProcessBuilder(args.toArray(new String[args.size()]));
IOUtils.exec(pb, ECHO_MODE.fetchFrom(params));
}
--- a/src/jdk.packager/macosx/classes/jdk/packager/internal/mac/MacAppBundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/macosx/classes/jdk/packager/internal/mac/MacAppBundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -58,7 +58,8 @@
public class MacAppBundler extends AbstractImageBundler {
private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.mac.MacAppBundler");
+ ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.mac.MacAppBundler");
public final static String MAC_BUNDLER_PREFIX =
BUNDLER_PREFIX + "macosx" + File.separator;
@@ -74,7 +75,8 @@
map.put("Finance", "public.app-category.finance");
map.put("Games", "public.app-category.games");
map.put("Graphics & Design", "public.app-category.graphics-design");
- map.put("Healthcare & Fitness", "public.app-category.healthcare-fitness");
+ map.put("Healthcare & Fitness",
+ "public.app-category.healthcare-fitness");
map.put("Lifestyle", "public.app-category.lifestyle");
map.put("Medical", "public.app-category.medical");
map.put("Music", "public.app-category.music");
@@ -167,7 +169,8 @@
"configRoot",
File.class,
params -> {
- File configRoot = new File(BUILD_ROOT.fetchFrom(params), "macosx");
+ File configRoot =
+ new File(BUILD_ROOT.fetchFrom(params), "macosx");
configRoot.mkdirs();
return configRoot;
},
@@ -190,7 +193,8 @@
String.class,
params -> {
String result = MacBaseInstallerBundler.findKey(
- "Developer ID Application: " + SIGNING_KEY_USER.fetchFrom(params),
+ "Developer ID Application: "
+ + SIGNING_KEY_USER.fetchFrom(params),
SIGNING_KEYCHAIN.fetchFrom(params),
VERBOSE.fetchFrom(params));
if (result != null) {
@@ -216,7 +220,8 @@
params -> IDENTIFIER.fetchFrom(params) + ".",
(s, p) -> s);
- public static final BundlerParamInfo<File> ICON_ICNS = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> ICON_ICNS =
+ new StandardBundlerParam<>(
I18N.getString("param.icon-icns.name"),
I18N.getString("param.icon-icns.description"),
"icon.icns",
@@ -224,7 +229,8 @@
params -> {
File f = ICON.fetchFrom(params);
if (f != null && !f.getName().toLowerCase().endsWith(".icns")) {
- Log.info(MessageFormat.format(I18N.getString("message.icon-not-icns"), f));
+ Log.info(MessageFormat.format(
+ I18N.getString("message.icon-not-icns"), f));
return null;
}
return f;
@@ -252,27 +258,31 @@
String p[] = v.split("\\.");
if (p.length > 3 || p.length < 1) {
- Log.verbose(I18N.getString("message.version-string-too-many-components"));
+ 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"));
+ 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"));
+ 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"));
+ Log.verbose(I18N.getString(
+ "message.version-string-no-negative-numbers"));
return false;
}
}
@@ -301,7 +311,8 @@
//to be used by chained bundlers, e.g. by EXE bundler to avoid
// skipping validation if p.type does not include "image"
- public boolean doValidate(Map<String, ? super Object> p) throws UnsupportedPlatformException, ConfigException {
+ public boolean doValidate(Map<String, ? super Object> p)
+ throws UnsupportedPlatformException, ConfigException {
if (Platform.getPlatform() != Platform.MAC) {
throw new UnsupportedPlatformException();
}
@@ -320,7 +331,8 @@
}
// reject explicitly set sign to true and no valid signature key
- if (Optional.ofNullable(MacAppImageBuilder.SIGN_BUNDLE.fetchFrom(p)).orElse(Boolean.FALSE)) {
+ if (Optional.ofNullable(MacAppImageBuilder.
+ SIGN_BUNDLE.fetchFrom(p)).orElse(Boolean.FALSE)) {
String signingIdentity = DEVELOPER_ID_APP_SIGNING_KEY.fetchFrom(p);
if (signingIdentity == null) {
throw new ConfigException(
@@ -341,7 +353,8 @@
APP_NAME.fetchFrom(params) + ".icns");
}
- File doBundle(Map<String, ? super Object> p, File outputDirectory, boolean dependentTask) {
+ File doBundle(Map<String, ? super Object> p, File outputDirectory,
+ boolean dependentTask) {
if (Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) {
return doJreBundle(p, outputDirectory, dependentTask);
} else {
@@ -349,7 +362,8 @@
}
}
- File doJreBundle(Map<String, ? super Object> p, File outputDirectory, boolean dependentTask) {
+ File doJreBundle(Map<String, ? super Object> p,
+ File outputDirectory, boolean dependentTask) {
try {
File rootDirectory = createRoot(p, outputDirectory, dependentTask,
APP_NAME.fetchFrom(p));
@@ -373,11 +387,13 @@
}
}
- File doAppBundle(Map<String, ? super Object> p, File outputDirectory, boolean dependentTask) {
+ File doAppBundle(Map<String, ? super Object> p, File outputDirectory,
+ boolean dependentTask) {
try {
File rootDirectory = createRoot(p, outputDirectory, dependentTask,
APP_NAME.fetchFrom(p) + ".app");
- AbstractAppImageBuilder appBuilder = new MacAppImageBuilder(p, outputDirectory.toPath());
+ AbstractAppImageBuilder appBuilder =
+ new MacAppImageBuilder(p, outputDirectory.toPath());
if (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null ) {
JLinkBundlerHelper.execute(p, appBuilder);
} else {
@@ -396,7 +412,8 @@
}
private File createRoot(Map<String, ? super Object> p,
- File outputDirectory, boolean dependentTask, String name) throws IOException {
+ File outputDirectory, boolean dependentTask, String name)
+ throws IOException {
if (!outputDirectory.isDirectory() && !outputDirectory.mkdirs()) {
throw new RuntimeException(MessageFormat.format(I18N.getString(
"error.cannot-create-output-dir"),
@@ -490,7 +507,8 @@
@Override
- public File execute(Map<String, ? super Object> params, File outputParentDir) {
+ public File execute(Map<String, ? super Object> params,
+ File outputParentDir) {
return doBundle(params, outputParentDir, false);
}
@@ -499,17 +517,20 @@
return Platform.getPlatform() == Platform.MAC;
}
-// private void createLauncherForEntryPoint(Map<String, ? super Object> p, File rootDirectory) throws IOException {
+// private void createLauncherForEntryPoint(Map<String, ? super Object> p,
+// File rootDirectory) throws IOException {
// prepareConfigFiles(p);
//
// if (LAUNCHER_CFG_FORMAT.fetchFrom(p).equals(CFG_FORMAT_PROPERTIES)) {
// writeCfgFile(p, rootDirectory);
// } else {
-// writeCfgFile(p, new File(rootDirectory, getLauncherCfgName(p)), "$APPDIR/PlugIns/Java.runtime");
+// writeCfgFile(p, new File(rootDirectory, getLauncherCfgName(p)),
+// "$APPDIR/PlugIns/Java.runtime");
// }
//
// // Copy executable root folder
-// File executableFile = new File(rootDirectory, "Contents/MacOS/" + getLauncherName(p));
+// File executableFile = new File(rootDirectory,
+// "Contents/MacOS/" + getLauncherName(p));
// IOUtils.copyFromURL(
// RAW_EXECUTABLE_URL.fetchFrom(p),
// executableFile);
--- a/src/jdk.packager/macosx/classes/jdk/packager/internal/mac/MacAppStoreBundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/macosx/classes/jdk/packager/internal/mac/MacAppStoreBundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -54,11 +54,15 @@
public class MacAppStoreBundler extends MacBaseInstallerBundler {
private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.mac.MacAppStoreBundler");
+ ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.mac.MacAppStoreBundler");
- private static final String TEMPLATE_BUNDLE_ICON_HIDPI = "GenericAppHiDPI.icns";
- private final static String DEFAULT_ENTITLEMENTS = "MacAppStore.entitlements";
- private final static String DEFAULT_INHERIT_ENTITLEMENTS = "MacAppStore_Inherit.entitlements";
+ private static final String TEMPLATE_BUNDLE_ICON_HIDPI =
+ "GenericAppHiDPI.icns";
+ private final static String DEFAULT_ENTITLEMENTS =
+ "MacAppStore.entitlements";
+ private final static String DEFAULT_INHERIT_ENTITLEMENTS =
+ "MacAppStore_Inherit.entitlements";
public static final BundlerParamInfo<String> MAC_APP_STORE_APP_SIGNING_KEY =
new StandardBundlerParam<>(
@@ -144,11 +148,13 @@
APP_NAME.fetchFrom(p)));
if (!outdir.isDirectory() && !outdir.mkdirs()) {
throw new RuntimeException(MessageFormat.format(I18N.getString(
- "error.cannot-create-output-dir"), outdir.getAbsolutePath()));
+ "error.cannot-create-output-dir"),
+ outdir.getAbsolutePath()));
}
if (!outdir.canWrite()) {
throw new RuntimeException(MessageFormat.format(I18N.getString(
- "error.cannot-write-to-output-dir"), outdir.getAbsolutePath()));
+ "error.cannot-write-to-output-dir"),
+ outdir.getAbsolutePath()));
}
// first, load in some overrides
@@ -177,7 +183,8 @@
String signingIdentity = MAC_APP_STORE_APP_SIGNING_KEY.fetchFrom(p);
String identifierPrefix = BUNDLE_ID_SIGNING_PREFIX.fetchFrom(p);
String entitlementsFile = getConfig_Entitlements(p).toString();
- String inheritEntitlements = getConfig_Inherit_Entitlements(p).toString();
+ String inheritEntitlements =
+ getConfig_Inherit_Entitlements(p).toString();
MacAppImageBuilder.signAppBundle(p, appLocation.toPath(),
signingIdentity, identifierPrefix,
@@ -192,7 +199,8 @@
+ ".pkg");
outdir.mkdirs();
- String installIdentify = MAC_APP_STORE_PKG_SIGNING_KEY.fetchFrom(p);
+ String installIdentify =
+ MAC_APP_STORE_PKG_SIGNING_KEY.fetchFrom(p);
List<String> buildOptions = new ArrayList<>();
buildOptions.add("productbuild");
@@ -221,8 +229,11 @@
return null;
} finally {
try {
- if (appImageDir != null && PREDEFINED_APP_IMAGE.fetchFrom(p) == null &&
- (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null || !Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) && !Log.isDebug()) {
+ if (appImageDir != null &&
+ PREDEFINED_APP_IMAGE.fetchFrom(p) == null &&
+ (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null ||
+ !Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) &&
+ !Log.isDebug()) {
IOUtils.deleteRecursive(appImageDir);
} else if (appImageDir != null) {
Log.info(MessageFormat.format(I18N.getString(
@@ -260,13 +271,14 @@
}
private File getConfig_Entitlements(Map<String, ? super Object> params) {
- return new File(CONFIG_ROOT.fetchFrom(params), APP_NAME.fetchFrom(params)
- + ".entitlements");
+ return new File(CONFIG_ROOT.fetchFrom(params),
+ APP_NAME.fetchFrom(params) + ".entitlements");
}
- private File getConfig_Inherit_Entitlements(Map<String, ? super Object> params) {
- return new File(CONFIG_ROOT.fetchFrom(params), APP_NAME.fetchFrom(params)
- + "_Inherit.entitlements");
+ private File getConfig_Inherit_Entitlements(
+ Map<String, ? super Object> params) {
+ return new File(CONFIG_ROOT.fetchFrom(params),
+ APP_NAME.fetchFrom(params) + "_Inherit.entitlements");
}
private void prepareEntitlements(Map<String, ? super Object> params)
@@ -296,11 +308,13 @@
}
private String getEntitlementsFileName(Map<String, ? super Object> params) {
- return MAC_BUNDLER_PREFIX+ APP_NAME.fetchFrom(params) +".entitlements";
+ return MAC_BUNDLER_PREFIX+ APP_NAME.fetchFrom(params) + ".entitlements";
}
- private String getInheritEntitlementsFileName(Map<String, ? super Object> params) {
- return MAC_BUNDLER_PREFIX+ APP_NAME.fetchFrom(params) +"_Inherit.entitlements";
+ private String getInheritEntitlementsFileName(
+ Map<String, ? super Object> params) {
+ return MAC_BUNDLER_PREFIX + APP_NAME.fetchFrom(params)
+ + "_Inherit.entitlements";
}
@@ -348,7 +362,8 @@
}
@Override
- public boolean validate(Map<String, ? super Object> params) throws UnsupportedPlatformException, ConfigException {
+ public boolean validate(Map<String, ? super Object> params)
+ throws UnsupportedPlatformException, ConfigException {
try {
if (Platform.getPlatform() != Platform.MAC) {
throw new UnsupportedPlatformException();
@@ -360,16 +375,18 @@
I18N.getString("error.parameters-null.advice"));
}
- // hdiutil is always available so there's no need to test for availability.
- //run basic validation to ensure requirements are met
+ // hdiutil is always available so there's no need to test for
+ // availability.
+ // run basic validation to ensure requirements are met
- //TODO Mac App Store apps cannot use the system runtime
+ // TODO Mac App Store apps cannot use the system runtime
- //we are not interested in return code, only possible exception
+ // we are not interested in return code, only possible exception
validateAppImageAndBundeler(params);
// reject explicitly set to not sign
- if (!Optional.ofNullable(MacAppImageBuilder.SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.TRUE)) {
+ if (!Optional.ofNullable(MacAppImageBuilder.
+ SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.TRUE)) {
throw new ConfigException(
I18N.getString("error.must-sign-app-store"),
I18N.getString("error.must-sign-app-store.advice"));
@@ -389,9 +406,10 @@
// things we could check...
// check the icons, make sure it has hidpi icons
- // check the category, make sure it fits in the list apple has provided
+ // check the category,
+ // make sure it fits in the list apple has provided
// validate bundle identifier is reverse dns
- // check for \a+\.\a+\..
+ // check for \a+\.\a+\..
return true;
} catch (RuntimeException re) {
@@ -404,7 +422,8 @@
}
@Override
- public File execute(Map<String, ? super Object> params, File outputParentDir) {
+ public File execute(Map<String, ? super Object> params,
+ File outputParentDir) {
return bundle(params, outputParentDir);
}
--- a/src/jdk.packager/macosx/classes/jdk/packager/internal/mac/MacBaseInstallerBundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/macosx/classes/jdk/packager/internal/mac/MacBaseInstallerBundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -57,7 +57,7 @@
private static final ResourceBundle I18N =
ResourceBundle.getBundle(
- "jdk.packager.internal.resources.mac.MacBaseInstallerBundler");
+ "jdk.packager.internal.resources.mac.MacBaseInstallerBundler");
//This could be generalized more to be for any type of Image Bundler
public static final BundlerParamInfo<MacAppBundler> APP_BUNDLER =
@@ -108,7 +108,8 @@
"configRoot",
File.class,
params -> {
- File imagesRoot = new File(BUILD_ROOT.fetchFrom(params), "macosx");
+ File imagesRoot =
+ new File(BUILD_ROOT.fetchFrom(params), "macosx");
imagesRoot.mkdirs();
return imagesRoot;
},
@@ -151,7 +152,8 @@
},
(s, p) -> s);
- protected void validateAppImageAndBundeler(Map<String, ? super Object> params)
+ protected void validateAppImageAndBundeler(
+ Map<String, ? super Object> params)
throws ConfigException, UnsupportedPlatformException {
if (PREDEFINED_APP_IMAGE.fetchFrom(params) != null) {
File applicationImage = PREDEFINED_APP_IMAGE.fetchFrom(params);
@@ -168,19 +170,22 @@
if (APP_NAME.fetchFrom(params) == null) {
throw new ConfigException(
I18N.getString("message.app-image-requires-app-name"),
- I18N.getString("message.app-image-requires-app-name.advice"));
+ I18N.getString(
+ "message.app-image-requires-app-name.advice"));
}
if (IDENTIFIER.fetchFrom(params) == null) {
throw new ConfigException(
I18N.getString("message.app-image-requires-identifier"),
- I18N.getString("message.app-image-requires-identifier.advice"));
+ I18N.getString(
+ "message.app-image-requires-identifier.advice"));
}
} else {
APP_BUNDLER.fetchFrom(params).doValidate(params);
}
}
- protected File prepareAppBundle(Map<String, ? super Object> p, boolean pkg) {
+ protected File prepareAppBundle(
+ Map<String, ? super Object> p, boolean pkg) {
File predefinedImage = StandardBundlerParam.getPredefinedAppImage(p);
if (predefinedImage != null) {
return predefinedImage;
@@ -214,7 +219,8 @@
return "INSTALLER";
}
- public static String findKey(String key, String keychainName, boolean verbose) {
+ public static String findKey(String key, String keychainName,
+ boolean verbose) {
if (Platform.getPlatform() != Platform.MAC) {
return null;
}
--- a/src/jdk.packager/macosx/classes/jdk/packager/internal/mac/MacCertificate.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/macosx/classes/jdk/packager/internal/mac/MacCertificate.java Mon Aug 27 16:01:38 2018 -0400
@@ -116,7 +116,8 @@
IOUtils.exec(security, verbose, false, ps);
String output = baos.toString();
output = output.substring(output.indexOf("=") + 1);
- DateFormat df = new SimpleDateFormat("MMM dd kk:mm:ss yyyy z", Locale.ENGLISH);
+ DateFormat df = new SimpleDateFormat(
+ "MMM dd kk:mm:ss yyyy z", Locale.ENGLISH);
result = df.parse(output);
}
catch (IOException ioe) {
@@ -127,7 +128,8 @@
return result;
}
- private static boolean verifyCertificate(String certificate, boolean verbose) {
+ private static boolean verifyCertificate(
+ String certificate, boolean verbose) {
boolean result = false;
try {
@@ -138,7 +140,8 @@
file = findCertificate(certificate, verbose);
if (file != null) {
- certificateDate = findCertificateDate(file.getCanonicalPath(), verbose);
+ certificateDate = findCertificateDate(
+ file.getCanonicalPath(), verbose);
}
}
finally {
--- a/src/jdk.packager/macosx/classes/jdk/packager/internal/mac/MacDmgBundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/macosx/classes/jdk/packager/internal/mac/MacDmgBundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -40,7 +40,8 @@
public class MacDmgBundler extends MacBaseInstallerBundler {
private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.mac.MacDmgBundler");
+ ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.mac.MacDmgBundler");
static final String DEFAULT_BACKGROUND_IMAGE="background_dmg.png";
static final String DEFAULT_DMG_SETUP_SCRIPT="DMGsetup.scpt";
@@ -48,7 +49,8 @@
static final String DEFAULT_LICENSE_PLIST="lic_template.plist";
- public static final BundlerParamInfo<String> INSTALLER_SUFFIX = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<String> INSTALLER_SUFFIX =
+ new StandardBundlerParam<> (
I18N.getString("param.installer-suffix.name"),
I18N.getString("param.installer-suffix.description"),
"mac.dmg.installerName.suffix",
@@ -80,13 +82,15 @@
try {
appImageDir.mkdirs();
- if (prepareAppBundle(params, true) != null && prepareConfigFiles(params)) {
+ if (prepareAppBundle(params, true) != null &&
+ prepareConfigFiles(params)) {
File configScript = getConfig_Script(params);
if (configScript.exists()) {
Log.info(MessageFormat.format(
I18N.getString("message.running-script"),
configScript.getAbsolutePath()));
- IOUtils.run("bash", configScript, ECHO_MODE.fetchFrom(params));
+ IOUtils.run("bash", configScript,
+ ECHO_MODE.fetchFrom(params));
}
return buildDMG(params, outdir);
@@ -97,19 +101,24 @@
return null;
} finally {
try {
- if (appImageDir != null && PREDEFINED_APP_IMAGE.fetchFrom(params) == null &&
- (PREDEFINED_RUNTIME_IMAGE.fetchFrom(params) == null || !Arguments.CREATE_JRE_INSTALLER.fetchFrom(params)) && !Log.isDebug()) {
+ if (appImageDir != null &&
+ PREDEFINED_APP_IMAGE.fetchFrom(params) == null &&
+ (PREDEFINED_RUNTIME_IMAGE.fetchFrom(params) == null ||
+ !Arguments.CREATE_JRE_INSTALLER.fetchFrom(params)) &&
+ !Log.isDebug()) {
IOUtils.deleteRecursive(appImageDir);
} else if (appImageDir != null) {
Log.info(MessageFormat.format(I18N.getString(
- "message.intermediate-image-location"), appImageDir.getAbsolutePath()));
+ "message.intermediate-image-location"),
+ appImageDir.getAbsolutePath()));
}
if (!ECHO_MODE.fetchFrom(params)) {
//cleanup
cleanupConfigFiles(params);
} else {
Log.info(MessageFormat.format(I18N.getString(
- "message.config-save-location"), CONFIG_ROOT.fetchFrom(params).getAbsolutePath()));
+ "message.config-save-location"),
+ CONFIG_ROOT.fetchFrom(params).getAbsolutePath()));
}
} catch (IOException ex) {
Log.debug(ex);
@@ -161,7 +170,8 @@
Writer w = new BufferedWriter(new FileWriter(dmgSetup));
w.write(preprocessTextResource(
MacAppBundler.MAC_BUNDLER_PREFIX + dmgSetup.getName(),
- I18N.getString("resource.dmg-setup-script"), DEFAULT_DMG_SETUP_SCRIPT, data, VERBOSE.fetchFrom(p),
+ I18N.getString("resource.dmg-setup-script"),
+ DEFAULT_DMG_SETUP_SCRIPT, data, VERBOSE.fetchFrom(p),
DROP_IN_RESOURCES_ROOT.fetchFrom(p)));
w.close();
}
@@ -171,7 +181,8 @@
APP_NAME.fetchFrom(params) + "-dmg-setup.scpt");
}
- private File getConfig_VolumeBackground(Map<String, ? super Object> params) {
+ private File getConfig_VolumeBackground(
+ Map<String, ? super Object> params) {
return new File(CONFIG_ROOT.fetchFrom(params),
APP_NAME.fetchFrom(params) + "-background.png");
}
@@ -204,20 +215,24 @@
}
if (licFile == null) {
- // this is NPE protection, validate should have caught it's absence
+ // this is NPE protection,
+ // validate should have caught it's absence
// so we don't complain or throw an error
return;
}
byte[] licenseContentOriginal = IOUtils.readFully(licFile);
- String licenseInBase64 = Base64.getEncoder().encodeToString(licenseContentOriginal);
+ String licenseInBase64 =
+ Base64.getEncoder().encodeToString(licenseContentOriginal);
Map<String, String> data = new HashMap<>();
data.put("APPLICATION_LICENSE_TEXT", licenseInBase64);
- Writer w = new BufferedWriter(new FileWriter(getConfig_LicenseFile(params)));
+ Writer w = new BufferedWriter(
+ new FileWriter(getConfig_LicenseFile(params)));
w.write(preprocessTextResource(
- MacAppBundler.MAC_BUNDLER_PREFIX + getConfig_LicenseFile(params).getName(),
+ MacAppBundler.MAC_BUNDLER_PREFIX
+ + getConfig_LicenseFile(params).getName(),
I18N.getString("resource.license-setup"),
DEFAULT_LICENSE_PLIST, data, VERBOSE.fetchFrom(params),
DROP_IN_RESOURCES_ROOT.fetchFrom(params)));
@@ -226,7 +241,6 @@
} catch (IOException ex) {
Log.verbose(ex);
}
-
}
private boolean prepareConfigFiles(Map<String, ? super Object> params)
@@ -242,14 +256,16 @@
File iconTarget = getConfig_VolumeIcon(params);
if (MacAppBundler.ICON_ICNS.fetchFrom(params) == null ||
!MacAppBundler.ICON_ICNS.fetchFrom(params).exists()) {
- fetchResource(MacAppBundler.MAC_BUNDLER_PREFIX + iconTarget.getName(),
+ fetchResource(
+ MacAppBundler.MAC_BUNDLER_PREFIX + iconTarget.getName(),
I18N.getString("resource.volume-icon"),
TEMPLATE_BUNDLE_ICON,
iconTarget,
VERBOSE.fetchFrom(params),
DROP_IN_RESOURCES_ROOT.fetchFrom(params));
} else {
- fetchResource(MacAppBundler.MAC_BUNDLER_PREFIX + iconTarget.getName(),
+ fetchResource(
+ MacAppBundler.MAC_BUNDLER_PREFIX + iconTarget.getName(),
I18N.getString("resource.volume-icon"),
MacAppBundler.ICON_ICNS.fetchFrom(params),
iconTarget,
@@ -258,7 +274,8 @@
}
- fetchResource(MacAppBundler.MAC_BUNDLER_PREFIX + getConfig_Script(params).getName(),
+ fetchResource(MacAppBundler.MAC_BUNDLER_PREFIX
+ + getConfig_Script(params).getName(),
I18N.getString("resource.post-install-script"),
(String) null,
getConfig_Script(params),
@@ -267,11 +284,11 @@
prepareLicense(params);
- //In theory we need to extract name from results of attach command
- //However, this will be a problem for customization as name will
- //possibly change every time and developer will not be able to fix it
- //As we are using tmp dir chance we get "different" namr are low =>
- //Use fixed name we used for bundle
+ // In theory we need to extract name from results of attach command
+ // However, this will be a problem for customization as name will
+ // possibly change every time and developer will not be able to fix it
+ // As we are using tmp dir chance we get "different" namr are low =>
+ // Use fixed name we used for bundle
prepareDMGSetupScript(APP_NAME.fetchFrom(params), params);
return true;
@@ -279,10 +296,11 @@
//name of post-image script
private File getConfig_Script(Map<String, ? super Object> params) {
- return new File(CONFIG_ROOT.fetchFrom(params), APP_NAME.fetchFrom(params) + "-post-image.sh");
+ return new File(CONFIG_ROOT.fetchFrom(params),
+ APP_NAME.fetchFrom(params) + "-post-image.sh");
}
- //Location of SetFile utility may be different depending on MacOS version
+ // Location of SetFile utility may be different depending on MacOS version
// We look for several known places and if none of them work will
// try ot find it
private String findSetFileUtility() {
@@ -337,7 +355,8 @@
protoDMG.delete();
if (finalDMG.exists() && !finalDMG.delete()) {
throw new IOException(MessageFormat.format(I18N.getString(
- "message.dmg-cannot-be-overwritten"), finalDMG.getAbsolutePath()));
+ "message.dmg-cannot-be-overwritten"),
+ finalDMG.getAbsolutePath()));
}
protoDMG.getParentFile().mkdirs();
@@ -366,7 +385,8 @@
"-mountroot", imagesRoot.getAbsolutePath());
IOUtils.exec(pb, ECHO_MODE.fetchFrom(p));
- File mountedRoot = new File(imagesRoot.getAbsolutePath(), APP_NAME.fetchFrom(p));
+ File mountedRoot =
+ new File(imagesRoot.getAbsolutePath(), APP_NAME.fetchFrom(p));
//volume icon
File volumeIconFile = new File(mountedRoot, ".VolumeIcon.icns");
@@ -377,16 +397,19 @@
getConfig_VolumeScript(p).getAbsolutePath());
IOUtils.exec(pb, ECHO_MODE.fetchFrom(p));
- //Indicate that we want a custom icon
- //NB: attributes of the root directory are ignored when creating the volume
- // Therefore we have to do this after we mount image
+ // Indicate that we want a custom icon
+ // NB: attributes of the root directory are ignored
+ // when creating the volume
+ // Therefore we have to do this after we mount image
String setFileUtility = findSetFileUtility();
- if (setFileUtility != null) { //can not find utility => keep going without icon
+ if (setFileUtility != null) {
+ //can not find utility => keep going without icon
try {
volumeIconFile.setWritable(true);
// The "creator" attribute on a file is a legacy attribute
- // but it seems Finder excepts these bytes to be "icnC" for the volume icon
- // (http://endrift.com/blog/2010/06/14/dmg-files-volume-icons-cli/)
+ // but it seems Finder excepts these bytes to be
+ // "icnC" for the volume icon
+ // http://endrift.com/blog/2010/06/14/dmg-files-volume-icons-cli
// (might not work on Mac 10.13 with old XCode)
pb = new ProcessBuilder(
setFileUtility,
@@ -402,10 +425,12 @@
IOUtils.exec(pb, ECHO_MODE.fetchFrom(p));
} catch (IOException ex) {
Log.info(ex.getMessage());
- Log.verbose("Cannot enable custom icon using SetFile utility");
+ Log.verbose(
+ "Cannot enable custom icon using SetFile utility");
}
} else {
- Log.verbose("Skip enabling custom icon as SetFile utility is not found");
+ Log.verbose(
+ "Skip enabling custom icon as SetFile utility is not found");
}
// Detach the temporary image
@@ -467,9 +492,9 @@
}
- //////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////
// Implement Bundler
- //////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////
@Override
public String getName() {
@@ -521,7 +546,8 @@
// validate license file, if used, exists in the proper place
if (params.containsKey(LICENSE_FILE.getID())) {
- List<RelativeFileSet> appResourcesList = APP_RESOURCES_LIST.fetchFrom(params);
+ List<RelativeFileSet> appResourcesList =
+ APP_RESOURCES_LIST.fetchFrom(params);
for (String license : LICENSE_FILE.fetchFrom(params)) {
boolean found = false;
for (RelativeFileSet appResources : appResourcesList) {
@@ -530,9 +556,8 @@
if (!found) {
throw new ConfigException(
I18N.getString("error.license-missing"),
- MessageFormat.format(
- I18N.getString("error.license-missing.advice"),
- license));
+ MessageFormat.format(I18N.getString(
+ "error.license-missing.advice"), license));
}
}
}
@@ -548,7 +573,8 @@
}
@Override
- public File execute(Map<String, ? super Object> params, File outputParentDir) {
+ public File execute(
+ Map<String, ? super Object> params, File outputParentDir) {
return bundle(params, outputParentDir);
}
--- a/src/jdk.packager/macosx/classes/jdk/packager/internal/mac/MacPkgBundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/macosx/classes/jdk/packager/internal/mac/MacPkgBundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -56,56 +56,67 @@
import java.util.ResourceBundle;
import static jdk.packager.internal.StandardBundlerParam.*;
-import static jdk.packager.internal.mac.MacBaseInstallerBundler.SIGNING_KEYCHAIN;
-import static jdk.packager.internal.mac.MacBaseInstallerBundler.SIGNING_KEY_USER;
+import static
+ jdk.packager.internal.mac.MacBaseInstallerBundler.SIGNING_KEYCHAIN;
+import static
+ jdk.packager.internal.mac.MacBaseInstallerBundler.SIGNING_KEY_USER;
public class MacPkgBundler extends MacBaseInstallerBundler {
- private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.mac.MacPkgBundler");
+ private static final ResourceBundle I18N = ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.mac.MacPkgBundler");
public final static String MAC_BUNDLER_PREFIX =
BUNDLER_PREFIX + "macosx" + File.separator;
private static final String DEFAULT_BACKGROUND_IMAGE = "background_pkg.png";
- private static final String TEMPLATE_PREINSTALL_SCRIPT = "preinstall.template";
- private static final String TEMPLATE_POSTINSTALL_SCRIPT = "postinstall.template";
+ private static final String TEMPLATE_PREINSTALL_SCRIPT =
+ "preinstall.template";
+ private static final String TEMPLATE_POSTINSTALL_SCRIPT =
+ "postinstall.template";
- private static final BundlerParamInfo<File> PACKAGES_ROOT = new StandardBundlerParam<>(
+ private static final BundlerParamInfo<File> PACKAGES_ROOT =
+ new StandardBundlerParam<>(
I18N.getString("param.packages-root.name"),
I18N.getString("param.packages-root.description"),
"mac.pkg.packagesRoot",
File.class,
params -> {
- File packagesRoot = new File(BUILD_ROOT.fetchFrom(params), "packages");
+ File packagesRoot =
+ new File(BUILD_ROOT.fetchFrom(params), "packages");
packagesRoot.mkdirs();
return packagesRoot;
},
(s, p) -> new File(s));
- protected final BundlerParamInfo<File> SCRIPTS_DIR = new StandardBundlerParam<>(
+ protected final BundlerParamInfo<File> SCRIPTS_DIR =
+ new StandardBundlerParam<>(
I18N.getString("param.scripts-dir.name"),
I18N.getString("param.scripts-dir.description"),
"mac.pkg.scriptsDir",
File.class,
params -> {
- File scriptsDir = new File(CONFIG_ROOT.fetchFrom(params), "scripts");
+ File scriptsDir =
+ new File(CONFIG_ROOT.fetchFrom(params), "scripts");
scriptsDir.mkdirs();
return scriptsDir;
},
(s, p) -> new File(s));
- public static final BundlerParamInfo<String> DEVELOPER_ID_INSTALLER_SIGNING_KEY =
+ public static final
+ BundlerParamInfo<String> DEVELOPER_ID_INSTALLER_SIGNING_KEY =
new StandardBundlerParam<>(
I18N.getString("param.signing-key-developer-id-installer.name"),
- I18N.getString("param.signing-key-developer-id-installer.description"),
+ I18N.getString(
+ "param.signing-key-developer-id-installer.description"),
"mac.signing-key-developer-id-installer",
String.class,
params -> {
String result = MacBaseInstallerBundler.findKey(
- "Developer ID Installer: " + SIGNING_KEY_USER.fetchFrom(params),
+ "Developer ID Installer: "
+ + SIGNING_KEY_USER.fetchFrom(params),
SIGNING_KEYCHAIN.fetchFrom(params),
VERBOSE.fetchFrom(params));
if (result != null) {
@@ -150,7 +161,7 @@
baseResourceLoader = MacResources.class;
}
- //@Override
+ // @Override
public File bundle(Map<String, ? super Object> params, File outdir) {
Log.info(MessageFormat.format(I18N.getString("message.building-pkg"),
APP_NAME.fetchFrom(params)));
@@ -176,7 +187,8 @@
Log.info(MessageFormat.format(I18N.getString(
"message.running-script"),
configScript.getAbsolutePath()));
- IOUtils.run("bash", configScript, ECHO_MODE.fetchFrom(params));
+ IOUtils.run("bash", configScript,
+ ECHO_MODE.fetchFrom(params));
}
return createPKG(params, outdir, appImageDir);
@@ -189,16 +201,17 @@
try {
if (appImageDir != null &&
PREDEFINED_APP_IMAGE.fetchFrom(params) == null &&
- (PREDEFINED_RUNTIME_IMAGE.fetchFrom(params) == null || !Arguments.CREATE_JRE_INSTALLER.fetchFrom(params)) &&
+ (PREDEFINED_RUNTIME_IMAGE.fetchFrom(params) == null ||
+ !Arguments.CREATE_JRE_INSTALLER.fetchFrom(params)) &&
!Log.isDebug()) {
IOUtils.deleteRecursive(appImageDir);
} else if (appImageDir != null) {
- Log.info(MessageFormat.format(
- I18N.getString("message.intermediate-image-location"),
+ Log.info(MessageFormat.format(I18N.getString(
+ "message.intermediate-image-location"),
appImageDir.getAbsolutePath()));
}
if (!ECHO_MODE.fetchFrom(params)) {
- //cleanup
+ // cleanup
cleanupConfigFiles(params);
} else {
Log.info(MessageFormat.format(
@@ -207,7 +220,7 @@
}
} catch (IOException ex) {
Log.debug(ex);
- //noinspection ReturnInsideFinallyBlock
+ // noinspection ReturnInsideFinallyBlock
return null;
}
}
@@ -234,20 +247,22 @@
}
}
- private File getConfig_DistributionXMLFile(Map<String, ? super Object> params) {
+ private File getConfig_DistributionXMLFile(
+ Map<String, ? super Object> params) {
return new File(CONFIG_ROOT.fetchFrom(params), "distribution.dist");
}
private File getConfig_BackgroundImage(Map<String, ? super Object> params) {
- return new File(CONFIG_ROOT.fetchFrom(params), APP_NAME.fetchFrom(params)
- + "-background.png");
+ return new File(CONFIG_ROOT.fetchFrom(params),
+ APP_NAME.fetchFrom(params) + "-background.png");
}
private File getScripts_PreinstallFile(Map<String, ? super Object> params) {
return new File(SCRIPTS_DIR.fetchFrom(params), "preinstall");
}
- private File getScripts_PostinstallFile(Map<String, ? super Object> params) {
+ private File getScripts_PostinstallFile(
+ Map<String, ? super Object> params) {
return new File(SCRIPTS_DIR.fetchFrom(params), "postinstall");
}
@@ -291,9 +306,10 @@
data.put("DEPLOY_LAUNCHD_PLIST_FILE",
IDENTIFIER.fetchFrom(params).toLowerCase() + ".launchd.plist");
- Writer w = new BufferedWriter(new FileWriter(getScripts_PreinstallFile(params)));
- String content = preprocessTextResource(
- MAC_BUNDLER_PREFIX + getScripts_PreinstallFile(params).getName(),
+ Writer w = new BufferedWriter(
+ new FileWriter(getScripts_PreinstallFile(params)));
+ String content = preprocessTextResource(MAC_BUNDLER_PREFIX
+ + getScripts_PreinstallFile(params).getName(),
I18N.getString("resource.pkg-preinstall-script"),
TEMPLATE_PREINSTALL_SCRIPT,
data,
@@ -303,9 +319,10 @@
w.close();
getScripts_PreinstallFile(params).setExecutable(true, false);
- w = new BufferedWriter(new FileWriter(getScripts_PostinstallFile(params)));
- content = preprocessTextResource(
- MAC_BUNDLER_PREFIX + getScripts_PostinstallFile(params).getName(),
+ w = new BufferedWriter(
+ new FileWriter(getScripts_PostinstallFile(params)));
+ content = preprocessTextResource(MAC_BUNDLER_PREFIX
+ + getScripts_PostinstallFile(params).getName(),
I18N.getString("resource.pkg-postinstall-script"),
TEMPLATE_POSTINSTALL_SCRIPT,
data,
@@ -317,8 +334,7 @@
}
private void prepareDistributionXMLFile(Map<String, ? super Object> params)
- throws IOException
- {
+ throws IOException {
File f = getConfig_DistributionXMLFile(params);
Log.verbose(MessageFormat.format(I18N.getString(
@@ -326,16 +342,18 @@
PrintStream out = new PrintStream(f);
- out.println("<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>");
+ out.println(
+ "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>");
out.println("<installer-gui-script minSpecVersion=\"1\">");
out.println("<title>" + APP_NAME.fetchFrom(params) + "</title>");
- out.println("<background" +
- " file=\"" + getConfig_BackgroundImage(params).getName() + "\"" +
- " mime-type=\"image/png\"" +
- " alignment=\"bottomleft\" " +
- " scaling=\"none\""+
- "/>");
+ out.println("<background" + " file=\""
+ + getConfig_BackgroundImage(params).getName()
+ + "\""
+ + " mime-type=\"image/png\""
+ + " alignment=\"bottomleft\" "
+ + " scaling=\"none\""
+ + "/>");
if (!LICENSE_FILE.fetchFrom(params).isEmpty()) {
File licFile = null;
@@ -383,17 +401,18 @@
out.println("<choice id=\"" + appId + "\" visible=\"false\">");
out.println(" <pkg-ref id=\"" + appId + "\"/>");
out.println("</choice>");
- out.println("<pkg-ref id=\"" + appId + "\" version=\"" + VERSION.fetchFrom(params) +
- "\" onConclusion=\"none\">" +
- URLEncoder.encode(getPackages_AppPackage(params).getName(),
- "UTF-8") + "</pkg-ref>");
+ out.println("<pkg-ref id=\"" + appId + "\" version=\""
+ + VERSION.fetchFrom(params) + "\" onConclusion=\"none\">"
+ + URLEncoder.encode(getPackages_AppPackage(params).getName(),
+ "UTF-8") + "</pkg-ref>");
out.println("</installer-gui-script>");
out.close();
}
- private boolean prepareConfigFiles(Map<String, ? super Object> params) throws IOException {
+ private boolean prepareConfigFiles(Map<String, ? super Object> params)
+ throws IOException {
File imageTarget = getConfig_BackgroundImage(params);
fetchResource(MacAppBundler.MAC_BUNDLER_PREFIX + imageTarget.getName(),
I18N.getString("resource.pkg-background-image"),
@@ -404,7 +423,8 @@
prepareDistributionXMLFile(params);
- fetchResource(MacAppBundler.MAC_BUNDLER_PREFIX + getConfig_Script(params).getName(),
+ fetchResource(MacAppBundler.MAC_BUNDLER_PREFIX
+ + getConfig_Script(params).getName(),
I18N.getString("resource.post-install-script"),
(String) null,
getConfig_Script(params),
@@ -414,15 +434,15 @@
return true;
}
- //name of post-image script
+ // name of post-image script
private File getConfig_Script(Map<String, ? super Object> params) {
- return new File(CONFIG_ROOT.fetchFrom(params), APP_NAME.fetchFrom(params)
- + "-post-image.sh");
+ return new File(CONFIG_ROOT.fetchFrom(params),
+ APP_NAME.fetchFrom(params) + "-post-image.sh");
}
private File createPKG(Map<String, ? super Object> params,
File outdir, File appLocation) {
- //generic find attempt
+ // generic find attempt
try {
File appPKG = getPackages_AppPackage(params);
@@ -448,14 +468,17 @@
commandLine.add(CONFIG_ROOT.fetchFrom(params).getAbsolutePath());
// maybe sign
- if (Optional.ofNullable(MacAppImageBuilder.SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.TRUE)) {
+ if (Optional.ofNullable(MacAppImageBuilder.
+ SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.TRUE)) {
if (Platform.getMajorVersion() > 10 ||
- (Platform.getMajorVersion() == 10 && Platform.getMinorVersion() >= 12)) {
+ (Platform.getMajorVersion() == 10 &&
+ Platform.getMinorVersion() >= 12)) {
// we need this for OS X 10.12+
Log.info(I18N.getString("message.signing.pkg"));
}
- String signingIdentity = DEVELOPER_ID_INSTALLER_SIGNING_KEY.fetchFrom(params);
+ String signingIdentity =
+ DEVELOPER_ID_INSTALLER_SIGNING_KEY.fetchFrom(params);
if (signingIdentity != null) {
commandLine.add("--sign");
commandLine.add(signingIdentity);
@@ -469,7 +492,8 @@
}
commandLine.add("--distribution");
- commandLine.add(getConfig_DistributionXMLFile(params).getAbsolutePath());
+ commandLine.add(
+ getConfig_DistributionXMLFile(params).getAbsolutePath());
commandLine.add("--package-path");
commandLine.add(PACKAGES_ROOT.fetchFrom(params).getAbsolutePath());
@@ -490,9 +514,9 @@
}
}
- //////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////
// Implement Bundler
- //////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////
@Override
public String getName() {
@@ -523,29 +547,31 @@
results.addAll(MacAppBundler.getAppBundleParameters());
results.addAll(Arrays.asList(
DEVELOPER_ID_INSTALLER_SIGNING_KEY,
- //IDENTIFIER,
+ // IDENTIFIER,
INSTALLER_SUFFIX,
LICENSE_FILE,
- //SERVICE_HINT,
+ // SERVICE_HINT,
SIGNING_KEYCHAIN));
return results;
}
@Override
- public boolean validate(Map<String, ? super Object> params) throws UnsupportedPlatformException, ConfigException {
+ 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
+ // run basic validation to ensure requirements are met
+ // we are not interested in return code, only possible exception
validateAppImageAndBundeler(params);
// validate license file, if used, exists in the proper place
if (params.containsKey(LICENSE_FILE.getID())) {
- List<RelativeFileSet> appResourcesList = APP_RESOURCES_LIST.fetchFrom(params);
+ List<RelativeFileSet> appResourcesList =
+ APP_RESOURCES_LIST.fetchFrom(params);
for (String license : LICENSE_FILE.fetchFrom(params)) {
boolean found = false;
for (RelativeFileSet appResources : appResourcesList) {
@@ -554,23 +580,28 @@
if (!found) {
throw new ConfigException(
I18N.getString("error.license-missing"),
- MessageFormat.format(I18N.getString("error.license-missing.advice"),
- license));
+ MessageFormat.format(
+ I18N.getString("error.license-missing.advice"),
+ license));
}
}
}
// reject explicitly set sign to true and no valid signature key
- if (Optional.ofNullable(MacAppImageBuilder.SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.FALSE)) {
- String signingIdentity = DEVELOPER_ID_INSTALLER_SIGNING_KEY.fetchFrom(params);
+ if (Optional.ofNullable(MacAppImageBuilder.
+ SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.FALSE)) {
+ String signingIdentity =
+ DEVELOPER_ID_INSTALLER_SIGNING_KEY.fetchFrom(params);
if (signingIdentity == null) {
throw new ConfigException(
I18N.getString("error.explicit-sign-no-cert"),
- I18N.getString("error.explicit-sign-no-cert.advice"));
+ I18N.getString(
+ "error.explicit-sign-no-cert.advice"));
}
}
- // hdiutil is always available so there's no need to test for availability.
+ // hdiutil is always available so there's no need
+ // to test for availability.
return true;
} catch (RuntimeException re) {
@@ -583,7 +614,8 @@
}
@Override
- public File execute(Map<String, ? super Object> params, File outputParentDir) {
+ public File execute(
+ Map<String, ? super Object> params, File outputParentDir) {
return bundle(params, outputParentDir);
}
--- a/src/jdk.packager/macosx/classes/jdk/packager/internal/resources/mac/MacResources.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/macosx/classes/jdk/packager/internal/resources/mac/MacResources.java Mon Aug 27 16:01:38 2018 -0400
@@ -25,7 +25,7 @@
package jdk.packager.internal.resources.mac;
-//no-op, use as anchor for resource loading
+// no-op, use as anchor for resource loading
public class MacResources {
}
--- a/src/jdk.packager/share/classes/jdk/packager/Main.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/Main.java Mon Aug 27 16:01:38 2018 -0400
@@ -48,7 +48,8 @@
System.exit(status);
}
- public static int run(PrintWriter out, PrintWriter err, String... args) throws Exception {
+ public static int run(PrintWriter out, PrintWriter err, String... args)
+ throws Exception {
// Create logger with provided streams
Log.Logger logger = new Log.Logger(false);
logger.setPrintWriter(out, err);
--- a/src/jdk.packager/share/classes/jdk/packager/internal/AbstractBundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/AbstractBundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -40,15 +40,17 @@
public abstract class AbstractBundler implements Bundler {
- private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.AbstractBundler");
+ private static final ResourceBundle I18N = ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.AbstractBundler");
- public static final BundlerParamInfo<File> IMAGES_ROOT = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> IMAGES_ROOT =
+ new StandardBundlerParam<>(
I18N.getString("param.images-root.name"),
I18N.getString("param.images-root.description"),
"imagesRoot",
File.class,
- params -> new File(StandardBundlerParam.BUILD_ROOT.fetchFrom(params), "images"),
+ params -> new File(
+ StandardBundlerParam.BUILD_ROOT.fetchFrom(params), "images"),
(s, p) -> null);
// do not use file separator -
@@ -64,12 +66,14 @@
InputStream is = streamResource(publicName, category,
defaultName, verbose, publicRoot);
if (is != null) {
- Files.copy(is, result.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(is, result.toPath(),
+ StandardCopyOption.REPLACE_EXISTING);
} else {
if (verbose) {
Log.info(MessageFormat.format(I18N.getString(
"message.using-default-resource"),
- category == null ? "" : "[" + category + "] ", publicName));
+ category == null ? "" : "[" + category + "] ",
+ publicName));
}
}
}
@@ -94,7 +98,8 @@
}
private InputStream streamResource(String publicName, String category,
- String defaultName, boolean verbose, File publicRoot) throws IOException {
+ String defaultName, boolean verbose, File publicRoot)
+ throws IOException {
boolean custom = false;
InputStream is = null;
if (publicName != null) {
@@ -104,7 +109,8 @@
is = new FileInputStream(publicResource);
}
} else {
- is = baseResourceLoader.getClassLoader().getResourceAsStream(publicName);
+ is = baseResourceLoader.getClassLoader().getResourceAsStream(
+ publicName);
}
custom = (is != null);
}
@@ -128,11 +134,13 @@
}
protected String preprocessTextResource(String publicName, String category,
- String defaultName, Map<String, String> pairs,
- boolean verbose, File publicRoot) throws IOException {
- InputStream inp = streamResource(publicName, category, defaultName, verbose, publicRoot);
+ String defaultName, Map<String, String> pairs,
+ boolean verbose, File publicRoot) throws IOException {
+ InputStream inp = streamResource(
+ publicName, category, defaultName, verbose, publicRoot);
if (inp == null) {
- throw new RuntimeException("Jar corrupt? No "+defaultName+" resource!");
+ throw new RuntimeException(
+ "Jar corrupt? No " + defaultName + " resource!");
}
// read fully into memory
@@ -162,7 +170,8 @@
public void cleanup(Map<String, ? super Object> params) {
if (!StandardBundlerParam.ECHO_MODE.fetchFrom(params)) {
try {
- IOUtils.deleteRecursive(StandardBundlerParam.BUILD_ROOT.fetchFrom(params));
+ IOUtils.deleteRecursive(
+ StandardBundlerParam.BUILD_ROOT.fetchFrom(params));
} catch (IOException e) {
Log.debug(e.getMessage());
}
--- a/src/jdk.packager/share/classes/jdk/packager/internal/AbstractImageBundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/AbstractImageBundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -39,10 +39,11 @@
*/
public abstract class AbstractImageBundler extends AbstractBundler {
- private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.AbstractImageBundler");
+ private static final ResourceBundle I18N = ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.AbstractImageBundler");
- public void imageBundleValidation(Map<String, ? super Object> p) throws ConfigException {
+ public void imageBundleValidation(Map<String, ? super Object> p)
+ throws ConfigException {
StandardBundlerParam.validateMainClassInfoFromAppResources(p);
Map<String, String> userJvmOptions = USER_JVM_OPTIONS.fetchFrom(p);
@@ -51,14 +52,16 @@
if (entry.getValue() == null || entry.getValue().isEmpty()) {
throw new ConfigException(
MessageFormat.format(I18N.getString(
- "error.empty-user-jvm-option-value"), entry.getKey()),
- I18N.getString("error.empty-user-jvm-option-value.advice"));
+ "error.empty-user-jvm-option-value"),
+ entry.getKey()), I18N.getString(
+ "error.empty-user-jvm-option-value.advice"));
}
}
}
boolean hasMainJar = MAIN_JAR.fetchFrom(p) != null;
- boolean hasMainModule = StandardBundlerParam.MODULE.fetchFrom(p) != null;
+ boolean hasMainModule =
+ StandardBundlerParam.MODULE.fetchFrom(p) != null;
boolean hasMainClass = MAIN_CLASS.fetchFrom(p) != null;
boolean jreInstaller = Arguments.CREATE_JRE_INSTALLER.fetchFrom(p);
@@ -69,8 +72,8 @@
}
}
- public static void extractFlagsFromVersion(Map<String, ? super Object> params,
- String versionOutput) {
+ public static void extractFlagsFromVersion(
+ Map<String, ? super Object> params, String versionOutput) {
Pattern bitArchPattern = Pattern.compile("(\\d*)[- ]?[bB]it");
Matcher matcher = bitArchPattern.matcher(versionOutput);
if (matcher.find()) {
@@ -93,7 +96,8 @@
params.put(".runtime.version.patch", "0");
params.put(".runtime.version.modifiers", matcher.group(7));
} else {
- Pattern newVersionMatcher = Pattern.compile("java version \"((\\d+).(\\d+).(\\d+).(\\d+))(-(.*))?(\\+[^\"]*)?\"");
+ Pattern newVersionMatcher = Pattern.compile(
+ "java version \"((\\d+).(\\d+).(\\d+).(\\d+))(-(.*))?(\\+[^\"]*)?\"");
matcher = newVersionMatcher.matcher(versionOutput);
if (matcher.find()) {
params.put(".runtime.version", matcher.group(1));
--- a/src/jdk.packager/share/classes/jdk/packager/internal/Arguments.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/Arguments.java Mon Aug 27 16:01:38 2018 -0400
@@ -51,8 +51,8 @@
import jdk.packager.internal.bundlers.BundleParams;
public class Arguments {
- private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.Arguments");
+ private static final ResourceBundle I18N = ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.Arguments");
private static final String IMAGE_MODE = "image";
private static final String INSTALLER_MODE = "installer";
@@ -70,8 +70,8 @@
IMAGE_MODE,
Boolean.class,
p -> Boolean.FALSE,
- (s, p) -> (s == null || "null".equalsIgnoreCase(s))?
- true : Boolean.valueOf(s));
+ (s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
+ true : Boolean.valueOf(s));
public static final BundlerParamInfo<Boolean> CREATE_INSTALLER =
new StandardBundlerParam<>(
@@ -80,8 +80,8 @@
INSTALLER_MODE,
Boolean.class,
p -> Boolean.FALSE,
- (s, p) -> (s == null || "null".equalsIgnoreCase(s))?
- true : Boolean.valueOf(s));
+ (s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
+ true : Boolean.valueOf(s));
public static final BundlerParamInfo<Boolean> CREATE_JRE_INSTALLER =
new StandardBundlerParam<>(
@@ -90,13 +90,12 @@
JRE_INSTALLER_MODE,
Boolean.class,
p -> Boolean.FALSE,
- (s, p) -> (s == null || "null".equalsIgnoreCase(s))?
- true : Boolean.valueOf(s));
+ (s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
+ true : Boolean.valueOf(s));
// regexp for parsing args (for example, for secondary launchers)
- private static Pattern pattern
- = Pattern.compile(
- "(?:(?:([\"'])(?:\\\\\\1|.)*?(?:\\1|$))|(?:\\\\[\"'\\s]|[^\\s]))++");
+ private static Pattern pattern = Pattern.compile(
+ "(?:(?:([\"'])(?:\\\\\\1|.)*?(?:\\1|$))|(?:\\\\[\"'\\s]|[^\\s]))++");
private DeployParams deployParams = null;
private Bundler.BundleType bundleType = null;
@@ -222,7 +221,8 @@
context().files = new ArrayList<>();
String files = popArg();
// TODO: should we split using ' '(space) ?
- context().files.addAll(Arrays.asList(files.split(File.pathSeparator)));
+ context().files.addAll(
+ Arrays.asList(files.split(File.pathSeparator)));
}),
ARGUMENTS ("arguments", "a", OptionCategories.PROPERTY, () -> {
@@ -230,7 +230,8 @@
setOptionValue("arguments", arguments);
}),
- STRIP_NATIVE_COMMANDS ("strip-native-commands", OptionCategories.PROPERTY, () -> {
+ STRIP_NATIVE_COMMANDS ("strip-native-commands",
+ OptionCategories.PROPERTY, () -> {
setOptionValue("strip-native-commands", true);
}),
@@ -252,7 +253,8 @@
args.forEach(a -> setOptionValue("user-jvm-args", a));
}),
- FILE_ASSOCIATIONS ("file-associations", OptionCategories.PROPERTY, () -> {
+ FILE_ASSOCIATIONS ("file-associations",
+ OptionCategories.PROPERTY, () -> {
Map<String, ? super Object> args = new HashMap<>();
// load .properties file
@@ -354,33 +356,37 @@
WIN_MENU_GROUP ("win-menu-group", OptionCategories.PLATFORM_WIN),
- WIN_SHORTCUT_HINT ("win-shortcut", OptionCategories.PLATFORM_WIN, () -> {
+ WIN_SHORTCUT_HINT ("win-shortcut",
+ OptionCategories.PLATFORM_WIN, () -> {
setOptionValue("win-shortcut", true);
}),
WIN_PER_USER_INSTALLATION ("win-per-user-install",
- OptionCategories.PLATFORM_WIN, () -> {
+ OptionCategories.PLATFORM_WIN, () -> {
setOptionValue("win-per-user-install", false);
}),
- WIN_DIR_CHOOSER ("win-dir-chooser", OptionCategories.PLATFORM_WIN, () -> {
+ WIN_DIR_CHOOSER ("win-dir-chooser",
+ OptionCategories.PLATFORM_WIN, () -> {
setOptionValue("win-dir-chooser", true);
}),
WIN_REGISTRY_NAME ("win-registry-name", OptionCategories.PLATFORM_WIN),
- WIN_MSI_UPGRADE_UUID ("win-upgrade-uuid", OptionCategories.PLATFORM_WIN),
+ WIN_MSI_UPGRADE_UUID ("win-upgrade-uuid",
+ OptionCategories.PLATFORM_WIN),
- LINUX_BUNDLE_NAME ("linux-bundle-name", OptionCategories.PLATFORM_LINUX),
+ LINUX_BUNDLE_NAME ("linux-bundle-name",
+ OptionCategories.PLATFORM_LINUX),
LINUX_DEB_MAINTAINER ("linux-deb-maintainer",
- OptionCategories.PLATFORM_LINUX),
+ OptionCategories.PLATFORM_LINUX),
LINUX_RPM_LICENSE_TYPE ("linux-rpm-license-type",
- OptionCategories.PLATFORM_LINUX),
+ OptionCategories.PLATFORM_LINUX),
LINUX_PACKAGE_DEPENDENCIES ("linux-package-deps",
- OptionCategories.PLATFORM_LINUX);
+ OptionCategories.PLATFORM_LINUX);
private final String id;
private final String shortId;
@@ -397,7 +403,8 @@
this(id, shortId, category, null);
}
- private CLIOptions(String id, OptionCategories category, ArgAction action) {
+ private CLIOptions(String id,
+ OptionCategories category, ArgAction action) {
this(id, null, category, action);
}
@@ -529,13 +536,16 @@
return false;
}
- if (!hasMainJar && !hasMainModule && !hasMainClass && !jreInstaller) {
- Log.info("ERROR: Main jar or main class or main module must be specified.");
+ if (!hasMainJar && !hasMainModule &&
+ !hasMainClass && !jreInstaller) {
+ Log.info("ERROR: Main jar or main class or main module "
+ + "must be specified.");
} else if (!hasMainModule && !hasMainClass) {
// try to get main-class from manifest
String mainClass = getMainClassFromManifest();
if (mainClass != null) {
- CLIOptions.setOptionValue(CLIOptions.APPCLASS.getId(), mainClass);
+ CLIOptions.setOptionValue(
+ CLIOptions.APPCLASS.getId(), mainClass);
}
}
@@ -548,15 +558,16 @@
deployParams.setBundleType(bundleType);
- List<Map<String, ? super Object>> launchersAsMap = new ArrayList<>();
+ List<Map<String, ? super Object>> launchersAsMap =
+ new ArrayList<>();
for (SecondaryLauncherArguments sl : secondaryLaunchers) {
launchersAsMap.add(sl.getLauncherMap());
}
deployParams.addBundleArgument(
- StandardBundlerParam.SECONDARY_LAUNCHERS.getID(),
- launchersAsMap);
+ StandardBundlerParam.SECONDARY_LAUNCHERS.getID(),
+ launchersAsMap);
// at this point deployParams should be already configured
@@ -583,8 +594,9 @@
CLIOptions mode = allOptions.get(0);
for (CLIOptions option : allOptions) {
if(!ValidOptions.checkIfSupported(mode, option)) {
- System.out.println("WARNING: argument [" + option.getId() + "] is not "
- + "supported for current configuration.");
+ System.out.println("WARNING: argument ["
+ + option.getId() + "] is not "
+ + "supported for current configuration.");
}
}
}
@@ -598,10 +610,10 @@
platformBundlers = new ArrayList<>();
for (jdk.packager.internal.Bundler bundler :
Bundlers.createBundlersInstance().getBundlers(
- bundleType.toString())) {
+ bundleType.toString())) {
if (hasTargetFormat && deployParams.getTargetFormat() != null &&
!deployParams.getTargetFormat().equalsIgnoreCase(
- bundler.getID())) {
+ bundler.getID())) {
continue;
}
if (bundler.supported()) {
@@ -612,12 +624,14 @@
return platformBundlers;
}
- private void generateBundle(Map<String,? super Object> params) throws PackagerException {
+ private void generateBundle(Map<String,? super Object> params)
+ throws PackagerException {
for (jdk.packager.internal.Bundler bundler : getPlatformBundlers()) {
Map<String, ? super Object> localParams = new HashMap<>(params);
try {
if (bundler.validate(localParams)) {
- File result = bundler.execute(localParams, deployParams.outdir);
+ File result =
+ bundler.execute(localParams, deployParams.outdir);
bundler.cleanup(localParams);
if (result == null) {
throw new PackagerException("MSG_BundlerFailed",
@@ -635,8 +649,8 @@
I18N.getString("MSG_BundlerConfigException"),
bundler.getName(), e.getMessage(), e.getAdvice()));
} else {
- Log.info(MessageFormat.format(
- I18N.getString("MSG_BundlerConfigExceptionNoAdvice"),
+ Log.info(MessageFormat.format(I18N.getString(
+ "MSG_BundlerConfigExceptionNoAdvice"),
bundler.getName(), e.getMessage()));
}
} catch (RuntimeException re) {
@@ -649,7 +663,7 @@
}
private void addResources(CommonParams commonParams,
- String inputdir, List<String> inputfiles) {
+ String inputdir, List<String> inputfiles) {
if (inputdir == null || inputdir.isEmpty()) {
return;
@@ -658,7 +672,8 @@
File baseDir = new File(inputdir);
if (!baseDir.isDirectory()) {
- Log.info("Unable to add resources: \"-srcdir\" is not a directory.");
+ Log.info(
+ "Unable to add resources: \"-srcdir\" is not a directory.");
return;
}
@@ -670,7 +685,8 @@
// is a mandatory argument in this case) will be packaged.
fileNames = new ArrayList<>();
try (Stream<Path> files = Files.list(baseDir.toPath())) {
- files.forEach(file -> fileNames.add(file.getFileName().toString()));
+ files.forEach(file -> fileNames.add(
+ file.getFileName().toString()));
} catch (IOException e) {
Log.info("Unable to add resources: " + e.getMessage());
}
--- a/src/jdk.packager/share/classes/jdk/packager/internal/Bundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/Bundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -69,17 +69,18 @@
* exception may contain advice on how to modify the params map
* to make it valid.
*/
- boolean validate(Map<String, ? super Object> params) throws UnsupportedPlatformException, ConfigException;
+ boolean validate(Map<String, ? super Object> params)
+ throws UnsupportedPlatformException, ConfigException;
/**
* Creates a bundle from existing content.
*
- * If a call to {@link #validate(java.util.Map)} date} returns true with the
- * parameters map, then you can expect a valid output. However if an exception
- * was thrown out of validate or it returned false then you should not
- * expect sensible results from this call. It may or may not return a value,
- * and it may or may not throw an exception. But any output should not
- * be considered valid or sane.
+ * If a call to {@link #validate(java.util.Map)} date} returns true with
+ * the parameters map, then you can expect a valid output.
+ * However if an exception was thrown out of validate or it returned
+ * false then you should not expect sensible results from this call.
+ * It may or may not return a value, and it may or may not throw an
+ * exception. But any output should not be considered valid or sane.
*
* @param params The parameters as specified by getBundleParameters.
* Keyed by the id from the ParamInfo. Execution may
@@ -112,7 +113,8 @@
* forward slashes.</li>
* </ul>
*/
- public File execute(Map<String, ? super Object> params, File outputParentDir);
+ public File execute(
+ Map<String, ? super Object> params, File outputParentDir);
/**
* Removes temporary files that are used for bundling.
--- a/src/jdk.packager/share/classes/jdk/packager/internal/BundlerParamInfo.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/BundlerParamInfo.java Mon Aug 27 16:01:38 2018 -0400
@@ -52,7 +52,8 @@
Class<T> valueType;
/**
- * If the value is not set, and no fallback value is found, the parameter uses the value returned by the producer.
+ * If the value is not set, and no fallback value is found,
+ * the parameter uses the value returned by the producer.
*/
Function<Map<String, ? super Object>, T> defaultValueFunction;
@@ -97,15 +98,18 @@
return defaultValueFunction;
}
- public void setDefaultValueFunction(Function<Map<String, ? super Object>, T> defaultValueFunction) {
+ public void setDefaultValueFunction(
+ Function<Map<String, ? super Object>, T> defaultValueFunction) {
this.defaultValueFunction = defaultValueFunction;
}
- public BiFunction<String, Map<String, ? super Object>,T> getStringConverter() {
+ public BiFunction<String, Map<String, ? super Object>,T>
+ getStringConverter() {
return stringConverter;
}
- public void setStringConverter(BiFunction<String, Map<String, ? super Object>, T> stringConverter) {
+ public void setStringConverter(BiFunction<String,
+ Map<String, ? super Object>, T> stringConverter) {
this.stringConverter = stringConverter;
}
@@ -115,7 +119,8 @@
}
@SuppressWarnings("unchecked")
- public final T fetchFrom(Map<String, ? super Object> params, boolean invokeDefault) {
+ public final T fetchFrom(Map<String, ? super Object> params,
+ boolean invokeDefault) {
Object o = params.get(getID());
if (o instanceof String && getStringConverter() != null) {
return getStringConverter().apply((String)o, params);
@@ -126,8 +131,9 @@
return (T) o;
}
if (o != null) {
- throw new IllegalArgumentException("Param " + getID() +
- " should be of type " + getValueType() + " but is a " + o.getClass());
+ throw new IllegalArgumentException("Param " + getID()
+ + " should be of type " + getValueType()
+ + " but is a " + o.getClass());
}
if (params.containsKey(getID())) {
// explicit nulls are allowed
--- a/src/jdk.packager/share/classes/jdk/packager/internal/Bundlers.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/Bundlers.java Mon Aug 27 16:01:38 2018 -0400
@@ -33,10 +33,12 @@
public interface Bundlers {
/**
- * This convenience method will call {@link #createBundlersInstance(ClassLoader)}
+ * This convenience method will call
+ * {@link #createBundlersInstance(ClassLoader)}
* with the classloader that this Bundlers is loaded from.
*
- * @return an instance of Bundlers loaded and configured from the current ClassLoader.
+ * @return an instance of Bundlers loaded and configured from
+ * the current ClassLoader.
*/
public static Bundlers createBundlersInstance() {
return createBundlersInstance(Bundlers.class.getClassLoader());
@@ -56,10 +58,13 @@
*
* @param servicesClassLoader the classloader to search for
* META-INF/service registered bundlers
- * @return an instance of Bundlers loaded and configured from the specified ClassLoader
+ * @return an instance of Bundlers loaded and configured from
+ * the specified ClassLoader
*/
- public static Bundlers createBundlersInstance(ClassLoader servicesClassLoader) {
- ServiceLoader<Bundlers> bundlersLoader = ServiceLoader.load(Bundlers.class, servicesClassLoader);
+ public static Bundlers createBundlersInstance(
+ ClassLoader servicesClassLoader) {
+ ServiceLoader<Bundlers> bundlersLoader =
+ ServiceLoader.load(Bundlers.class, servicesClassLoader);
Bundlers bundlers = null;
Iterator<Bundlers> iter = bundlersLoader.iterator();
if (iter.hasNext()) {
@@ -108,7 +113,8 @@
*
* </UL>
*
- * This method is called from the {@link #createBundlersInstance(ClassLoader)}
+ * This method is called from the
+ * {@link #createBundlersInstance(ClassLoader)}
* and {@link #createBundlersInstance()} methods.
* NOTE: Because of the module system this method is now not used.
*/
@@ -117,7 +123,8 @@
/**
* Loads bundlers from the META-INF/services directly.
*
- * This method is called from the {@link #createBundlersInstance(ClassLoader)}
+ * This method is called from the
+ * {@link #createBundlersInstance(ClassLoader)}
* and {@link #createBundlersInstance()} methods.
*/
void loadBundlersFromServices(ClassLoader cl);
--- a/src/jdk.packager/share/classes/jdk/packager/internal/CLIHelp.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/CLIHelp.java Mon Aug 27 16:01:38 2018 -0400
@@ -29,8 +29,8 @@
public class CLIHelp {
- private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.CLIHelp");
+ private static final ResourceBundle I18N = ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.CLIHelp");
// generates --help for jpackager's CLI
public static void showHelp() {
--- a/src/jdk.packager/share/classes/jdk/packager/internal/CommonParams.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/CommonParams.java Mon Aug 27 16:01:38 2018 -0400
@@ -48,7 +48,8 @@
@Override
public String toString() {
- return "CommonParams{" + "outdir=" + outdir + " verbose=" + verbose + '}';
+ return "CommonParams{" + "outdir=" + outdir
+ + " verbose=" + verbose + '}';
}
}
--- a/src/jdk.packager/share/classes/jdk/packager/internal/DeployParams.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/DeployParams.java Mon Aug 27 16:01:38 2018 -0400
@@ -99,7 +99,7 @@
Boolean needInstall = null;
String outfile;
- //if true then we cobundle js and image files needed
+ // if true then we cobundle js and image files needed
// for web deployment with the application
boolean includeDT;
@@ -113,11 +113,12 @@
File javaRuntimeToUse = null;
boolean javaRuntimeWasSet = false;
- //list of jvm args (in theory string can contain spaces and need to be escaped
+ // list of jvm args
+ // (in theory string can contain spaces and need to be escaped
List<String> jvmargs = new LinkedList<>();
Map<String, String> jvmUserArgs = new LinkedHashMap<>();
- //list of jvm properties (can also be passed as VM args
+ // list of jvm properties (can also be passed as VM args
// but keeping them separate make it a bit more convinient
Map<String, String> properties = new LinkedHashMap<>();
@@ -368,9 +369,9 @@
}
}
- //we need to expand as in some cases
+ // we need to expand as in some cases
// (most notably javapackager)
- //we may get "." as filename and assumption is we include
+ // we may get "." as filename and assumption is we include
// everything in the given folder
// (IOUtils.copyfiles() have recursive behavior)
List<File> expandFileset(File root) {
@@ -393,7 +394,7 @@
@Override
public void addResource(File baseDir, String path) {
File file = new File(baseDir, path);
- //normalize top level dir
+ // normalize top level dir
// to strip things like "." in the path
// or it can confuse symlink detection logic
file = file.getAbsoluteFile();
@@ -401,12 +402,13 @@
if (baseDir == null) {
baseDir = file.getParentFile();
}
- resources.add(new RelativeFileSet(baseDir, new LinkedHashSet<>(expandFileset(file))));
+ resources.add(new RelativeFileSet(
+ baseDir, new LinkedHashSet<>(expandFileset(file))));
}
@Override
public void addResource(File baseDir, File file) {
- //normalize initial file
+ // normalize initial file
// to strip things like "." in the path
// or it can confuse symlink detection logic
file = file.getAbsoluteFile();
@@ -414,7 +416,8 @@
if (baseDir == null) {
baseDir = file.getParentFile();
}
- resources.add(new RelativeFileSet(baseDir, new LinkedHashSet<>(expandFileset(file))));
+ resources.add(new RelativeFileSet(
+ baseDir, new LinkedHashSet<>(expandFileset(file))));
}
public void addResource(File baseDir, String path, String type) {
@@ -425,7 +428,8 @@
addResource(baseDir, file, "eager", type, null, null);
}
- public void addResource(File baseDir, File file, String mode, String type, String os, String arch) {
+ public void addResource(File baseDir, File file, String mode,
+ String type, String os, String arch) {
Set<File> singleFile = new LinkedHashSet<>();
singleFile.add(file);
if (baseDir == null) {
@@ -455,12 +459,9 @@
private static File createFile(final File baseDir, final String path) {
final File testFile = new File(path);
- return testFile.isAbsolute()
- ? testFile
- : new File(baseDir == null
- ? null
- : baseDir.getAbsolutePath(),
- path);
+ return testFile.isAbsolute() ?
+ testFile : new File(baseDir == null ?
+ null : baseDir.getAbsolutePath(), path);
}
@@ -470,12 +471,14 @@
throw new PackagerException("ERR_MissingArgument", "--output");
}
- if (bundlerArguments.get(Arguments.CLIOptions.MODULE.getId()) == null && !jreInstaller) {
+ if (bundlerArguments.get(
+ Arguments.CLIOptions.MODULE.getId()) == null && !jreInstaller) {
if (resources.isEmpty()) {
throw new PackagerException("ERR_MissingAppResources");
}
- if (bundlerArguments.get(Arguments.CLIOptions.APPCLASS.getId()) == null) {
+ if (bundlerArguments.get(
+ Arguments.CLIOptions.APPCLASS.getId()) == null) {
throw new PackagerException("ERR_MissingArgument", "--class");
}
}
@@ -523,7 +526,8 @@
List<Icon> icons = new LinkedList<>();
- public void addIcon(String href, String kind, int w, int h, int d, RunMode m) {
+ public void addIcon(
+ String href, String kind, int w, int h, int d, RunMode m) {
icons.add(new Icon(href, kind, w, h, d, m));
}
@@ -607,8 +611,9 @@
//skip resources for other OS
// and nativelib jars (we are including raw libraries)
if ((os == null || currentOS.contains(os.toLowerCase())) &&
- (arch == null || currentArch.startsWith(arch.toLowerCase()))
- && rfs.getType() != RelativeFileSet.Type.nativelib) {
+ (arch == null ||
+ currentArch.startsWith(arch.toLowerCase())) &&
+ rfs.getType() != RelativeFileSet.Type.nativelib) {
if (rfs.getType() == RelativeFileSet.Type.license) {
for (String s : rfs.getIncludedFiles()) {
bundleParams.addLicenseFile(s);
@@ -679,32 +684,37 @@
File appIcon = null;
List<Map<String, ? super Object>> bundlerIcons = new ArrayList<>();
for (Icon ic: icons) {
- //NB: in theory we should be paying attention to RunMode but
- // currently everything is marked as webstart internally and runmode
- // is not publicly documented property
- if (/* (ic.mode == RunMode.ALL || ic.mode == RunMode.STANDALONE) && */
+ // NB: in theory we should be paying attention to RunMode but
+ // currently everything is marked as webstart internally and
+ // runmode is not publicly documented property
+ if (/* (ic.mode == RunMode.ALL ||
+ ic.mode == RunMode.STANDALONE) && */
(ic.kind == null || ic.kind.equals("default")))
{
//could be full path or something relative to the output folder
appIcon = new File(ic.href);
if (!appIcon.exists()) {
- jdk.packager.internal.Log.debug("Icon [" + ic.href + "] is not valid absolute path. " +
- "Assume it is relative to the output dir.");
+ jdk.packager.internal.Log.debug(
+ "Icon [" + ic.href + "] is not valid absolute path. "
+ + "Assume it is relative to the output dir.");
appIcon = new File(outdir, ic.href);
}
}
Map<String, ? super Object> iconInfo = new TreeMap<>();
- /*
+/*
if (ic.href != null) iconInfo.put(ICONS_HREF.getID(), ic.href);
if (ic.kind != null) iconInfo.put(ICONS_KIND.getID(), ic.kind);
- if (ic.width > 0) iconInfo.put(ICONS_WIDTH.getID(), Integer.toString(ic.width));
- if (ic.height > 0) iconInfo.put(ICONS_HEIGHT.getID(), Integer.toString(ic.height));
- if (ic.depth > 0) iconInfo.put(ICONS_DEPTH.getID(), Integer.toString(ic.depth));
+ if (ic.width > 0) iconInfo.put(ICONS_WIDTH.getID(),
+ Integer.toString(ic.width));
+ if (ic.height > 0) iconInfo.put(ICONS_HEIGHT.getID(),
+ Integer.toString(ic.height));
+ if (ic.depth > 0) iconInfo.put(ICONS_DEPTH.getID(),
+ Integer.toString(ic.depth));
*/
if (!iconInfo.isEmpty()) bundlerIcons.add(iconInfo);
}
- // putUnlessNullOrEmpty(ICONS.getID(), bundlerIcons);
+ // putUnlessNullOrEmpty(ICONS.getID(), bundlerIcons);
bundleParams.setIcon(appIcon);
@@ -718,8 +728,10 @@
Map<String, String> unescapedHtmlParams = new TreeMap<>();
Map<String, String> escapedHtmlParams = new TreeMap<>();
- //putUnlessNullOrEmpty(JNLPBundler.APPLET_PARAMS.getID(), unescapedHtmlParams);
- //putUnlessNullOrEmpty(ESCAPED_APPLET_PARAMS.getID(), escapedHtmlParams);
+ // putUnlessNullOrEmpty(JNLPBundler.APPLET_PARAMS.getID(),
+ // unescapedHtmlParams);
+ // putUnlessNullOrEmpty(ESCAPED_APPLET_PARAMS.getID(),
+ // escapedHtmlParams);
/*
putUnlessNull(WIDTH.getID(), width);
@@ -752,7 +764,8 @@
keys.retainAll(bundleParams.getBundleParamsAsMap().keySet());
if (!keys.isEmpty()) {
- throw new RuntimeException("Deploy Params and Bundler Arguments overlap in the following values:" + keys.toString());
+ throw new RuntimeException("Deploy Params and Bundler Arguments "
+ + "overlap in the following values:" + keys.toString());
}
bundleParams.addAllBundleParams(bundlerArguments);
--- a/src/jdk.packager/share/classes/jdk/packager/internal/EnumeratedBundlerParam.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/EnumeratedBundlerParam.java Mon Aug 27 16:01:38 2018 -0400
@@ -31,14 +31,15 @@
/**
*
- * The class 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.
+ * The class 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:
+ * The following example illustrates a simple usage of
+ * the MAC_CATEGORY parameter:
*
* <pre>{@code
* Set<String> keys = MAC_CATEGORY.getDisplayableKeys();
@@ -51,20 +52,17 @@
*
*/
public class EnumeratedBundlerParam<T> extends BundlerParamInfo<T> {
- //Not sure if this is the correct order, my idea is that from and IDE's 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)
+ // Not sure if this is the correct order, my idea is that from and IDE's
+ // 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;
- public EnumeratedBundlerParam(String name,
- String description,
- 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) {
+ public EnumeratedBundlerParam(String name, String description,
+ 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.name = name;
this.description = description;
this.id = id;
@@ -102,8 +100,10 @@
if (isStrict()) {
T value = fetchFrom(params);
if (!isInPossibleValues(value)) {
- throw new InvalidBundlerParamException("Parameter " +
- value.toString() + " not in valid set of values for BundlerParam " + name);
+ throw new InvalidBundlerParamException("Parameter "
+ + value.toString()
+ + " not in valid set of values for BundlerParam "
+ + name);
}
return value;
}
--- a/src/jdk.packager/share/classes/jdk/packager/internal/IOUtils.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/IOUtils.java Mon Aug 27 16:01:38 2018 -0400
@@ -96,7 +96,8 @@
copyFromURL(location, file, false);
}
- public static void copyFromURL(URL location, File file, boolean append) throws IOException {
+ public static void copyFromURL(URL location, File file, boolean append)
+ throws IOException {
if (location == null) {
throw new IOException("Missing input resource!");
}
@@ -169,13 +170,15 @@
public static void run(String launcher, File paramFile, boolean verbose)
throws IOException {
if (paramFile != null && paramFile.exists()) {
- ProcessBuilder pb = new ProcessBuilder(launcher, paramFile.getName());
+ ProcessBuilder pb =
+ new ProcessBuilder(launcher, paramFile.getName());
pb = pb.directory(paramFile.getParentFile());
exec(pb, verbose);
}
}
- public static void exec(ProcessBuilder pb, boolean verbose) throws IOException {
+ public static void exec(ProcessBuilder pb, boolean verbose)
+ throws IOException {
exec(pb, verbose, false);
}
@@ -185,11 +188,13 @@
}
public static void exec(ProcessBuilder pb, boolean verbose,
- boolean testForPresenseOnly, PrintStream consumer) throws IOException {
+ boolean testForPresenseOnly, PrintStream consumer)
+ throws IOException {
pb.redirectErrorStream(true);
String prefix = Arguments.echoMode() ? "\nECHO-MODE: " : "";
- Log.verbose(prefix + "Running " + Arrays.toString(pb.command().toArray(new String[0]))
- + (pb.directory() != null ? (" in " + pb.directory()) : ""));
+ Log.verbose(prefix + "Running "
+ + Arrays.toString(pb.command().toArray(new String[0]))
+ + (pb.directory() != null ? (" in " + pb.directory()) : ""));
Process p = pb.start();
InputStreamReader isr = new InputStreamReader(p.getInputStream());
BufferedReader br = new BufferedReader(isr);
@@ -206,10 +211,12 @@
try {
int ret = p.waitFor();
if (ret != 0 && !(testForPresenseOnly && ret != 127)) {
- throw new IOException("Exec failed with code " + ret +
- " command [" + Arrays.toString(pb.command().toArray(new String[0])) +
- " in " + (pb.directory() != null ?
- pb.directory().getAbsolutePath() : "unspecified directory"));
+ throw new IOException("Exec failed with code "
+ + ret + " command ["
+ + Arrays.toString(pb.command().toArray(new String[0]))
+ + " in " + (pb.directory() != null ?
+ pb.directory().getAbsolutePath() :
+ "unspecified directory"));
}
} catch (InterruptedException ex) {
}
@@ -230,11 +237,13 @@
}
}
- return Runtime.getRuntime().exec(argsList.toArray(new String[argsList.size()]));
+ return Runtime.getRuntime().exec(
+ argsList.toArray(new String[argsList.size()]));
}
private static void logErrorStream(Process p) {
- final BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+ final BufferedReader err =
+ new BufferedReader(new InputStreamReader(p.getErrorStream()));
Thread t = new Thread(() -> {
try {
String line;
@@ -254,7 +263,8 @@
final Process p = startProcess(args);
List<String> list = new ArrayList<>();
- final BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ final BufferedReader in =
+ new BufferedReader(new InputStreamReader(p.getInputStream()));
Thread t = new Thread(() -> {
try {
String line;
@@ -278,8 +288,8 @@
return ret;
}
- //no good test if we are running pre-JRE7
- //use heuristic approach
+ // no good test if we are running pre-JRE7
+ // use heuristic approach
// "false positive" is better than wrong answer
public static boolean isNotSymbolicLink(File file) {
//no symlinks on windows
@@ -302,7 +312,7 @@
public static byte[] readFully(File f) throws IOException {
InputStream inp = new FileInputStream(f);
- //read fully into memory
+ // read fully into memory
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
--- a/src/jdk.packager/share/classes/jdk/packager/internal/JLinkBundlerHelper.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/JLinkBundlerHelper.java Mon Aug 27 16:01:38 2018 -0400
@@ -52,9 +52,8 @@
public final class JLinkBundlerHelper {
- private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.JLinkBundlerHelper");
-
+ private static final ResourceBundle I18N = ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.JLinkBundlerHelper");
private static final String JRE_MODULES_FILENAME =
"jdk/packager/internal/resources/jre.list";
private static final String SERVER_JRE_MODULES_FILENAME =
@@ -142,14 +141,17 @@
public static File getMainJar(Map<String, ? super Object> params) {
File result = null;
- RelativeFileSet fileset = StandardBundlerParam.MAIN_JAR.fetchFrom(params);
+ RelativeFileSet fileset =
+ StandardBundlerParam.MAIN_JAR.fetchFrom(params);
if (fileset != null) {
String filename = fileset.getIncludedFiles().iterator().next();
- result = fileset.getBaseDirectory().toPath().resolve(filename).toFile();
+ result = fileset.getBaseDirectory().toPath().
+ resolve(filename).toFile();
if (result == null || !result.exists()) {
- String srcdir = StandardBundlerParam.SOURCE_DIR.fetchFrom(params);
+ String srcdir =
+ StandardBundlerParam.SOURCE_DIR.fetchFrom(params);
if (srcdir != null) {
result = new File(srcdir + File.separator + filename);
@@ -195,16 +197,18 @@
public static String getJDKVersion(Map<String, ? super Object> params) {
String result = "";
- List<Path> modulePath = StandardBundlerParam.MODULE_PATH.fetchFrom(params);
- Set<String> limitModules = StandardBundlerParam.LIMIT_MODULES.fetchFrom(params);
+ List<Path> modulePath =
+ StandardBundlerParam.MODULE_PATH.fetchFrom(params);
+ Set<String> limitModules =
+ StandardBundlerParam.LIMIT_MODULES.fetchFrom(params);
Path javaBasePath = findPathOfModule(modulePath, "java.base.jmod");
Set<String> addModules = getRedistributableModules(modulePath,
StandardBundlerParam.ADD_MODULES.fetchFrom(params),
limitModules, JRE_MODULES_FILENAME);
if (javaBasePath != null && javaBasePath.toFile().exists()) {
- result = RedistributableModules.getModuleVersion(javaBasePath.toFile(),
- modulePath, addModules, limitModules);
+ result = RedistributableModules.getModuleVersion(
+ javaBasePath.toFile(), modulePath, addModules, limitModules);
}
return result;
@@ -212,7 +216,8 @@
public static Path getJDKHome(Map<String, ? super Object> params) {
Path result = null;
- List<Path> modulePath = StandardBundlerParam.MODULE_PATH.fetchFrom(params);
+ List<Path> modulePath =
+ StandardBundlerParam.MODULE_PATH.fetchFrom(params);
Path javaBasePath = findPathOfModule(modulePath, "java.base.jmod");
if (javaBasePath != null && javaBasePath.toFile().exists()) {
@@ -226,7 +231,9 @@
Path bin = result.resolve("bin");
if (Files.exists(bin)) {
- final String exe = (Platform.getPlatform() == Platform.WINDOWS) ? ".exe" : "";
+ final String exe =
+ (Platform.getPlatform() == Platform.WINDOWS) ?
+ ".exe" : "";
Path javaExe = bin.resolve("java" + exe);
if (Files.exists(javaExe)) {
@@ -245,16 +252,22 @@
private static Set<String> getRedistributableModules(List<Path> modulePath,
Set<String> addModules, Set<String> limitModules, String filename) {
- ModuleHelper moduleHelper = new ModuleHelper(modulePath, addModules, limitModules, filename);
+ ModuleHelper moduleHelper = new ModuleHelper(
+ modulePath, addModules, limitModules, filename);
return removeInvalidModules(modulePath, moduleHelper.modules());
}
public static void execute(Map<String, ? super Object> params,
- AbstractAppImageBuilder imageBuilder) throws IOException, Exception {
- List<Path> modulePath = StandardBundlerParam.MODULE_PATH.fetchFrom(params);
- Set<String> addModules = StandardBundlerParam.ADD_MODULES.fetchFrom(params);
- Set<String> limitModules = StandardBundlerParam.LIMIT_MODULES.fetchFrom(params);
- boolean stripNativeCommands = StandardBundlerParam.STRIP_NATIVE_COMMANDS.fetchFrom(params);
+ AbstractAppImageBuilder imageBuilder)
+ throws IOException, Exception {
+ List<Path> modulePath =
+ StandardBundlerParam.MODULE_PATH.fetchFrom(params);
+ Set<String> addModules =
+ StandardBundlerParam.ADD_MODULES.fetchFrom(params);
+ Set<String> limitModules =
+ StandardBundlerParam.LIMIT_MODULES.fetchFrom(params);
+ boolean stripNativeCommands =
+ StandardBundlerParam.STRIP_NATIVE_COMMANDS.fetchFrom(params);
Path outputDir = imageBuilder.getRoot();
String excludeFileList = imageBuilder.getExcludeFileList();
File mainJar = getMainJar(params);
@@ -262,7 +275,8 @@
if (mainJar != null) {
mainJarType = new Module(mainJar).getModuleType();
- } else if (mainJar == null && StandardBundlerParam.MODULE.fetchFrom(params) == null) {
+ } else if (mainJar == null &&
+ StandardBundlerParam.MODULE.fetchFrom(params) == null) {
// user specified only main class, all jars will be on the classpath
mainJarType = Module.ModuleType.UnnamedJar;
}
@@ -273,16 +287,19 @@
// non-redistributable modules removed.
if (mainJarType == Module.ModuleType.UnnamedJar) {
addModules.add(ModuleHelper.ALL_RUNTIME);
- } else if (mainJarType == Module.ModuleType.Unknown || mainJarType == Module.ModuleType.ModularJar) {
+ } else if (mainJarType == Module.ModuleType.Unknown ||
+ mainJarType == Module.ModuleType.ModularJar) {
String mainModule = getMainModule(params);
addModules.add(mainModule);
// Error if any of the srcfiles are modular jars.
- Set<String> modularJars = getResourceFileJarList(params, Module.JarType.ModularJar);
+ Set<String> modularJars =
+ getResourceFileJarList(params, Module.JarType.ModularJar);
if (!modularJars.isEmpty()) {
throw new Exception(MessageFormat.format(I18N.getString(
- "error.srcfiles.contain.modules"), modularJars.toString()));
+ "error.srcfiles.contain.modules"),
+ modularJars.toString()));
}
}
@@ -291,12 +308,14 @@
addModules.addAll(redistModules);
if (imageBuilder.getPlatformSpecificModulesFile() != null) {
- Set<String> platformModules = RedistributableModules.getRedistributableModules(
+ Set<String> platformModules =
+ RedistributableModules.getRedistributableModules(
modulePath, imageBuilder.getPlatformSpecificModulesFile());
addModules.addAll(platformModules);
}
- Log.info(MessageFormat.format(I18N.getString("message.modules"), addModules.toString()));
+ Log.info(MessageFormat.format(
+ I18N.getString("message.modules"), addModules.toString()));
if (StandardBundlerParam.ECHO_MODE.fetchFrom(params)) {
Log.info("\nECHO-MODE: Running jlink [ ");
@@ -323,24 +342,31 @@
}
public static void generateServerJre(Map<String, ? super Object> params,
- AbstractAppImageBuilder imageBuilder) throws IOException, Exception {
- List<Path> modulePath = StandardBundlerParam.MODULE_PATH.fetchFrom(params);
- Set<String> addModules = StandardBundlerParam.ADD_MODULES.fetchFrom(params);
- Set<String> limitModules = StandardBundlerParam.LIMIT_MODULES.fetchFrom(params);
- boolean stripNativeCommands = StandardBundlerParam.STRIP_NATIVE_COMMANDS.fetchFrom(params);
+ AbstractAppImageBuilder imageBuilder)
+ throws IOException, Exception {
+ List<Path> modulePath =
+ StandardBundlerParam.MODULE_PATH.fetchFrom(params);
+ Set<String> addModules =
+ StandardBundlerParam.ADD_MODULES.fetchFrom(params);
+ Set<String> limitModules =
+ StandardBundlerParam.LIMIT_MODULES.fetchFrom(params);
+ boolean stripNativeCommands =
+ StandardBundlerParam.STRIP_NATIVE_COMMANDS.fetchFrom(params);
Path outputDir = imageBuilder.getRoot();
addModules.add(ModuleHelper.ALL_RUNTIME);
- Set<String> redistModules = getRedistributableModules(
- modulePath, addModules, limitModules, SERVER_JRE_MODULES_FILENAME);
+ Set<String> redistModules = getRedistributableModules(modulePath,
+ addModules, limitModules, SERVER_JRE_MODULES_FILENAME);
addModules.addAll(redistModules);
if (imageBuilder.getPlatformSpecificModulesFile() != null) {
- Set<String> platformModules = RedistributableModules.getRedistributableModules(
- modulePath, imageBuilder.getPlatformSpecificModulesFile());
+ Set<String> platformModules =
+ RedistributableModules.getRedistributableModules(
+ modulePath, imageBuilder.getPlatformSpecificModulesFile());
addModules.addAll(platformModules);
}
- Log.info(MessageFormat.format(I18N.getString("message.modules"), addModules.toString()));
+ Log.info(MessageFormat.format(
+ I18N.getString("message.modules"), addModules.toString()));
if (StandardBundlerParam.ECHO_MODE.fetchFrom(params)) {
Log.info("\nECHO-MODE: Running jlink [ ");
@@ -366,7 +392,8 @@
}
// Returns the path to the JDK modules in the user defined module path.
- public static Path findPathOfModule(List<Path> modulePath, String moduleName) {
+ public static Path findPathOfModule(
+ List<Path> modulePath, String moduleName) {
Path result = null;
for (Path path : modulePath) {
@@ -387,7 +414,8 @@
String srcdir = StandardBundlerParam.SOURCE_DIR.fetchFrom(params);
- for (RelativeFileSet appResources : StandardBundlerParam.APP_RESOURCES_LIST.fetchFrom(params)) {
+ for (RelativeFileSet appResources :
+ StandardBundlerParam.APP_RESOURCES_LIST.fetchFrom(params)) {
for (String resource : appResources.getIncludedFiles()) {
if (resource.endsWith(".jar")) {
String filename = srcdir + File.separator + resource;
@@ -400,7 +428,8 @@
case ModularJar: {
Module module = new Module(new File(filename));
- if (module.getModuleType() == Module.ModuleType.ModularJar) {
+ if (module.getModuleType() ==
+ Module.ModuleType.ModularJar) {
files.add(filename);
}
break;
@@ -408,7 +437,8 @@
case UnnamedJar: {
Module module = new Module(new File(filename));
- if (module.getModuleType() == Module.ModuleType.UnnamedJar) {
+ if (module.getModuleType() ==
+ Module.ModuleType.UnnamedJar) {
files.add(filename);
}
break;
@@ -421,12 +451,14 @@
return files;
}
- private static Set<String> removeInvalidModules(List<Path> modulePath, Set<String> modules) {
+ private static Set<String> removeInvalidModules(
+ List<Path> modulePath, Set<String> modules) {
Set<String> result = new LinkedHashSet();
ModuleManager mm = new ModuleManager(modulePath);
- List<Module> lmodules = mm.getModules(EnumSet.of(ModuleManager.SearchType.ModularJar,
- ModuleManager.SearchType.Jmod,
- ModuleManager.SearchType.ExplodedModule));
+ List<Module> lmodules =
+ mm.getModules(EnumSet.of(ModuleManager.SearchType.ModularJar,
+ ModuleManager.SearchType.Jmod,
+ ModuleManager.SearchType.ExplodedModule));
HashMap<String, Module> validModules = new HashMap<>();
@@ -439,7 +471,8 @@
result.add(name);
}
else {
- Log.info(MessageFormat.format(I18N.getString("warning.module.does.not.exist"), name));
+ Log.info(MessageFormat.format(
+ I18N.getString("warning.module.does.not.exist"), name));
}
}
@@ -460,7 +493,8 @@
Set<String> limitMods, String filename) {
Macros macro = Macros.None;
- for (Iterator<String> iterator = roots.iterator(); iterator.hasNext();) {
+ for (Iterator<String> iterator = roots.iterator();
+ iterator.hasNext();) {
String module = iterator.next();
switch (module) {
@@ -482,7 +516,9 @@
this.modules.addAll(getModuleNamesFromPath(paths));
break;
case AllRuntime:
- Set<String> m = RedistributableModules.getRedistributableModules(paths, filename);
+ Set<String> m =
+ RedistributableModules.getRedistributableModules(
+ paths, filename);
if (m != null) {
this.modules.addAll(m);
@@ -499,9 +535,11 @@
private static Set<String> getModuleNamesFromPath(List<Path> Value) {
Set<String> result = new LinkedHashSet();
ModuleManager mm = new ModuleManager(Value);
- List<Module> modules = mm.getModules(EnumSet.of(ModuleManager.SearchType.ModularJar,
- ModuleManager.SearchType.Jmod,
- ModuleManager.SearchType.ExplodedModule));
+ List<Module> modules =
+ mm.getModules(
+ EnumSet.of(ModuleManager.SearchType.ModularJar,
+ ModuleManager.SearchType.Jmod,
+ ModuleManager.SearchType.ExplodedModule));
for (Module module : modules) {
result.add(module.getModuleName());
--- a/src/jdk.packager/share/classes/jdk/packager/internal/JavaPackagerToolProvider.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/JavaPackagerToolProvider.java Mon Aug 27 16:01:38 2018 -0400
@@ -34,7 +34,8 @@
return "javapackager";
}
- public synchronized int run(PrintWriter out, PrintWriter err, String... args) {
+ public synchronized int run(
+ PrintWriter out, PrintWriter err, String... args) {
try {
jdk.packager.Main.run(out, err, args);
} catch (Exception ignored) {
--- a/src/jdk.packager/share/classes/jdk/packager/internal/JreUtils.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/JreUtils.java Mon Aug 27 16:01:38 2018 -0400
@@ -96,11 +96,13 @@
return false;
}
- public static void walk(File base, File root, Rule ruleset[], Set<File> files) {
+ public static void walk(File base, File root,
+ Rule ruleset[], Set<File> files) {
walk(base, root, ruleset, files, false);
}
- public static void walk(File base, File root, Rule ruleset[], Set<File> files, boolean acceptSymlinks) {
+ public static void walk(File base, File root, Rule ruleset[],
+ Set<File> files, boolean acceptSymlinks) {
if (!root.isDirectory()) {
if (root.isFile()) {
files.add(root);
@@ -111,7 +113,8 @@
File[] lst = root.listFiles();
if (lst != null) {
for (File f : lst) {
- if ((acceptSymlinks || IOUtils.isNotSymbolicLink(f)) && !shouldExclude(base, f, ruleset)) {
+ if ((acceptSymlinks || IOUtils.isNotSymbolicLink(f)) &&
+ !shouldExclude(base, f, ruleset)) {
if (f.isDirectory()) {
walk(base, f, ruleset, files, acceptSymlinks);
} else if (f.isFile()) {
--- a/src/jdk.packager/share/classes/jdk/packager/internal/Module.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/Module.java Mon Aug 27 16:01:38 2018 -0400
@@ -40,7 +40,8 @@
private final ModuleType moduleType;
public enum JarType {All, UnnamedJar, ModularJar}
- public enum ModuleType {Unknown, UnnamedJar, ModularJar, Jmod, ExplodedModule}
+ public enum ModuleType {
+ Unknown, UnnamedJar, ModularJar, Jmod, ExplodedModule}
public Module(File AFile) {
super();
@@ -83,7 +84,8 @@
}
}
else if (AFile.isDirectory()) {
- File moduleInfo = new File(filename + File.separator + "module-info.class");
+ File moduleInfo = new File(
+ filename + File.separator + "module-info.class");
if (moduleInfo.exists()) {
result = ModuleType.ExplodedModule;
@@ -97,11 +99,13 @@
JarType result = JarType.All;
try {
- ZipInputStream zip = new ZipInputStream(new FileInputStream(FileName));
+ ZipInputStream zip =
+ new ZipInputStream(new FileInputStream(FileName));
result = JarType.UnnamedJar;
try {
- for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) {
+ for (ZipEntry entry = zip.getNextEntry(); entry != null;
+ entry = zip.getNextEntry()) {
if (entry.getName().matches("module-info.class")) {
result = JarType.ModularJar;
break;
--- a/src/jdk.packager/share/classes/jdk/packager/internal/ModuleManager.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/ModuleManager.java Mon Aug 27 16:01:38 2018 -0400
@@ -43,7 +43,8 @@
String lfolders = folders.replaceAll("^\"|\"$", "");
List<Path> paths = new ArrayList();
- for (String folder : Arrays.asList(lfolders.split(File.pathSeparator))) {
+ for (String folder :
+ Arrays.asList(lfolders.split(File.pathSeparator))) {
File file = new File(folder);
paths.add(file.toPath());
}
@@ -64,7 +65,8 @@
public List<Module> getModules() {
return getModules(EnumSet.of(SearchType.UnnamedJar,
- SearchType.ModularJar, SearchType.Jmod, SearchType.ExplodedModule));
+ SearchType.ModularJar, SearchType.Jmod,
+ SearchType.ExplodedModule));
}
public List<Module> getModules(EnumSet<SearchType> Search) {
--- a/src/jdk.packager/share/classes/jdk/packager/internal/PackagerException.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/PackagerException.java Mon Aug 27 16:01:38 2018 -0400
@@ -46,12 +46,14 @@
}
public PackagerException(String key, String ... arguments) {
- super(MessageFormat.format(bundle.getString(key), (Object[]) arguments));
+ super(MessageFormat.format(
+ bundle.getString(key), (Object[]) arguments));
}
- public PackagerException(Throwable cause, String key, String ... arguments) {
- super(MessageFormat.format(bundle.getString(key), (Object[]) arguments),
- cause);
+ public PackagerException(
+ Throwable cause, String key, String ... arguments) {
+ super(MessageFormat.format(bundle.getString(key),
+ (Object[]) arguments), cause);
}
}
--- a/src/jdk.packager/share/classes/jdk/packager/internal/PackagerLib.java Thu Aug 23 11:09:16 2018 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2012, 2018, 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.packager.internal;
-
-import jdk.packager.internal.bundlers.BundleParams;
-import jdk.packager.internal.bundlers.Bundler.BundleType;
-import java.io.File;
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-
-// this class must be removed in the future
-@Deprecated
-public class PackagerLib {
- public static final String JAVA_VERSION = System.getProperty("java.version");
-
- private static final ResourceBundle bundle =
- ResourceBundle.getBundle("jdk.packager.internal.resources.Bundle");
-
- private enum Filter {ALL, CLASSES_ONLY, RESOURCES}
-
- public void generateDeploymentPackages(DeployParams deployParams) throws PackagerException {
- if (deployParams == null) {
- throw new IllegalArgumentException("Parameters must not be null.");
- }
-
- try {
- BundleParams bp = deployParams.getBundleParams();
-
- if (bp != null) {
- switch(deployParams.getBundleType()) {
- case NATIVE: {
- // Generate disk images.
- generateNativeBundles(deployParams.outdir,
- bp.getBundleParamsAsMap(),
- BundleType.IMAGE.toString(),
- deployParams.getTargetFormat());
-
- // Generate installers.
- generateNativeBundles(deployParams.outdir,
- bp.getBundleParamsAsMap(),
- BundleType.INSTALLER.toString(),
- deployParams.getTargetFormat());
- break;
- }
-
- case NONE: {
- break;
- }
-
- default: {
- // A specefic output format, just generate that.
- generateNativeBundles(deployParams.outdir,
- bp.getBundleParamsAsMap(),
- deployParams.getBundleType().toString(),
- deployParams.getTargetFormat());
- }
- }
- }
- } catch (PackagerException ex) {
- throw ex;
- } catch (Exception ex) {
- throw new PackagerException(ex, "ERR_DeployFailed", ex.getMessage());
- }
-
- }
-
- private void generateNativeBundles(File outdir, Map<String, ? super Object> params,
- String bundleType, String bundleFormat) throws PackagerException {
- for (Bundler bundler : Bundlers.createBundlersInstance().getBundlers(bundleType)) {
- // if they specify the bundle format, require we match the ID
- if (bundleFormat != null && !bundleFormat.equalsIgnoreCase(bundler.getID())) continue;
-
- Map<String, ? super Object> localParams = new HashMap<>(params);
- try {
- if (bundler.validate(localParams)) {
- File result = bundler.execute(localParams, outdir);
- bundler.cleanup(localParams);
- if (result == null) {
- throw new PackagerException("MSG_BundlerFailed", bundler.getID(), bundler.getName());
- }
- }
- } catch (UnsupportedPlatformException e) {
- Log.debug(MessageFormat.format(bundle.getString("MSG_BundlerPlatformException"), bundler.getName()));
- } catch (ConfigException e) {
- Log.debug(e);
- if (e.getAdvice() != null) {
- Log.info(MessageFormat.format(bundle.getString("MSG_BundlerConfigException"), bundler.getName(), e.getMessage(), e.getAdvice()));
- } else {
- Log.info(MessageFormat.format(bundle.getString("MSG_BundlerConfigExceptionNoAdvice"), bundler.getName(), e.getMessage()));
- }
- } catch (RuntimeException re) {
- Log.info(MessageFormat.format(bundle.getString("MSG_BundlerRuntimeException"), bundler.getName(), re.toString()));
- Log.debug(re);
- }
- }
- }
-}
--- a/src/jdk.packager/share/classes/jdk/packager/internal/Platform.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/Platform.java Mon Aug 27 16:01:38 2018 -0400
@@ -28,7 +28,8 @@
import java.util.regex.Pattern;
/**
- * Use <code>Platform</code> to detect the operating system that is currently running.
+ * Use <code>Platform</code> to detect the operating system
+ * that is currently running.
*
* Example:
*
--- a/src/jdk.packager/share/classes/jdk/packager/internal/RedistributableModules.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/RedistributableModules.java Mon Aug 27 16:01:38 2018 -0400
@@ -71,7 +71,8 @@
Set<String> addModules = new HashSet<>();
Set<String> limitModules = new HashSet<>();
- ModuleFinder finder = AppRuntimeImageBuilder.moduleFinder(modulePath, addModules, limitModules);
+ ModuleFinder finder = AppRuntimeImageBuilder.moduleFinder(
+ modulePath, addModules, limitModules);
Optional<ModuleReference> mref = finder.find(JDK_PACKAGER_MODULE);
if (mref.isPresent()) {
@@ -123,8 +124,9 @@
return result;
}
- public static String getModuleVersion(File moduleFile, List<Path> modulePath,
- Set<String> addModules, Set<String> limitModules) {
+ public static String getModuleVersion(File moduleFile,
+ List<Path> modulePath, Set<String> addModules,
+ Set<String> limitModules) {
String result = "";
Module module = new Module(moduleFile);
@@ -136,7 +138,8 @@
ModuleDescriptor descriptor = mref.get().descriptor();
if (descriptor != null) {
- Optional<ModuleDescriptor.Version> version = descriptor.version();
+ Optional<ModuleDescriptor.Version> version =
+ descriptor.version();
if (version.isPresent()) {
result = version.get().toString();
--- a/src/jdk.packager/share/classes/jdk/packager/internal/RelativeFileSet.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/RelativeFileSet.java Mon Aug 27 16:01:38 2018 -0400
@@ -64,7 +64,8 @@
throw new RuntimeException("File " + f.getAbsolutePath() +
" does not belong to " + baseAbsolute);
}
- if (!absolute.equals(baseAbsolute)) { //possible in javapackager case
+ if (!absolute.equals(baseAbsolute)) {
+ // possible in javapackager case
this.files.add(absolute.substring(baseAbsolute.length()+1));
}
}
--- a/src/jdk.packager/share/classes/jdk/packager/internal/SecondaryLauncherArguments.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/SecondaryLauncherArguments.java Mon Aug 27 16:01:38 2018 -0400
@@ -64,21 +64,22 @@
}
putUnlessNull(bundleParams, Arguments.CLIOptions.NAME.getId(),
- getOptionValue(CLIOptions.NAME));
+ getOptionValue(CLIOptions.NAME));
putUnlessNull(bundleParams, Arguments.CLIOptions.VERSION.getId(),
- getOptionValue(CLIOptions.VERSION));
+ getOptionValue(CLIOptions.VERSION));
// 3 boolean values:
putUnlessNull(bundleParams, Arguments.CLIOptions.WIN_MENU_HINT.getId(),
- getOptionValue(CLIOptions.WIN_MENU_HINT));
- putUnlessNull(bundleParams, Arguments.CLIOptions.WIN_SHORTCUT_HINT.getId(),
- getOptionValue(CLIOptions.WIN_SHORTCUT_HINT));
+ getOptionValue(CLIOptions.WIN_MENU_HINT));
+ putUnlessNull(bundleParams,
+ Arguments.CLIOptions.WIN_SHORTCUT_HINT.getId(),
+ getOptionValue(CLIOptions.WIN_SHORTCUT_HINT));
putUnlessNull(bundleParams, Arguments.CLIOptions.SINGLETON.getId(),
- getOptionValue(CLIOptions.SINGLETON));
+ getOptionValue(CLIOptions.SINGLETON));
String value = getOptionValue(CLIOptions.ICON);
putUnlessNull(bundleParams, Arguments.CLIOptions.ICON.getId(),
- (value == null) ? null : new File(value));
+ (value == null) ? null : new File(value));
String argumentStr = getOptionValue(CLIOptions.ARGUMENTS);
putUnlessNullOrEmpty(bundleParams,
--- a/src/jdk.packager/share/classes/jdk/packager/internal/StandardBundlerParam.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/StandardBundlerParam.java Mon Aug 27 16:01:38 2018 -0400
@@ -59,14 +59,15 @@
public class StandardBundlerParam<T> extends BundlerParamInfo<T> {
- private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.StandardBundlerParam");
+ private static final ResourceBundle I18N = ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.StandardBundlerParam");
private static final String JAVABASEJMOD = "java.base.jmod";
public StandardBundlerParam(String name, String description, String id,
- Class<T> valueType,
- Function<Map<String, ? super Object>, T> defaultValueFunction,
- BiFunction<String, Map<String, ? super Object>, T> stringConverter) {
+ Class<T> valueType,
+ Function<Map<String, ? super Object>, T> defaultValueFunction,
+ BiFunction<String, Map<String, ? super Object>, T> stringConverter)
+ {
this.name = name;
this.description = description;
this.id = id;
@@ -82,18 +83,21 @@
BundleParams.PARAM_APP_RESOURCES,
RelativeFileSet.class,
null, // no default. Required parameter
- null // no string translation, tool must provide complex type
+ null // no string translation,
+ // tool must provide complex type
);
@SuppressWarnings("unchecked")
- public static final StandardBundlerParam<List<RelativeFileSet>> APP_RESOURCES_LIST =
+ public static final
+ StandardBundlerParam<List<RelativeFileSet>> APP_RESOURCES_LIST =
new StandardBundlerParam<>(
I18N.getString("param.app-resources-list.name"),
I18N.getString("param.app-resource-list.description"),
BundleParams.PARAM_APP_RESOURCES + "List",
(Class<List<RelativeFileSet>>) (Object) List.class,
// Default is appResources, as a single item list
- p -> new ArrayList<>(Collections.singletonList(APP_RESOURCES.fetchFrom(p))),
+ p -> new ArrayList<>(Collections.singletonList(
+ APP_RESOURCES.fetchFrom(p))),
StandardBundlerParam::createAppResourcesListFromString
);
@@ -107,7 +111,8 @@
p -> null,
(s, p) -> {
String value = String.valueOf(s);
- if (value.charAt(value.length() - 1) == File.separatorChar) {
+ if (value.charAt(value.length() - 1) ==
+ File.separatorChar) {
return value.substring(0, value.length() - 1);
}
else {
@@ -126,7 +131,8 @@
(s, p) -> null
);
- // note that each bundler is likely to replace this one with their own converter
+ // note that each bundler is likely to replace this one with
+ // their own converter
public static final StandardBundlerParam<RelativeFileSet> MAIN_JAR =
new StandardBundlerParam<>(
I18N.getString("param.main-jar.name"),
@@ -166,7 +172,8 @@
return null;
}
extractMainClassInfoFromAppResources(params);
- String s = (String) params.get(BundleParams.PARAM_APPLICATION_CLASS);
+ String s = (String) params.get(
+ BundleParams.PARAM_APPLICATION_CLASS);
if (s == null) {
s = JLinkBundlerHelper.getMainClass(params);
}
@@ -194,7 +201,8 @@
(s, p) -> s
);
- private static Pattern TO_FS_NAME = Pattern.compile("\\s|[\\\\/?:*<>|]"); // keep out invalid/undesireable filename characters
+ private static Pattern TO_FS_NAME = Pattern.compile("\\s|[\\\\/?:*<>|]");
+ // keep out invalid/undesireable filename characters
public static final StandardBundlerParam<String> APP_FS_NAME =
new StandardBundlerParam<>(
@@ -202,7 +210,8 @@
I18N.getString("param.app-fs-name.description"),
"name.fs",
String.class,
- params -> TO_FS_NAME.matcher(APP_NAME.fetchFrom(params)).replaceAll(""),
+ params -> TO_FS_NAME.matcher(
+ APP_NAME.fetchFrom(params)).replaceAll(""),
(s, p) -> s
);
@@ -254,7 +263,8 @@
I18N.getString("param.copyright.description"),
Arguments.CLIOptions.COPYRIGHT.getId(),
String.class,
- params -> MessageFormat.format(I18N.getString("param.copyright.default"), new Date()),
+ params -> MessageFormat.format(I18N.getString(
+ "param.copyright.default"), new Date()),
(s, p) -> s
);
@@ -281,7 +291,8 @@
);
@SuppressWarnings("unchecked")
- public static final StandardBundlerParam<Map<String, String>> JVM_PROPERTIES =
+ public static final
+ StandardBundlerParam<Map<String, String>> JVM_PROPERTIES =
new StandardBundlerParam<>(
I18N.getString("param.jvm-system-properties.name"),
I18N.getString("param.jvm-system-properties.description"),
@@ -293,8 +304,10 @@
try {
Properties p = new Properties();
p.load(new StringReader(s));
- for (Map.Entry<Object, Object> entry : p.entrySet()) {
- map.put((String)entry.getKey(), (String)entry.getValue());
+ for (Map.Entry<Object,
+ Object> entry : p.entrySet()) {
+ map.put((String)entry.getKey(),
+ (String)entry.getValue());
}
} catch (IOException e) {
e.printStackTrace();
@@ -304,7 +317,8 @@
);
@SuppressWarnings("unchecked")
- public static final StandardBundlerParam<Map<String, String>> USER_JVM_OPTIONS =
+ public static final
+ StandardBundlerParam<Map<String, String>> USER_JVM_OPTIONS =
new StandardBundlerParam<>(
I18N.getString("param.user-jvm-options.name"),
I18N.getString("param.user-jvm-options.description"),
@@ -316,8 +330,10 @@
try {
Properties p = new Properties();
p.load(new StringReader(s));
- for (Map.Entry<Object, Object> entry : p.entrySet()) {
- map.put((String)entry.getKey(), (String)entry.getValue());
+ for (Map.Entry<Object, Object> entry :
+ p.entrySet()) {
+ map.put((String)entry.getKey(),
+ (String)entry.getValue());
}
} catch (IOException e) {
e.printStackTrace();
@@ -329,14 +345,15 @@
public static final StandardBundlerParam<String> TITLE =
new StandardBundlerParam<>(
I18N.getString("param.title.name"),
- I18N.getString("param.title.description"), //?? but what does it do?
+ I18N.getString("param.title.description"),
BundleParams.PARAM_TITLE,
String.class,
APP_NAME::fetchFrom,
(s, p) -> s
);
- // note that each bundler is likely to replace this one with their own converter
+ // note that each bundler is likely to replace this one with
+ // their own converter
public static final StandardBundlerParam<String> VERSION =
new StandardBundlerParam<>(
I18N.getString("param.version.name"),
@@ -366,7 +383,8 @@
File.class,
params -> {
try {
- return Files.createTempDirectory("jdk.packager").toFile();
+ return Files.createTempDirectory(
+ "jdk.packager").toFile();
} catch (IOException ioe) {
return null;
}
@@ -399,7 +417,8 @@
I18N.getString("param.preferences-id.description"),
"preferencesID",
String.class,
- p -> Optional.ofNullable(IDENTIFIER.fetchFrom(p)).orElse("").replace('.', '/'),
+ p -> Optional.ofNullable(IDENTIFIER.fetchFrom(p)).
+ orElse("").replace('.', '/'),
(s, p) -> s
);
@@ -421,8 +440,9 @@
Arguments.CLIOptions.VERBOSE.getId(),
Boolean.class,
params -> false,
- // valueOf(null) is false, and we actually do want null in some cases
- (s, p) -> (s == null || "null".equalsIgnoreCase(s))? true : Boolean.valueOf(s)
+ // valueOf(null) is false, and we actually do want null
+ (s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
+ true : Boolean.valueOf(s)
);
public static final StandardBundlerParam<File> DROP_IN_RESOURCES_ROOT =
@@ -469,21 +489,24 @@
I18N.getString("param.secondary-launchers.name"),
I18N.getString("param.secondary-launchers.description"),
Arguments.CLIOptions.SECONDARY_LAUNCHER.getId(),
- (Class<List<Map<String, ? super Object>>>) (Object) List.class,
+ (Class<List<Map<String, ? super Object>>>) (Object)
+ List.class,
params -> new ArrayList<>(1),
- // valueOf(null) is false, and we actually do want null in some cases
+ // valueOf(null) is false, and we actually do want null
(s, p) -> null
);
@SuppressWarnings("unchecked")
- public static final StandardBundlerParam<List<Map<String, ? super Object>>> FILE_ASSOCIATIONS =
+ public static final StandardBundlerParam
+ <List<Map<String, ? super Object>>> FILE_ASSOCIATIONS =
new StandardBundlerParam<>(
I18N.getString("param.file-associations.name"),
I18N.getString("param.file-associations.description"),
Arguments.CLIOptions.FILE_ASSOCIATIONS.getId(),
- (Class<List<Map<String, ? super Object>>>) (Object) List.class,
+ (Class<List<Map<String, ? super Object>>>) (Object)
+ List.class,
params -> new ArrayList<>(1),
- // valueOf(null) is false, and we actually do want null in some cases
+ // valueOf(null) is false, and we actually do want null
(s, p) -> null
);
@@ -505,7 +528,8 @@
I18N.getString("param.fa-content-type.description"),
"fileAssociation.contentType",
(Class<List<String>>) (Object) List.class,
- params -> null, // null means not matched to a content/mime type
+ params -> null,
+ // null means not matched to a content/mime type
(s, p) -> Arrays.asList(s.split("(,|\\s)+"))
);
@@ -538,12 +562,14 @@
(Class<List<Path>>) (Object)List.class,
p -> { return getDefaultModulePath(); },
(s, p) -> {
- List<Path> modulePath = Arrays.asList(s.split(File.pathSeparator)).stream()
- .map(ss -> new File(ss).toPath())
- .collect(Collectors.toList());
+ List<Path> modulePath = Arrays.asList(s
+ .split(File.pathSeparator)).stream()
+ .map(ss -> new File(ss).toPath())
+ .collect(Collectors.toList());
Path javaBasePath = null;
if (modulePath != null) {
- javaBasePath = JLinkBundlerHelper.findPathOfModule(modulePath, JAVABASEJMOD);
+ javaBasePath = JLinkBundlerHelper
+ .findPathOfModule(modulePath, JAVABASEJMOD);
}
else {
modulePath = new ArrayList();
@@ -555,13 +581,17 @@
if (jdkModulePath != null) {
modulePath.addAll(jdkModulePath);
- javaBasePath = JLinkBundlerHelper.findPathOfModule(modulePath, JAVABASEJMOD);
+ javaBasePath =
+ JLinkBundlerHelper.findPathOfModule(
+ modulePath, JAVABASEJMOD);
}
}
- if (javaBasePath == null || !Files.exists(javaBasePath)) {
+ if (javaBasePath == null ||
+ !Files.exists(javaBasePath)) {
jdk.packager.internal.Log.info(
- String.format(I18N.getString("warning.no.jdk.modules.found")));
+ String.format(I18N.getString(
+ "warning.no.jdk.modules.found")));
}
return modulePath;
@@ -612,7 +642,8 @@
(s, p) -> Boolean.valueOf(s)
);
- public static final BundlerParamInfo<Boolean> SINGLETON = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<Boolean> SINGLETON =
+ new StandardBundlerParam<> (
I18N.getString("param.singleton.name"),
I18N.getString("param.singleton.description"),
Arguments.CLIOptions.SINGLETON.getId(),
@@ -621,7 +652,8 @@
(s, p) -> Boolean.valueOf(s)
);
- public static final BundlerParamInfo<Boolean> ECHO_MODE = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<Boolean> ECHO_MODE =
+ new StandardBundlerParam<> (
I18N.getString("param.echo-mode.name"),
I18N.getString("param.echo-mode.description"),
Arguments.CLIOptions.ECHO_MODE.getId(),
@@ -646,46 +678,55 @@
return applicationImage;
}
- public static void copyPredefinedRuntimeImage(Map<String, ? super Object> p,
- AbstractAppImageBuilder appBuilder) throws IOException , ConfigException {
+ public static void copyPredefinedRuntimeImage(
+ Map<String, ? super Object> p,
+ AbstractAppImageBuilder appBuilder)
+ throws IOException , ConfigException {
File image = PREDEFINED_RUNTIME_IMAGE.fetchFrom(p);
if (!image.exists()) {
throw new ConfigException(
- MessageFormat.format(I18N.getString(
- "message.runtime-image-dir-does-not-exist"),
- PREDEFINED_RUNTIME_IMAGE.getID(),
- image.toString()),
- MessageFormat.format(I18N.getString(
- "message.runtime-image-dir-does-not-exist.advice"),
- PREDEFINED_RUNTIME_IMAGE.getID()));
+ MessageFormat.format(I18N.getString(
+ "message.runtime-image-dir-does-not-exist"),
+ PREDEFINED_RUNTIME_IMAGE.getID(),
+ image.toString()),
+ MessageFormat.format(I18N.getString(
+ "message.runtime-image-dir-does-not-exist.advice"),
+ PREDEFINED_RUNTIME_IMAGE.getID()));
}
IOUtils.copyRecursive(image.toPath(), appBuilder.getRoot());
appBuilder.prepareApplicationFiles();
}
- public static void extractMainClassInfoFromAppResources(Map<String, ? super Object> params) {
+ public static void extractMainClassInfoFromAppResources(
+ Map<String, ? super Object> params) {
boolean hasMainClass = params.containsKey(MAIN_CLASS.getID());
boolean hasMainJar = params.containsKey(MAIN_JAR.getID());
boolean hasMainJarClassPath = params.containsKey(CLASSPATH.getID());
boolean hasModule = params.containsKey(MODULE.getID());
- boolean jreInstaller = params.containsKey(Arguments.CREATE_JRE_INSTALLER.getID());
+ boolean jreInstaller =
+ params.containsKey(Arguments.CREATE_JRE_INSTALLER.getID());
- if (hasMainClass && hasMainJar && hasMainJarClassPath || hasModule || jreInstaller) {
+ if (hasMainClass && hasMainJar && hasMainJarClassPath || hasModule ||
+ jreInstaller) {
return;
}
- // it's a pair. The [0] is the srcdir [1] is the file relative to sourcedir
+ // it's a pair.
+ // The [0] is the srcdir [1] is the file relative to sourcedir
List<String[]> filesToCheck = new ArrayList<>();
if (hasMainJar) {
RelativeFileSet rfs = MAIN_JAR.fetchFrom(params);
for (String s : rfs.getIncludedFiles()) {
- filesToCheck.add(new String[]{rfs.getBaseDirectory().toString(), s});
+ filesToCheck.add(
+ new String[] {rfs.getBaseDirectory().toString(), s});
}
} else if (hasMainJarClassPath) {
for (String s : CLASSPATH.fetchFrom(params).split("\\s+")) {
if (APP_RESOURCES.fetchFrom(params) != null) {
- filesToCheck.add(new String[] {APP_RESOURCES.fetchFrom(params).getBaseDirectory().toString(), s});
+ filesToCheck.add(
+ new String[] {APP_RESOURCES.fetchFrom(params)
+ .getBaseDirectory().toString(), s});
}
}
} else {
@@ -697,7 +738,8 @@
if (rfs == null) continue;
for (String s : rfs.getIncludedFiles()) {
- filesToCheck.add(new String[]{rfs.getBaseDirectory().toString(), s});
+ filesToCheck.add(
+ new String[]{rfs.getBaseDirectory().toString(), s});
}
}
}
@@ -714,7 +756,8 @@
try (JarFile jf = new JarFile(file)) {
Manifest m = jf.getManifest();
- Attributes attrs = (m != null) ? m.getMainAttributes() : null;
+ Attributes attrs = (m != null) ?
+ m.getMainAttributes() : null;
if (attrs != null) {
if (!hasMainJar) {
@@ -722,11 +765,15 @@
fnames[0] = file.getParentFile().toString();
}
params.put(MAIN_JAR.getID(), new RelativeFileSet(
- new File(fnames[0]), new LinkedHashSet<>(Collections.singletonList(file))));
+ new File(fnames[0]),
+ new LinkedHashSet<>(Collections
+ .singletonList(file))));
}
if (!hasMainJarClassPath) {
- String cp = attrs.getValue(Attributes.Name.CLASS_PATH);
- params.put(CLASSPATH.getID(), cp == null ? "" : cp);
+ String cp =
+ attrs.getValue(Attributes.Name.CLASS_PATH);
+ params.put(CLASSPATH.getID(),
+ cp == null ? "" : cp);
}
break;
}
@@ -743,9 +790,11 @@
boolean hasMainJar = params.containsKey(MAIN_JAR.getID());
boolean hasMainJarClassPath = params.containsKey(CLASSPATH.getID());
boolean hasModule = params.containsKey(MODULE.getID());
- boolean jreInstaller = params.containsKey(Arguments.CREATE_JRE_INSTALLER.getID());
+ boolean jreInstaller =
+ params.containsKey(Arguments.CREATE_JRE_INSTALLER.getID());
- if (hasMainClass && hasMainJar && hasMainJarClassPath || hasModule || jreInstaller) {
+ if (hasMainClass && hasMainJar && hasMainJarClassPath ||
+ hasModule || jreInstaller) {
return;
}
@@ -754,14 +803,17 @@
if (!params.containsKey(MAIN_CLASS.getID())) {
if (hasMainJar) {
throw new ConfigException(
- MessageFormat.format(I18N.getString("error.no-main-class-with-main-jar"),
- MAIN_JAR.fetchFrom(params)),
- MessageFormat.format(I18N.getString("error.no-main-class-with-main-jar.advice"),
- MAIN_JAR.fetchFrom(params)));
+ MessageFormat.format(I18N.getString(
+ "error.no-main-class-with-main-jar"),
+ MAIN_JAR.fetchFrom(params)),
+ MessageFormat.format(I18N.getString(
+ "error.no-main-class-with-main-jar.advice"),
+ MAIN_JAR.fetchFrom(params)));
} else if (hasMainJarClassPath) {
throw new ConfigException(
I18N.getString("error.no-main-class-with-classpath"),
- I18N.getString("error.no-main-class-with-classpath.advice"));
+ I18N.getString(
+ "error.no-main-class-with-classpath.advice"));
} else {
throw new ConfigException(
I18N.getString("error.no-main-class"),
@@ -792,11 +844,14 @@
return l;
}
- private static List<RelativeFileSet> createAppResourcesListFromString(String s, Map<String, ? super Object> objectObjectMap) {
+ private static List<RelativeFileSet>
+ createAppResourcesListFromString(String s,
+ Map<String, ? super Object> objectObjectMap) {
List<RelativeFileSet> result = new ArrayList<>();
for (String path : s.split("[:;]")) {
File f = new File(path);
- if (f.getName().equals("*") || path.endsWith("/") || path.endsWith("\\")) {
+ if (f.getName().equals("*") || path.endsWith("/") ||
+ path.endsWith("\\")) {
if (f.getName().equals("*")) {
f = f.getParentFile();
}
@@ -810,39 +865,48 @@
}
result.add(new RelativeFileSet(f, theFiles));
} else {
- result.add(new RelativeFileSet(f.getParentFile(), Collections.singleton(f)));
+ result.add(new RelativeFileSet(f.getParentFile(),
+ Collections.singleton(f)));
}
}
return result;
}
- private static RelativeFileSet getMainJar(String moduleName, Map<String, ? super Object> params) {
+ private static RelativeFileSet getMainJar(
+ String moduleName, Map<String, ? super Object> params) {
for (RelativeFileSet rfs : APP_RESOURCES_LIST.fetchFrom(params)) {
File appResourcesRoot = rfs.getBaseDirectory();
File mainJarFile = new File(appResourcesRoot, moduleName);
if (mainJarFile.exists()) {
- return new RelativeFileSet(appResourcesRoot, new LinkedHashSet<>(Collections.singletonList(mainJarFile)));
+ return new RelativeFileSet(appResourcesRoot,
+ new LinkedHashSet<>(Collections.singletonList(
+ mainJarFile)));
}
else {
List<Path> modulePath = MODULE_PATH.fetchFrom(params);
- Path modularJarPath = JLinkBundlerHelper.findPathOfModule(modulePath, moduleName);
+ Path modularJarPath = JLinkBundlerHelper.findPathOfModule(
+ modulePath, moduleName);
if (modularJarPath != null && Files.exists(modularJarPath)) {
- return new RelativeFileSet(appResourcesRoot, new LinkedHashSet<>(Collections.singletonList(modularJarPath.toFile())));
+ return new RelativeFileSet(appResourcesRoot,
+ new LinkedHashSet<>(Collections.singletonList(
+ modularJarPath.toFile())));
}
}
}
throw new IllegalArgumentException(
- new ConfigException(
- MessageFormat.format(I18N.getString("error.main-jar-does-not-exist"), moduleName),
- I18N.getString("error.main-jar-does-not-exist.advice")));
+ new ConfigException(MessageFormat.format(I18N.getString(
+ "error.main-jar-does-not-exist"),
+ moduleName), I18N.getString(
+ "error.main-jar-does-not-exist.advice")));
}
public static List<Path> getDefaultModulePath() {
List<Path> result = new ArrayList();
- Path jdkModulePath = Paths.get(System.getProperty("java.home"), "jmods").toAbsolutePath();
+ Path jdkModulePath = Paths.get(
+ System.getProperty("java.home"), "jmods").toAbsolutePath();
if (jdkModulePath != null && Files.exists(jdkModulePath)) {
result.add(jdkModulePath);
@@ -854,7 +918,9 @@
Map<String, String> env = System.getenv();
if (env.containsKey("JDK_HOME")) {
- jdkModulePath = Paths.get(env.get("JDK_HOME"), ".." + File.separator + "images" + File.separator + "jmods").toAbsolutePath();
+ jdkModulePath = Paths.get(env.get("JDK_HOME"),
+ ".." + File.separator + "images"
+ + File.separator + "jmods").toAbsolutePath();
if (jdkModulePath != null && Files.exists(jdkModulePath)) {
result.add(jdkModulePath);
--- a/src/jdk.packager/share/classes/jdk/packager/internal/ValidOptions.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/share/classes/jdk/packager/internal/ValidOptions.java Mon Aug 27 16:01:38 2018 -0400
@@ -36,7 +36,8 @@
private ValidOptions() {};
// multimap that contains pairs of (mode, supported args)
- private static final Map<CLIOptions, Set<CLIOptions>> options = new HashMap<>();
+ private static final Map<CLIOptions, Set<CLIOptions>> options =
+ new HashMap<>();
private static boolean argsInitialized = false;
@@ -102,14 +103,16 @@
if (Platform.getPlatform() == Platform.MAC) {
add(CLIOptions.CREATE_INSTALLER, CLIOptions.MAC_APP_STORE_CATEGORY);
- add(CLIOptions.CREATE_INSTALLER, CLIOptions.MAC_APP_STORE_ENTITLEMENTS);
+ add(CLIOptions.CREATE_INSTALLER,
+ CLIOptions.MAC_APP_STORE_ENTITLEMENTS);
}
if (Platform.getPlatform() == Platform.LINUX) {
add(CLIOptions.CREATE_INSTALLER, CLIOptions.LINUX_BUNDLE_NAME);
add(CLIOptions.CREATE_INSTALLER, CLIOptions.LINUX_DEB_MAINTAINER);
add(CLIOptions.CREATE_INSTALLER, CLIOptions.LINUX_RPM_LICENSE_TYPE);
- add(CLIOptions.CREATE_INSTALLER, CLIOptions.LINUX_PACKAGE_DEPENDENCIES);
+ add(CLIOptions.CREATE_INSTALLER,
+ CLIOptions.LINUX_PACKAGE_DEPENDENCIES);
add(CLIOptions.CREATE_INSTALLER, CLIOptions.DESCRIPTION);
add(CLIOptions.CREATE_INSTALLER, CLIOptions.VENDOR);
add(CLIOptions.CREATE_INSTALLER, CLIOptions.CATEGORY);
@@ -120,7 +123,8 @@
add(CLIOptions.CREATE_INSTALLER, CLIOptions.WIN_MENU_HINT);
add(CLIOptions.CREATE_INSTALLER, CLIOptions.WIN_MENU_GROUP);
add(CLIOptions.CREATE_INSTALLER, CLIOptions.WIN_SHORTCUT_HINT);
- add(CLIOptions.CREATE_INSTALLER, CLIOptions.WIN_PER_USER_INSTALLATION);
+ add(CLIOptions.CREATE_INSTALLER,
+ CLIOptions.WIN_PER_USER_INSTALLATION);
add(CLIOptions.CREATE_INSTALLER, CLIOptions.WIN_DIR_CHOOSER);
add(CLIOptions.CREATE_INSTALLER, CLIOptions.WIN_REGISTRY_NAME);
add(CLIOptions.CREATE_INSTALLER, CLIOptions.WIN_MSI_UPGRADE_UUID);
@@ -140,7 +144,8 @@
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.BUILD_ROOT);
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.INSTALL_DIR);
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.ECHO_MODE);
- add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.PREDEFINED_RUNTIME_IMAGE);
+ add(CLIOptions.CREATE_JRE_INSTALLER,
+ CLIOptions.PREDEFINED_RUNTIME_IMAGE);
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.ADD_MODULES);
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.MODULE_PATH);
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.LIMIT_MODULES);
@@ -148,27 +153,36 @@
if (Platform.getPlatform() == Platform.MAC) {
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.MAC_SIGN);
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.MAC_BUNDLE_NAME);
- add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.MAC_BUNDLE_IDENTIFIER);
- add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.MAC_BUNDLE_SIGNING_PREFIX);
- add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.MAC_SIGNING_KEY_NAME);
- add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.MAC_SIGNING_KEYCHAIN);
+ add(CLIOptions.CREATE_JRE_INSTALLER,
+ CLIOptions.MAC_BUNDLE_IDENTIFIER);
+ add(CLIOptions.CREATE_JRE_INSTALLER,
+ CLIOptions.MAC_BUNDLE_SIGNING_PREFIX);
+ add(CLIOptions.CREATE_JRE_INSTALLER,
+ CLIOptions.MAC_SIGNING_KEY_NAME);
+ add(CLIOptions.CREATE_JRE_INSTALLER,
+ CLIOptions.MAC_SIGNING_KEYCHAIN);
}
if (Platform.getPlatform() == Platform.WINDOWS) {
- add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.WIN_PER_USER_INSTALLATION);
+ add(CLIOptions.CREATE_JRE_INSTALLER,
+ CLIOptions.WIN_PER_USER_INSTALLATION);
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.WIN_DIR_CHOOSER);
- add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.WIN_MSI_UPGRADE_UUID);
+ add(CLIOptions.CREATE_JRE_INSTALLER,
+ CLIOptions.WIN_MSI_UPGRADE_UUID);
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.DESCRIPTION);
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.VENDOR);
}
if (Platform.getPlatform() == Platform.LINUX) {
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.LINUX_BUNDLE_NAME);
- add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.LINUX_DEB_MAINTAINER);
- add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.LINUX_PACKAGE_DEPENDENCIES);
+ add(CLIOptions.CREATE_JRE_INSTALLER,
+ CLIOptions.LINUX_DEB_MAINTAINER);
+ add(CLIOptions.CREATE_JRE_INSTALLER,
+ CLIOptions.LINUX_PACKAGE_DEPENDENCIES);
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.DESCRIPTION);
add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.VENDOR);
- add(CLIOptions.CREATE_JRE_INSTALLER, CLIOptions.LINUX_RPM_LICENSE_TYPE);
+ add(CLIOptions.CREATE_JRE_INSTALLER,
+ CLIOptions.LINUX_RPM_LICENSE_TYPE);
}
argsInitialized = true;
--- a/src/jdk.packager/windows/classes/jdk/packager/internal/builders/windows/WindowsAppImageBuilder.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/windows/classes/jdk/packager/internal/builders/windows/WindowsAppImageBuilder.java Mon Aug 27 16:01:38 2018 -0400
@@ -68,7 +68,7 @@
private static final ResourceBundle I18N =
ResourceBundle.getBundle(
- "jdk.packager.internal.resources.builders.windows.WindowsAppImageBuilder");
+ "jdk.packager.internal.resources.builders.windows.WindowsAppImageBuilder");
private static final String MODULES_FILENAME =
"jdk/packager/internal/resources/windows/windows.jre.list";
@@ -78,14 +78,13 @@
private final static String EXECUTABLE_NAME = "WinLauncher.exe";
private final static String LIBRARY_NAME = "packager.dll";
- // TODO: do we still need this?
- private final static String[] VS_VERS = {"100", "110", "120", "140"};
private final static String REDIST_MSVCR = "vcruntimeVS_VER.dll";
private final static String REDIST_MSVCP = "msvcpVS_VER.dll";
private final static String TEMPLATE_APP_ICON ="javalogo_white_48.ico";
- private static final String EXECUTABLE_PROPERTIES_TEMPLATE = "WinLauncher.properties";
+ private static final String EXECUTABLE_PROPERTIES_TEMPLATE =
+ "WinLauncher.properties";
private final Path root;
private final Path appDir;
@@ -94,19 +93,22 @@
private final Map<String, ? super Object> params;
- public static final BundlerParamInfo<File> CONFIG_ROOT = new WindowsBundlerParam<>(
+ public static final BundlerParamInfo<File> CONFIG_ROOT =
+ new WindowsBundlerParam<>(
I18N.getString("param.config-root.name"),
I18N.getString("param.config-root.description"),
"configRoot",
File.class,
params -> {
- File imagesRoot = new File(BUILD_ROOT.fetchFrom(params), "windows");
+ File imagesRoot =
+ new File(BUILD_ROOT.fetchFrom(params), "windows");
imagesRoot.mkdirs();
return imagesRoot;
},
(s, p) -> null);
- public static final BundlerParamInfo<Boolean> REBRAND_EXECUTABLE = new WindowsBundlerParam<>(
+ public static final BundlerParamInfo<Boolean> REBRAND_EXECUTABLE =
+ new WindowsBundlerParam<>(
I18N.getString("param.rebrand-executable.name"),
I18N.getString("param.rebrand-executable.description"),
"win.launcher.rebrand",
@@ -114,7 +116,8 @@
params -> Boolean.TRUE,
(s, p) -> Boolean.valueOf(s));
- public static final BundlerParamInfo<File> ICON_ICO = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> ICON_ICO =
+ new StandardBundlerParam<>(
I18N.getString("param.icon-ico.name"),
I18N.getString("param.icon-ico.description"),
"icon.ico",
@@ -122,7 +125,8 @@
params -> {
File f = ICON.fetchFrom(params);
if (f != null && !f.getName().toLowerCase().endsWith(".ico")) {
- Log.info(MessageFormat.format(I18N.getString("message.icon-not-ico"), f));
+ Log.info(MessageFormat.format(
+ I18N.getString("message.icon-not-ico"), f));
return null;
}
return f;
@@ -131,8 +135,10 @@
- public WindowsAppImageBuilder(Map<String, Object> config, Path imageOutDir) throws IOException {
- super(config, imageOutDir.resolve(APP_NAME.fetchFrom(config) + "/runtime"));
+ public WindowsAppImageBuilder(Map<String, Object> config, Path imageOutDir)
+ throws IOException {
+ super(config,
+ imageOutDir.resolve(APP_NAME.fetchFrom(config) + "/runtime"));
Objects.requireNonNull(imageOutDir);
@@ -146,7 +152,8 @@
Files.createDirectories(runtimeDir);
}
- public WindowsAppImageBuilder(String jreName, Path imageOutDir) throws IOException {
+ public WindowsAppImageBuilder(String jreName, Path imageOutDir)
+ throws IOException {
super(null, imageOutDir.resolve(jreName));
Objects.requireNonNull(imageOutDir);
@@ -178,7 +185,8 @@
*/
private void setExecutable(Path file) {
try {
- Set<PosixFilePermission> perms = Files.getPosixFilePermissions(file);
+ Set<PosixFilePermission> perms =
+ Files.getPosixFilePermissions(file);
perms.add(PosixFilePermission.OWNER_EXECUTE);
perms.add(PosixFilePermission.GROUP_EXECUTE);
perms.add(PosixFilePermission.OTHERS_EXECUTE);
@@ -188,7 +196,8 @@
}
}
- private static void createUtf8File(File file, String content) throws IOException {
+ private static void createUtf8File(File file, String content)
+ throws IOException {
try (OutputStream fout = new FileOutputStream(file);
Writer output = new OutputStreamWriter(fout, "UTF-8")) {
output.write(content);
@@ -210,11 +219,14 @@
}
private File getConfig_AppIcon(Map<String, ? super Object> params) {
- return new File(getConfigRoot(params), APP_FS_NAME.fetchFrom(params) + ".ico");
+ return new File(getConfigRoot(params),
+ APP_FS_NAME.fetchFrom(params) + ".ico");
}
- private File getConfig_ExecutableProperties(Map<String, ? super Object> params) {
- return new File(getConfigRoot(params), APP_FS_NAME.fetchFrom(params) + ".properties");
+ private File getConfig_ExecutableProperties(
+ Map<String, ? super Object> params) {
+ return new File(getConfigRoot(params),
+ APP_FS_NAME.fetchFrom(params) + ".properties");
}
File getConfigRoot(Map<String, ? super Object> params) {
@@ -238,12 +250,13 @@
Map<String, ? super Object> originalParams = new HashMap<>(params);
File rootFile = root.toFile();
if (!rootFile.isDirectory() && !rootFile.mkdirs()) {
- throw new RuntimeException(MessageFormat.format(
- I18N.getString("error.cannot-create-output-dir"), rootFile.getAbsolutePath()));
+ throw new RuntimeException(MessageFormat.format(I18N.getString(
+ "error.cannot-create-output-dir"), rootFile.getAbsolutePath()));
}
if (!rootFile.canWrite()) {
throw new RuntimeException(MessageFormat.format(
- I18N.getString("error.cannot-write-to-output-dir"), rootFile.getAbsolutePath()));
+ I18N.getString("error.cannot-write-to-output-dir"),
+ rootFile.getAbsolutePath()));
}
try {
// create the .exe launchers
@@ -309,9 +322,11 @@
// TODO: do we still need this?
private boolean copyMSVCDLLs(String VS_VER) throws IOException {
- final InputStream REDIST_MSVCR_URL = WinResources.class.getResourceAsStream(
+ final InputStream REDIST_MSVCR_URL =
+ WinResources.class.getResourceAsStream(
REDIST_MSVCR.replaceAll("VS_VER", VS_VER));
- final InputStream REDIST_MSVCP_URL = WinResources.class.getResourceAsStream(
+ final InputStream REDIST_MSVCP_URL =
+ WinResources.class.getResourceAsStream(
REDIST_MSVCP.replaceAll("VS_VER", VS_VER));
if (REDIST_MSVCR_URL != null && REDIST_MSVCP_URL != null) {
@@ -327,19 +342,22 @@
return false;
}
- private void validateValueAndPut(Map<String, String> data, String key,
- BundlerParamInfo<String> param, Map<String, ? super Object> params) {
+ private void validateValueAndPut(
+ Map<String, String> data, String key,
+ BundlerParamInfo<String> param,
+ Map<String, ? super Object> params) {
String value = param.fetchFrom(params);
if (value.contains("\r") || value.contains("\n")) {
- Log.info("Configuration Parameter " + param.getID() + " contains multiple lines of text, ignore it");
+ Log.info("Configuration Parameter " + param.getID()
+ + " contains multiple lines of text, ignore it");
data.put(key, "");
return;
}
data.put(key, value);
}
- protected void prepareExecutableProperties(Map<String, ? super Object> params)
- throws IOException {
+ protected void prepareExecutableProperties(
+ Map<String, ? super Object> params) throws IOException {
Map<String, String> data = new HashMap<>();
// mapping Java parameters in strings for version resource
@@ -356,9 +374,10 @@
validateValueAndPut(data, "PRODUCT_VERSION", VERSION, params);
data.put("SPECIAL_BUILD", "");
- Writer w = new BufferedWriter(new FileWriter(getConfig_ExecutableProperties(params)));
- String content = preprocessTextResource(
- WINDOWS_BUNDLER_PREFIX + getConfig_ExecutableProperties(params).getName(),
+ Writer w = new BufferedWriter(
+ new FileWriter(getConfig_ExecutableProperties(params)));
+ String content = preprocessTextResource(WINDOWS_BUNDLER_PREFIX
+ + getConfig_ExecutableProperties(params).getName(),
I18N.getString("resource.executable-properties-template"),
EXECUTABLE_PROPERTIES_TEMPLATE, data,
VERBOSE.fetchFrom(params),
@@ -367,13 +386,16 @@
w.close();
}
- private void createLauncherForEntryPoint(Map<String, ? super Object> p) throws IOException {
+ private void createLauncherForEntryPoint(
+ Map<String, ? super Object> p) throws IOException {
File launcherIcon = ICON_ICO.fetchFrom(p);
- File icon = launcherIcon != null ? launcherIcon : ICON_ICO.fetchFrom(params);
+ File icon = launcherIcon != null ?
+ launcherIcon : ICON_ICO.fetchFrom(params);
File iconTarget = getConfig_AppIcon(p);
- InputStream in = locateResource("package/windows/" + APP_NAME.fetchFrom(params) + ".ico",
+ InputStream in = locateResource(
+ "package/windows/" + APP_NAME.fetchFrom(params) + ".ico",
"icon",
TEMPLATE_APP_ICON,
icon,
@@ -381,13 +403,15 @@
DROP_IN_RESOURCES_ROOT.fetchFrom(params));
Files.copy(in, iconTarget.toPath());
- writeCfgFile(p, root.resolve(getLauncherCfgName(p)).toFile(), "$APPDIR\\runtime");
+ writeCfgFile(p, root.resolve(
+ getLauncherCfgName(p)).toFile(), "$APPDIR\\runtime");
prepareExecutableProperties(p);
// Copy executable root folder
Path executableFile = root.resolve(getLauncherName(p));
- try (InputStream is_launcher = getResourceAsStream("papplauncher.exe")) {
+ try (InputStream is_launcher =
+ getResourceAsStream("papplauncher.exe")) {
writeEntry(is_launcher, executableFile);
}
@@ -396,7 +420,8 @@
// Update branding of EXE file
if (REBRAND_EXECUTABLE.fetchFrom(p)) {
- File tool = new File(System.getProperty("java.home") + "\\bin\\jpackager.exe");
+ File tool = new File(
+ System.getProperty("java.home") + "\\bin\\jpackager.exe");
// Run tool on launcher file to change the icon and the metadata.
try {
@@ -433,11 +458,14 @@
}
}
- Files.copy(iconTarget.toPath(), root.resolve(APP_NAME.fetchFrom(p) + ".ico"));
+ Files.copy(iconTarget.toPath(),
+ root.resolve(APP_NAME.fetchFrom(p) + ".ico"));
}
- private void copyApplication(Map<String, ? super Object> params) throws IOException {
- List<RelativeFileSet> appResourcesList = APP_RESOURCES_LIST.fetchFrom(params);
+ private void copyApplication(Map<String, ? super Object> params)
+ throws IOException {
+ List<RelativeFileSet> appResourcesList =
+ APP_RESOURCES_LIST.fetchFrom(params);
if (appResourcesList == null) {
throw new RuntimeException("Null app resources?");
}
--- a/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinAppBundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinAppBundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -55,9 +55,11 @@
public class WinAppBundler extends AbstractImageBundler {
private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.windows.WinAppBundler");
+ ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.windows.WinAppBundler");
- public static final BundlerParamInfo<File> ICON_ICO = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<File> ICON_ICO =
+ new StandardBundlerParam<>(
I18N.getString("param.icon-ico.name"),
I18N.getString("param.icon-ico.description"),
"icon.ico",
@@ -65,7 +67,8 @@
params -> {
File f = ICON.fetchFrom(params);
if (f != null && !f.getName().toLowerCase().endsWith(".ico")) {
- Log.info(MessageFormat.format(I18N.getString("message.icon-not-ico"), f));
+ Log.info(MessageFormat.format(
+ I18N.getString("message.icon-not-ico"), f));
return null;
}
return f;
@@ -113,7 +116,8 @@
}
// Make sure that jpackager.exe exists.
- File tool = new File(System.getProperty("java.home") + "\\bin\\jpackager.exe");
+ File tool = new File(
+ System.getProperty("java.home") + "\\bin\\jpackager.exe");
if (!tool.exists()) {
throw new ConfigException(
@@ -121,21 +125,22 @@
I18N.getString("error.no-windows-resources.advice"));
}
- //validate runtime bit-architectire
+ // validate runtime bit-architectire
testRuntimeBitArchitecture(p);
return true;
}
- private static void testRuntimeBitArchitecture(Map<String, ? super Object> params)
- throws ConfigException {
+ private static void testRuntimeBitArchitecture(
+ Map<String, ? super Object> params) throws ConfigException {
if ("true".equalsIgnoreCase(System.getProperty(
"fxpackager.disableBitArchitectureMismatchCheck"))) {
Log.debug(I18N.getString("message.disable-bit-architecture-check"));
return;
}
- if ((BIT_ARCH_64.fetchFrom(params) != BIT_ARCH_64_RUNTIME.fetchFrom(params))) {
+ if ((BIT_ARCH_64.fetchFrom(params) !=
+ BIT_ARCH_64_RUNTIME.fetchFrom(params))) {
throw new ConfigException(
I18N.getString("error.bit-architecture-mismatch"),
I18N.getString("error.bit-architecture-mismatch.advice"));
@@ -191,7 +196,8 @@
return rootDirectory;
}
- File doBundle(Map<String, ? super Object> p, File outputDirectory, boolean dependentTask) {
+ File doBundle(Map<String, ? super Object> p,
+ File outputDirectory, boolean dependentTask) {
if (Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) {
return doJreBundle(p, outputDirectory, dependentTask);
} else {
@@ -199,7 +205,8 @@
}
}
- File doJreBundle(Map<String, ? super Object> p, File outputDirectory, boolean dependentTask) {
+ File doJreBundle(Map<String, ? super Object> p,
+ File outputDirectory, boolean dependentTask) {
try {
File rootDirectory = createRoot(p, outputDirectory, dependentTask);
AbstractAppImageBuilder appBuilder = new WindowsAppImageBuilder(
@@ -223,10 +230,13 @@
}
}
- File doAppBundle(Map<String, ? super Object> p, File outputDirectory, boolean dependentTask) {
+ File doAppBundle(Map<String, ? super Object> p,
+ File outputDirectory, boolean dependentTask) {
try {
- File rootDirectory = createRoot(p, outputDirectory, dependentTask);
- AbstractAppImageBuilder appBuilder = new WindowsAppImageBuilder(p, outputDirectory.toPath());
+ File rootDirectory =
+ createRoot(p, outputDirectory, dependentTask);
+ AbstractAppImageBuilder appBuilder =
+ new WindowsAppImageBuilder(p, outputDirectory.toPath());
if (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null ) {
JLinkBundlerHelper.execute(p, appBuilder);
} else {
@@ -251,7 +261,8 @@
private static final String RUNTIME_AUTO_DETECT = ".runtime.autodetect";
- public static void extractFlagsFromRuntime(Map<String, ? super Object> params) {
+ public static void extractFlagsFromRuntime(
+ Map<String, ? super Object> params) {
if (params.containsKey(".runtime.autodetect")) return;
params.put(RUNTIME_AUTO_DETECT, "attempted");
@@ -260,7 +271,8 @@
File runtimePath = JLinkBundlerHelper.getJDKHome(params).toFile();
File launcherPath = new File(runtimePath, "bin\\java.exe");
- ProcessBuilder pb = new ProcessBuilder(launcherPath.getAbsolutePath(), "-version");
+ ProcessBuilder pb =
+ new ProcessBuilder(launcherPath.getAbsolutePath(), "-version");
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
try (PrintStream pout = new PrintStream(baos)) {
IOUtils.exec(pb, Log.isDebug(), true, pout);
@@ -322,7 +334,8 @@
}
@Override
- public File execute(Map<String, ? super Object> params, File outputParentDir) {
+ public File execute(
+ Map<String, ? super Object> params, File outputParentDir) {
return doBundle(params, outputParentDir, false);
}
--- a/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinMsiBundler.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WinMsiBundler.java Mon Aug 27 16:01:38 2018 -0400
@@ -44,7 +44,8 @@
public class WinMsiBundler extends AbstractBundler {
private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.windows.WinMsiBundler");
+ ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.windows.WinMsiBundler");
public static final BundlerParamInfo<WinAppBundler> APP_BUNDLER =
new WindowsBundlerParam<>(
@@ -71,7 +72,8 @@
"configRoot",
File.class,
params -> {
- File imagesRoot = new File(BUILD_ROOT.fetchFrom(params), "windows");
+ File imagesRoot =
+ new File(BUILD_ROOT.fetchFrom(params), "windows");
imagesRoot.mkdirs();
return imagesRoot;
},
@@ -106,8 +108,10 @@
Arguments.CLIOptions.WIN_PER_USER_INSTALLATION.getId(),
Boolean.class,
params -> true, // MSIs default to system wide
+ // valueOf(null) is false,
+ // and we actually do want null
(s, p) -> (s == null || "null".equalsIgnoreCase(s))? null
- : Boolean.valueOf(s) // valueOf(null) is false, and we actually do want null
+ : Boolean.valueOf(s)
);
@@ -121,12 +125,14 @@
(s, p) -> s
);
- public static final BundlerParamInfo<UUID> UPGRADE_UUID = new WindowsBundlerParam<>(
+ public static final BundlerParamInfo<UUID> UPGRADE_UUID =
+ new WindowsBundlerParam<>(
I18N.getString("param.upgrade-uuid.name"),
I18N.getString("param.upgrade-uuid.description"),
Arguments.CLIOptions.WIN_MSI_UPGRADE_UUID.getId(),
UUID.class,
- params -> UUID.randomUUID(), // TODO check to see if identifier is a valid UUID during default
+ params -> UUID.randomUUID(), // TODO check to see
+ // if identifier is a valid UUID during default
(s, p) -> UUID.fromString(s));
private static final String TOOL_CANDLE = "candle.exe";
@@ -144,7 +150,8 @@
+ "C:\\Program Files (x86)\\WiX Toolset v3.7\\bin;"
+ "C:\\Program Files\\WiX Toolset v3.7\\bin";
- public static final BundlerParamInfo<String> TOOL_CANDLE_EXECUTABLE = new WindowsBundlerParam<>(
+ public static final BundlerParamInfo<String> TOOL_CANDLE_EXECUTABLE =
+ new WindowsBundlerParam<>(
I18N.getString("param.candle-path.name"),
I18N.getString("param.candle-path.description"),
"win.msi.candle.exe",
@@ -186,8 +193,10 @@
Arguments.CLIOptions.WIN_MENU_HINT.getId(),
Boolean.class,
params -> false,
- // valueOf(null) is false, and we actually do want null in some cases
- (s, p) -> (s == null || "null".equalsIgnoreCase(s))? true : Boolean.valueOf(s)
+ // valueOf(null) is false,
+ // and we actually do want null in some cases
+ (s, p) -> (s == null ||
+ "null".equalsIgnoreCase(s))? true : Boolean.valueOf(s)
);
public static final StandardBundlerParam<Boolean> SHORTCUT_HINT =
@@ -197,8 +206,10 @@
Arguments.CLIOptions.WIN_SHORTCUT_HINT.getId(),
Boolean.class,
params -> false,
- // valueOf(null) is false, and we actually do want null in some cases
- (s, p) -> (s == null || "null".equalsIgnoreCase(s))? false : Boolean.valueOf(s)
+ // valueOf(null) is false,
+ // and we actually do want null in some cases
+ (s, p) -> (s == null ||
+ "null".equalsIgnoreCase(s))? false : Boolean.valueOf(s)
);
public WinMsiBundler() {
@@ -241,11 +252,11 @@
MENU_GROUP,
MENU_HINT,
PRODUCT_VERSION,
-// RUN_AT_STARTUP,
+ // RUN_AT_STARTUP,
SHORTCUT_HINT,
-// SERVICE_HINT,
-// START_ON_INSTALL,
-// STOP_ON_UNINSTALL,
+ // SERVICE_HINT,
+ // START_ON_INSTALL,
+ // STOP_ON_UNINSTALL,
MSI_SYSTEM_WIDE,
//UPGRADE_UUID,
VENDOR,
@@ -255,7 +266,8 @@
}
@Override
- public File execute(Map<String, ? super Object> params, File outputParentDir) {
+ public File execute(
+ Map<String, ? super Object> params, File outputParentDir) {
return bundle(params, outputParentDir);
}
@@ -273,7 +285,8 @@
double getVersion() {
if (version == 0f) {
- String content = new String(((ByteArrayOutputStream) out).toByteArray());
+ String content =
+ new String(((ByteArrayOutputStream) out).toByteArray());
Pattern pattern = Pattern.compile("version (\\d+.\\d+)");
Matcher matcher = pattern.matcher(content);
if (matcher.find()) {
@@ -293,7 +306,8 @@
toolName,
"/?");
VersionExtractor ve = new VersionExtractor();
- IOUtils.exec(pb, Log.isDebug(), true, ve); //not interested in the output
+ // not interested in the output
+ IOUtils.exec(pb, Log.isDebug(), true, ve);
double version = ve.getVersion();
Log.verbose(MessageFormat.format(
I18N.getString("message.tool-version"),
@@ -315,14 +329,16 @@
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
+ // run basic validation to ensure requirements are met
+ // we are not interested in return code, only possible exception
APP_BUNDLER.fetchFrom(p).doValidate(p);
- double candleVersion = findToolVersion(TOOL_CANDLE_EXECUTABLE.fetchFrom(p));
- double lightVersion = findToolVersion(TOOL_LIGHT_EXECUTABLE.fetchFrom(p));
+ double candleVersion =
+ findToolVersion(TOOL_CANDLE_EXECUTABLE.fetchFrom(p));
+ double lightVersion =
+ findToolVersion(TOOL_LIGHT_EXECUTABLE.fetchFrom(p));
- //WiX 3.0+ is required
+ // WiX 3.0+ is required
double minVersion = 3.0f;
boolean bad = false;
@@ -355,32 +371,34 @@
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("error.version-string-wrong-format.advice"),
+ MessageFormat.format(I18N.getString(
+ "error.version-string-wrong-format"), version),
+ MessageFormat.format(I18N.getString(
+ "error.version-string-wrong-format.advice"),
PRODUCT_VERSION.getID()));
}
// only one mime type per association, at least one file extension
- List<Map<String, ? super Object>> associations = FILE_ASSOCIATIONS.fetchFrom(p);
+ 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) {
- throw new ConfigException(
- MessageFormat.format(
- I18N.getString("error.too-many-content-types-for-file-association"), i),
- I18N.getString("error.too-many-content-types-for-file-association.advice"));
+ throw new ConfigException(MessageFormat.format(
+ I18N.getString("error.too-many-content-"
+ + "types-for-file-association"), i),
+ I18N.getString("error.too-many-content-"
+ + "types-for-file-association.advice"));
}
}
}
// validate license file, if used, exists in the proper place
if (p.containsKey(LICENSE_FILE.getID())) {
- List<RelativeFileSet> appResourcesList = APP_RESOURCES_LIST.fetchFrom(p);
+ List<RelativeFileSet> appResourcesList =
+ APP_RESOURCES_LIST.fetchFrom(p);
for (String license : LICENSE_FILE.fetchFrom(p)) {
boolean found = false;
for (RelativeFileSet appResources : appResourcesList) {
@@ -406,12 +424,12 @@
}
}
- //http://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
+ // http://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) {
@@ -420,27 +438,31 @@
String p[] = v.split("\\.");
if (p.length > 3) {
- Log.verbose(I18N.getString("message.version-string-too-many-components"));
+ 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"));
+ 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"));
+ 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"));
+ Log.verbose(I18N.getString(
+ "error.version-string-build-out-of-range"));
return false;
}
}
@@ -453,7 +475,8 @@
return true;
}
- private boolean prepareProto(Map<String, ? super Object> p) throws IOException {
+ private boolean prepareProto(Map<String, ? super Object> p)
+ throws IOException {
File appDir = StandardBundlerParam.getPredefinedAppImage(p);
if (appDir == null) {
@@ -465,7 +488,7 @@
List<String> licenseFiles = LICENSE_FILE.fetchFrom(p);
if (licenseFiles != null) {
- //need to copy license file to the root of win.app.image
+ // need to copy license file to the root of win.app.image
outerLoop:
for (RelativeFileSet rfs : APP_RESOURCES_LIST.fetchFrom(p)) {
for (String s : licenseFiles) {
@@ -481,9 +504,10 @@
}
// copy file association icons
- List<Map<String, ? super Object>> fileAssociations = FILE_ASSOCIATIONS.fetchFrom(p);
- for (Map<String, ? super Object> fileAssociation : fileAssociations) {
- File icon = FA_ICON.fetchFrom(fileAssociation); //TODO FA_ICON_ICO
+ 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;
}
@@ -505,11 +529,13 @@
public File bundle(Map<String, ? super Object> p, File outdir) {
if (!outdir.isDirectory() && !outdir.mkdirs()) {
throw new RuntimeException(MessageFormat.format(
- I18N.getString("error.cannot-create-output-dir"), outdir.getAbsolutePath()));
+ I18N.getString("error.cannot-create-output-dir"),
+ outdir.getAbsolutePath()));
}
if (!outdir.canWrite()) {
throw new RuntimeException(MessageFormat.format(
- I18N.getString("error.cannot-write-to-output-dir"), outdir.getAbsolutePath()));
+ I18N.getString("error.cannot-write-to-output-dir"),
+ outdir.getAbsolutePath()));
}
// validate we have valid tools before continuing
@@ -518,8 +544,10 @@
if (light == null || !new File(light).isFile() ||
candle == null || !new File(candle).isFile()) {
Log.info(I18N.getString("error.no-wix-tools"));
- Log.info(MessageFormat.format(I18N.getString("message.light-file-string"), light));
- Log.info(MessageFormat.format(I18N.getString("message.candle-file-string"), candle));
+ Log.info(MessageFormat.format(
+ I18N.getString("message.light-file-string"), light));
+ Log.info(MessageFormat.format(
+ I18N.getString("message.candle-file-string"), candle));
return null;
}
@@ -530,7 +558,7 @@
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
+ // 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);
}
@@ -539,17 +567,20 @@
&& prepareBasicProjectConfig(p)) {
File configScriptSrc = getConfig_Script(p);
if (configScriptSrc.exists()) {
- //we need to be running post script in the image folder
+ // 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?
+ // NOTE: Would it be better to generate it to the image
+ // folder and save only if "verbose" is requested?
// for now we replicate it
- File configScript = new File(imageDir, configScriptSrc.getName());
+ File configScript =
+ new File(imageDir, configScriptSrc.getName());
IOUtils.copyFile(configScriptSrc, configScript);
Log.info(MessageFormat.format(
- I18N.getString("message.running-wsh-script"), configScript.getAbsolutePath()));
- IOUtils.run("wscript", configScript, ECHO_MODE.fetchFrom(p));
+ I18N.getString("message.running-wsh-script"),
+ configScript.getAbsolutePath()));
+ IOUtils.run("wscript",
+ configScript, ECHO_MODE.fetchFrom(p));
}
return buildMSI(p, outdir);
}
@@ -559,8 +590,10 @@
return null;
} finally {
try {
- if (imageDir != null && PREDEFINED_APP_IMAGE.fetchFrom(p) == null &&
- (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null || !Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) &&
+ if (imageDir != null &&
+ PREDEFINED_APP_IMAGE.fetchFrom(p) == null &&
+ (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null ||
+ !Arguments.CREATE_JRE_INSTALLER.fetchFrom(p)) &&
!Log.isDebug()) {
IOUtils.deleteRecursive(imageDir);
} else if (imageDir != null) {
@@ -576,7 +609,7 @@
cleanupConfigFiles(p);
}
} catch (IOException ex) {
- //noinspection ReturnInsideFinallyBlock
+ // noinspection ReturnInsideFinallyBlock
Log.debug(ex.getMessage());
return null;
}
@@ -594,13 +627,14 @@
}
}
- //name of post-image script
+ // name of post-image script
private File getConfig_Script(Map<String, ? super Object> params) {
return new File(CONFIG_ROOT.fetchFrom(params),
APP_FS_NAME.fetchFrom(params) + "-post-image.wsf");
}
- private boolean prepareBasicProjectConfig(Map<String, ? super Object> params) throws IOException {
+ private boolean prepareBasicProjectConfig(
+ Map<String, ? super Object> params) throws IOException {
fetchResource(WinAppBundler.WIN_BUNDLER_PREFIX +
getConfig_Script(params).getName(),
I18N.getString("resource.post-install-script"),
@@ -616,29 +650,34 @@
basedir.getAbsolutePath().length() + 1);
}
- boolean prepareMainProjectFile(Map<String, ? super Object> params) throws IOException {
+ boolean prepareMainProjectFile(
+ Map<String, ? super Object> params) throws IOException {
Map<String, String> data = new HashMap<>();
UUID productGUID = UUID.randomUUID();
Log.verbose(MessageFormat.format(
- I18N.getString("message.generated-product-guid"), productGUID.toString()));
+ I18N.getString("message.generated-product-guid"),
+ productGUID.toString()));
- //we use random GUID for product itself but
+ // we use random GUID for product itself but
// user provided for upgrade guid
- // Upgrade guid is important to decide whether it is upgrade of installed
- // app. I.e. we need it to be the same for 2 different versions of app if possible
+ // Upgrade guid is important to decide whether it is an upgrade of
+ // installed app. I.e. we need it to be the same for
+ // 2 different versions of app if possible
data.put("PRODUCT_GUID", productGUID.toString());
- data.put("PRODUCT_UPGRADE_GUID", UPGRADE_UUID.fetchFrom(params).toString());
+ data.put("PRODUCT_UPGRADE_GUID",
+ UPGRADE_UUID.fetchFrom(params).toString());
data.put("APPLICATION_NAME", APP_NAME.fetchFrom(params));
data.put("APPLICATION_DESCRIPTION", DESCRIPTION.fetchFrom(params));
data.put("APPLICATION_VENDOR", VENDOR.fetchFrom(params));
data.put("APPLICATION_VERSION", PRODUCT_VERSION.fetchFrom(params));
- //WinAppBundler will add application folder again => step out
+ // WinAppBundler will add application folder again => step out
File imageRootDir = WIN_APP_IMAGE.fetchFrom(params);
- File launcher = new File(imageRootDir, WinAppBundler.getLauncherName(params));
+ File launcher = new File(imageRootDir,
+ WinAppBundler.getLauncherName(params));
String launcherPath = relativePath(imageRootDir, launcher);
data.put("APPLICATION_LAUNCHER", launcherPath);
@@ -677,11 +716,14 @@
StringBuilder secondaryLauncherIcons = new StringBuilder();
for (int i = 0; i < secondaryLaunchers.size(); i++) {
Map<String, ? super Object> sl = secondaryLaunchers.get(i);
- // <Icon Id="DesktopIcon.exe" SourceFile="APPLICATION_ICON" />
+ // <Icon Id="DesktopIcon.exe" SourceFile="APPLICATION_ICON" />
if (SHORTCUT_HINT.fetchFrom(sl) || MENU_HINT.fetchFrom(sl)) {
- File secondaryLauncher = new File(imageRootDir, WinAppBundler.getLauncherName(sl));
- String secondaryLauncherPath = relativePath(imageRootDir, secondaryLauncher);
- String secondaryLauncherIconPath = secondaryLauncherPath.replace(".exe", ".ico");
+ File secondaryLauncher = new File(imageRootDir,
+ WinAppBundler.getLauncherName(sl));
+ String secondaryLauncherPath =
+ relativePath(imageRootDir, secondaryLauncher);
+ String secondaryLauncherIconPath =
+ secondaryLauncherPath.replace(".exe", ".ico");
secondaryLauncherIcons.append(" <Icon Id=\"Launcher");
secondaryLauncherIcons.append(i);
@@ -694,9 +736,11 @@
String wxs = Arguments.CREATE_JRE_INSTALLER.fetchFrom(params) ?
MSI_PROJECT_TEMPLATE_SERVER_JRE : MSI_PROJECT_TEMPLATE;
- Writer w = new BufferedWriter(new FileWriter(getConfig_ProjectFile(params)));
+ Writer w = new BufferedWriter(
+ new FileWriter(getConfig_ProjectFile(params)));
w.write(preprocessTextResource(
- WinAppBundler.WIN_BUNDLER_PREFIX + getConfig_ProjectFile(params).getName(),
+ WinAppBundler.WIN_BUNDLER_PREFIX
+ + getConfig_ProjectFile(params).getName(),
I18N.getString("resource.wix-config-file"),
wxs, data, VERBOSE.fetchFrom(params),
DROP_IN_RESOURCES_ROOT.fetchFrom(params)));
@@ -713,36 +757,41 @@
* to exclude license dialog
*/
private static final String TWEAK_FOR_EXCLUDING_LICENSE =
- " <Publish Dialog=\"WelcomeDlg\" Control=\"Next\"" +
- " Event=\"NewDialog\" Value=\"InstallDirDlg\" Order=\"2\"> 1" +
- " </Publish>\n" +
- " <Publish Dialog=\"InstallDirDlg\" Control=\"Back\"" +
- " Event=\"NewDialog\" Value=\"WelcomeDlg\" Order=\"2\"> 1" +
- " </Publish>\n";
+ " <Publish Dialog=\"WelcomeDlg\" Control=\"Next\""
+ + " Event=\"NewDialog\" Value=\"InstallDirDlg\""
+ + " Order=\"2\"> 1"
+ + " </Publish>\n"
+ + " <Publish Dialog=\"InstallDirDlg\" Control=\"Back\""
+ + " Event=\"NewDialog\" Value=\"WelcomeDlg\""
+ + " Order=\"2\"> 1"
+ + " </Publish>\n";
/**
- * Creates UI element using WiX built-in dialog sets - WixUI_InstallDir/WixUI_Minimal.
+ * Creates UI element using WiX built-in dialog sets
+ * - WixUI_InstallDir/WixUI_Minimal.
* The dialog sets are the closest to what we want to implement.
*
* WixUI_Minimal for license dialog only
- * WixUI_InstallDir for installdir dialog only or for both installdir/license dialogs
+ * WixUI_InstallDir for installdir dialog only or for both
+ * installdir/license dialogs
*/
private String getUIBlock(Map<String, ? super Object> params) {
String uiBlock = " <UI/>\n"; // UI-less element
if (INSTALLDIR_CHOOSER.fetchFrom(params)) {
- boolean enableTweakForExcludingLicense = (getLicenseFile(params) == null);
- uiBlock =
- " <UI>\n" +
- " <Property Id=\"WIXUI_INSTALLDIR\" Value=\"APPLICATIONFOLDER\" />\n" +
- " <UIRef Id=\"WixUI_InstallDir\" />\n" +
- (enableTweakForExcludingLicense ? TWEAK_FOR_EXCLUDING_LICENSE : "") +
- " </UI>\n";
+ boolean enableTweakForExcludingLicense =
+ (getLicenseFile(params) == null);
+ uiBlock = " <UI>\n"
+ + " <Property Id=\"WIXUI_INSTALLDIR\""
+ + " Value=\"APPLICATIONFOLDER\" />\n"
+ + " <UIRef Id=\"WixUI_InstallDir\" />\n"
+ + (enableTweakForExcludingLicense ?
+ TWEAK_FOR_EXCLUDING_LICENSE : "")
+ +" </UI>\n";
} else if (getLicenseFile(params) != null) {
- uiBlock =
- " <UI>\n" +
- " <UIRef Id=\"WixUI_Minimal\" />\n" +
- " </UI>\n";
+ uiBlock = " <UI>\n"
+ + " <UIRef Id=\"WixUI_Minimal\" />\n"
+ + " </UI>\n";
}
return uiBlock;
@@ -760,7 +809,7 @@
root.getAbsolutePath()));
}
- //sort to files and dirs
+ // sort to files and dirs
File[] children = root.listFiles();
if (children != null) {
for (File f : children) {
@@ -772,18 +821,22 @@
}
}
- //have files => need to output component
- out.println(prefix + " <Component Id=\"comp" + (compId++) + "\" DiskId=\"1\""
+ // have files => need to output component
+ out.println(prefix + " <Component Id=\"comp" + (compId++)
+ + "\" DiskId=\"1\""
+ " Guid=\"" + UUID.randomUUID().toString() + "\""
- + (BIT_ARCH_64.fetchFrom(params) ? " Win64=\"yes\"" : "") + ">");
+ + (BIT_ARCH_64.fetchFrom(params) ? " Win64=\"yes\"" : "")
+ + ">");
out.println(prefix + " <CreateFolder/>");
- out.println(prefix + " <RemoveFolder Id=\"RemoveDir" + (id++) + "\" On=\"uninstall\" />");
+ out.println(prefix + " <RemoveFolder Id=\"RemoveDir"
+ + (id++) + "\" On=\"uninstall\" />");
boolean needRegistryKey = !MSI_SYSTEM_WIDE.fetchFrom(params);
File imageRootDir = WIN_APP_IMAGE.fetchFrom(params);
- File launcherFile = new File(imageRootDir, WinAppBundler.getLauncherName(params));
+ File launcherFile =
+ new File(imageRootDir, WinAppBundler.getLauncherName(params));
- //Find out if we need to use registry. We need it if
+ // Find out if we need to use registry. We need it if
// - we doing user level install as file can not serve as KeyPath
// - if we adding shortcut in this component
@@ -795,14 +848,16 @@
}
if (needRegistryKey) {
- //has to be under HKCU to make WiX happy
+ // has to be under HKCU to make WiX happy
out.println(prefix + " <RegistryKey Root=\"HKCU\" "
+ " Key=\"Software\\" + VENDOR.fetchFrom(params) + "\\"
+ APP_NAME.fetchFrom(params) + "\""
- + (CAN_USE_WIX36.fetchFrom(params)
- ? ">" : " Action=\"createAndRemoveOnUninstall\">"));
- out.println(prefix + " <RegistryValue Name=\"Version\" Value=\""
- + VERSION.fetchFrom(params) + "\" Type=\"string\" KeyPath=\"yes\"/>");
+ + (CAN_USE_WIX36.fetchFrom(params) ?
+ ">" : " Action=\"createAndRemoveOnUninstall\">"));
+ out.println(prefix
+ + " <RegistryValue Name=\"Version\" Value=\""
+ + VERSION.fetchFrom(params)
+ + "\" Type=\"string\" KeyPath=\"yes\"/>");
out.println(prefix + " </RegistryKey>");
}
@@ -817,7 +872,8 @@
launcherSet = launcherSet || isLauncher;
- boolean doShortcuts = isLauncher && (menuShortcut || desktopShortcut);
+ boolean doShortcuts =
+ isLauncher && (menuShortcut || desktopShortcut);
String thisFileId = isLauncher ? LAUNCHER_ID : ("FileId" + (id++));
idToFileMap.put(f.getName(), thisFileId);
@@ -826,33 +882,50 @@
thisFileId + "\""
+ " Name=\"" + f.getName() + "\" "
+ " Source=\"" + relativePath(imageRootDir, f) + "\""
- + (BIT_ARCH_64.fetchFrom(params) ? " ProcessorArchitecture=\"x64\"" : "") + ">");
+ + (BIT_ARCH_64.fetchFrom(params) ?
+ " ProcessorArchitecture=\"x64\"" : "") + ">");
if (doShortcuts && desktopShortcut) {
- out.println(prefix + " <Shortcut Id=\"desktopShortcut\" Directory=\"DesktopFolder\""
- + " Name=\"" + APP_NAME.fetchFrom(params) + "\" WorkingDirectory=\"INSTALLDIR\""
- + " Advertise=\"no\" Icon=\"DesktopIcon.exe\" IconIndex=\"0\" />");
+ out.println(prefix
+ + " <Shortcut Id=\"desktopShortcut\" Directory="
+ + "\"DesktopFolder\""
+ + " Name=\"" + APP_NAME.fetchFrom(params)
+ + "\" WorkingDirectory=\"INSTALLDIR\""
+ + " Advertise=\"no\" Icon=\"DesktopIcon.exe\""
+ + " IconIndex=\"0\" />");
}
if (doShortcuts && menuShortcut) {
- out.println(prefix + " <Shortcut Id=\"ExeShortcut\" Directory=\"ProgramMenuDir\""
+ out.println(prefix
+ + " <Shortcut Id=\"ExeShortcut\" Directory="
+ + "\"ProgramMenuDir\""
+ " Name=\"" + APP_NAME.fetchFrom(params)
- + "\" Advertise=\"no\" Icon=\"StartMenuIcon.exe\" IconIndex=\"0\" />");
+ + "\" Advertise=\"no\" Icon=\"StartMenuIcon.exe\""
+ + " IconIndex=\"0\" />");
}
- List<Map<String, ? super Object>> secondaryLaunchers = SECONDARY_LAUNCHERS.fetchFrom(params);
+ List<Map<String, ? super Object>> secondaryLaunchers =
+ SECONDARY_LAUNCHERS.fetchFrom(params);
for (int i = 0; i < secondaryLaunchers.size(); i++) {
Map<String, ? super Object> sl = secondaryLaunchers.get(i);
- File secondaryLauncherFile = new File(imageRootDir, WinAppBundler.getLauncherName(sl));
+ File secondaryLauncherFile = new File(imageRootDir,
+ WinAppBundler.getLauncherName(sl));
if (f.equals(secondaryLauncherFile)) {
if (SHORTCUT_HINT.fetchFrom(sl)) {
- out.println(prefix + " <Shortcut Id=\"desktopShortcut" + i + "\" Directory=\"DesktopFolder\""
- + " Name=\"" + APP_NAME.fetchFrom(sl) + "\" WorkingDirectory=\"INSTALLDIR\""
- + " Advertise=\"no\" Icon=\"Launcher" + i + ".exe\" IconIndex=\"0\" />");
+ out.println(prefix
+ + " <Shortcut Id=\"desktopShortcut"
+ + i + "\" Directory=\"DesktopFolder\""
+ + " Name=\"" + APP_NAME.fetchFrom(sl)
+ + "\" WorkingDirectory=\"INSTALLDIR\""
+ + " Advertise=\"no\" Icon=\"Launcher"
+ + i + ".exe\" IconIndex=\"0\" />");
}
if (MENU_HINT.fetchFrom(sl)) {
- out.println(prefix + " <Shortcut Id=\"ExeShortcut" + i + "\" Directory=\"ProgramMenuDir\""
+ out.println(prefix
+ + " <Shortcut Id=\"ExeShortcut"
+ + i + "\" Directory=\"ProgramMenuDir\""
+ " Name=\"" + APP_NAME.fetchFrom(sl)
- + "\" Advertise=\"no\" Icon=\"Launcher" + i + ".exe\" IconIndex=\"0\" />");
- //Should we allow different menu groups? Not for now.
+ + "\" Advertise=\"no\" Icon=\"Launcher"
+ + i + ".exe\" IconIndex=\"0\" />");
+ // Should we allow different menu groups? Not for now.
}
}
}
@@ -860,29 +933,34 @@
}
if (launcherSet) {
- List<Map<String, ? super Object>> fileAssociations = FILE_ASSOCIATIONS.fetchFrom(params);
+ List<Map<String, ? super Object>> fileAssociations =
+ FILE_ASSOCIATIONS.fetchFrom(params);
String regName = APP_REGISTRY_NAME.fetchFrom(params);
Set<String> defaultedMimes = new TreeSet<>();
int count = 0;
- for (Map<String, ? super Object> fileAssociation : fileAssociations) {
- String description = FA_DESCRIPTION.fetchFrom(fileAssociation);
- List<String> extensions = FA_EXTENSIONS.fetchFrom(fileAssociation);
- List<String> mimeTypes = FA_CONTENT_TYPE.fetchFrom(fileAssociation);
- File icon = FA_ICON.fetchFrom(fileAssociation); //TODO FA_ICON_ICO
+ for (Map<String, ? super Object> fa : fileAssociations) {
+ String description = FA_DESCRIPTION.fetchFrom(fa);
+ List<String> extensions = FA_EXTENSIONS.fetchFrom(fa);
+ List<String> mimeTypes = FA_CONTENT_TYPE.fetchFrom(fa);
+ File icon = FA_ICON.fetchFrom(fa); // TODO FA_ICON_ICO
- String mime = (mimeTypes == null || mimeTypes.isEmpty()) ? null : mimeTypes.get(0);
+ String mime = (mimeTypes == null ||
+ mimeTypes.isEmpty()) ? null : mimeTypes.get(0);
if (extensions == null) {
- Log.info(I18N.getString("message.creating-association-with-null-extension"));
+ Log.info(I18N.getString(
+ "message.creating-association-with-null-extension"));
String entryName = regName + "File";
if (count > 0) {
entryName += "." + count;
}
count++;
- out.print(prefix + " <ProgId Id='" + entryName + "' Description='" + description + "'");
+ out.print(prefix + " <ProgId Id='" + entryName
+ + "' Description='" + description + "'");
if (icon != null && icon.exists()) {
- out.print(" Icon='" + idToFileMap.get(icon.getName()) + "' IconIndex='0'");
+ out.print(" Icon='" + idToFileMap.get(icon.getName())
+ + "' IconIndex='0'");
}
out.println(" />");
} else {
@@ -893,26 +971,36 @@
}
count++;
- out.print(prefix + " <ProgId Id='" + entryName + "' Description='" + description + "'");
+ out.print(prefix + " <ProgId Id='" + entryName
+ + "' Description='" + description + "'");
if (icon != null && icon.exists()) {
- out.print(" Icon='" + idToFileMap.get(icon.getName()) + "' IconIndex='0'");
+ out.print(" Icon='"
+ + idToFileMap.get(icon.getName())
+ + "' IconIndex='0'");
}
out.println(">");
if (extensions == null) {
- Log.info(I18N.getString("message.creating-association-with-null-extension"));
+ Log.info(I18N.getString(
+ "message.creating-association-with-null-extension"));
} else {
- out.print(prefix + " <Extension Id='" + ext + "' Advertise='no'");
+ out.print(prefix + " <Extension Id='"
+ + ext + "' Advertise='no'");
if (mime == null) {
out.println(">");
} else {
out.println(" ContentType='" + mime + "'>");
if (!defaultedMimes.contains(mime)) {
- out.println(prefix + " <MIME ContentType='" + mime + "' Default='yes' />");
+ out.println(prefix
+ + " <MIME ContentType='"
+ + mime + "' Default='yes' />");
defaultedMimes.add(mime);
}
}
- out.println(prefix + " <Verb Id='open' Command='Open' TargetFile='" + LAUNCHER_ID + "' Argument='\"%1\"' />");
+ out.println(prefix
+ + " <Verb Id='open' Command='Open' "
+ + "TargetFile='" + LAUNCHER_ID
+ + "' Argument='\"%1\"' />");
out.println(prefix + " </Extension>");
}
out.println(prefix + " </ProgId>");
@@ -939,56 +1027,66 @@
}
}
- boolean prepareContentList(Map<String, ? super Object> params) throws FileNotFoundException {
- File f = new File(CONFIG_ROOT.fetchFrom(params), MSI_PROJECT_CONTENT_FILE);
+ boolean prepareContentList(Map<String, ? super Object> params)
+ throws FileNotFoundException {
+ File f = new File(
+ CONFIG_ROOT.fetchFrom(params), MSI_PROJECT_CONTENT_FILE);
PrintStream out = new PrintStream(f);
- //opening
+ // opening
out.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
out.println("<Include>");
out.println(" <Directory Id=\"TARGETDIR\" Name=\"SourceDir\">");
if (MSI_SYSTEM_WIDE.fetchFrom(params)) {
- //install to programfiles
+ // install to programfiles
if (BIT_ARCH_64.fetchFrom(params)) {
- out.println(" <Directory Id=\"ProgramFiles64Folder\" Name=\"PFiles\">");
+ out.println(" <Directory Id=\"ProgramFiles64Folder\" "
+ + "Name=\"PFiles\">");
} else {
- out.println(" <Directory Id=\"ProgramFilesFolder\" Name=\"PFiles\">");
+ out.println(" <Directory Id=\"ProgramFilesFolder\" "
+ + "Name=\"PFiles\">");
}
} else {
- //install to user folder
- out.println(" <Directory Name=\"AppData\" Id=\"LocalAppDataFolder\">");
+ // install to user folder
+ out.println(
+ " <Directory Name=\"AppData\" Id=\"LocalAppDataFolder\">");
}
out.println(" <Directory Id=\"APPLICATIONFOLDER\" Name=\""
+ APP_NAME.fetchFrom(params) + "\">");
- //dynamic part
+ // dynamic part
id = 0;
- compId = 0; //reset counters
+ compId = 0; // reset counters
walkFileTree(params, WIN_APP_IMAGE.fetchFrom(params), out, " ");
- //closing
+ // closing
out.println(" </Directory>");
out.println(" </Directory>");
- //for shortcuts
+ // for shortcuts
if (SHORTCUT_HINT.fetchFrom(params)) {
out.println(" <Directory Id=\"DesktopFolder\" />");
}
if (MENU_HINT.fetchFrom(params)) {
out.println(" <Directory Id=\"ProgramMenuFolder\">");
- out.println(" <Directory Id=\"ProgramMenuDir\" Name=\"" + MENU_GROUP.fetchFrom(params) + "\">");
+ out.println(" <Directory Id=\"ProgramMenuDir\" Name=\""
+ + MENU_GROUP.fetchFrom(params) + "\">");
out.println(" <Component Id=\"comp" + (compId++) + "\""
+ " Guid=\"" + UUID.randomUUID().toString() + "\""
- + (BIT_ARCH_64.fetchFrom(params) ? " Win64=\"yes\"" : "") + ">");
- out.println(" <RemoveFolder Id=\"ProgramMenuDir\" On=\"uninstall\" />");
- //This has to be under HKCU to make WiX happy.
- //There are numberous discussions on this amoung WiX users
- // (if user A installs and user B uninstalls then key is left behind)
- //and there are suggested workarounds but none of them are appealing.
- //Leave it for now
- out.println(" <RegistryValue Root=\"HKCU\" Key=\"Software\\"
- + VENDOR.fetchFrom(params) + "\\" + APP_NAME.fetchFrom(params)
+ + (BIT_ARCH_64.fetchFrom(params) ? " Win64=\"yes\"" : "")
+ + ">");
+ out.println(" <RemoveFolder Id=\"ProgramMenuDir\" "
+ + "On=\"uninstall\" />");
+ // This has to be under HKCU to make WiX happy.
+ // There are numberous discussions on this amoung WiX users
+ // (if user A installs and user B uninstalls key is left behind)
+ // there are suggested workarounds but none of them are appealing.
+ // Leave it for now
+ out.println(
+ " <RegistryValue Root=\"HKCU\" Key=\"Software\\"
+ + VENDOR.fetchFrom(params) + "\\"
+ + APP_NAME.fetchFrom(params)
+ "\" Type=\"string\" Value=\"\" />");
out.println(" </Component>");
out.println(" </Directory>");
@@ -997,11 +1095,12 @@
out.println(" </Directory>");
- out.println(" <Feature Id=\"DefaultFeature\" Title=\"Main Feature\" Level=\"1\">");
+ out.println(" <Feature Id=\"DefaultFeature\" "
+ + "Title=\"Main Feature\" Level=\"1\">");
for (int j = 0; j < compId; j++) {
out.println(" <ComponentRef Id=\"comp" + j + "\" />");
}
- //component is defined in the template.wsx
+ // component is defined in the template.wsx
out.println(" <ComponentRef Id=\"CleanupMainApplicationFolder\" />");
out.println(" </Feature>");
out.println("</Include>");
@@ -1011,7 +1110,8 @@
}
private File getConfig_ProjectFile(Map<String, ? super Object> params) {
- return new File(CONFIG_ROOT.fetchFrom(params), APP_NAME.fetchFrom(params) + ".wxs");
+ return new File(CONFIG_ROOT.fetchFrom(params),
+ APP_NAME.fetchFrom(params) + ".wxs");
}
private String getLicenseFile(Map<String, ? super Object> params) {
@@ -1023,24 +1123,30 @@
}
}
- private boolean prepareWiXConfig(Map<String, ? super Object> params) throws IOException {
+ private boolean prepareWiXConfig(
+ Map<String, ? super Object> params) throws IOException {
return prepareMainProjectFile(params) && prepareContentList(params);
}
private final static String MSI_PROJECT_TEMPLATE = "template.wxs";
- private final static String MSI_PROJECT_TEMPLATE_SERVER_JRE = "template.server.jre.wxs";
+ private final static String MSI_PROJECT_TEMPLATE_SERVER_JRE =
+ "template.server.jre.wxs";
private final static String MSI_PROJECT_CONTENT_FILE = "bundle.wxi";
- private File buildMSI(Map<String, ? super Object> params, File outdir) throws IOException {
+ private File buildMSI(Map<String, ? super Object> params, File outdir)
+ throws IOException {
File tmpDir = new File(BUILD_ROOT.fetchFrom(params), "tmp");
- File candleOut = new File(tmpDir, APP_NAME.fetchFrom(params) +".wixobj");
- File msiOut = new File(outdir, INSTALLER_FILE_NAME.fetchFrom(params) + ".msi");
+ File candleOut = new File(
+ tmpDir, APP_NAME.fetchFrom(params) +".wixobj");
+ File msiOut = new File(
+ outdir, INSTALLER_FILE_NAME.fetchFrom(params) + ".msi");
- Log.verbose(MessageFormat.format(I18N.getString("message.preparing-msi-config"), msiOut.getAbsolutePath()));
+ Log.verbose(MessageFormat.format(I18N.getString(
+ "message.preparing-msi-config"), msiOut.getAbsolutePath()));
msiOut.getParentFile().mkdirs();
- //run candle
+ // run candle
ProcessBuilder pb = new ProcessBuilder(
TOOL_CANDLE_EXECUTABLE.fetchFrom(params),
"-nologo",
@@ -1050,7 +1156,8 @@
pb = pb.directory(WIN_APP_IMAGE.fetchFrom(params));
IOUtils.exec(pb, ECHO_MODE.fetchFrom(params));
- Log.verbose(MessageFormat.format(I18N.getString("message.generating-msi"), msiOut.getAbsolutePath()));
+ Log.verbose(MessageFormat.format(I18N.getString(
+ "message.generating-msi"), msiOut.getAbsolutePath()));
boolean enableLicenseUI = (getLicenseFile(params) != null);
boolean enableInstalldirUI = INSTALLDIR_CHOOSER.fetchFrom(params);
@@ -1063,7 +1170,8 @@
}
commandLine.add("-nologo");
commandLine.add("-spdb");
- commandLine.add("-sice:60"); //ignore warnings due to "missing launcguage info" (ICE60)
+ commandLine.add("-sice:60");
+ // ignore warnings due to "missing launcguage info" (ICE60)
commandLine.add(candleOut.getAbsolutePath());
commandLine.add("-ext");
commandLine.add("WixUtilExtension");
@@ -1103,16 +1211,20 @@
if (!existingLicenseIsRTF) {
List<String> oldLicense = Files.readAllLines(f.toPath());
- try (Writer w = Files.newBufferedWriter(f.toPath(), Charset.forName("Windows-1252"))) {
- w.write("{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}}\n" +
- "\\viewkind4\\uc1\\pard\\sa200\\sl276\\slmult1\\lang9\\fs20 ");
+ try (Writer w = Files.newBufferedWriter(
+ f.toPath(), Charset.forName("Windows-1252"))) {
+ w.write("{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033"
+ + "{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}}\n"
+ + "\\viewkind4\\uc1\\pard\\sa200\\sl276"
+ + "\\slmult1\\lang9\\fs20 ");
oldLicense.forEach(l -> {
try {
for (char c : l.toCharArray()) {
- //0x00 <= ch < 0x20 Escaped (\'hh)
- //0x20 <= ch < 0x80 Raw(non - escaped) character
- //0x80 <= ch <= 0xFF Escaped(\ 'hh)
- //0x5C, 0x7B, 0x7D (special RTF characters\,{,})Escaped(\'hh)
+ // 0x00 <= ch < 0x20 Escaped (\'hh)
+ // 0x20 <= ch < 0x80 Raw(non - escaped) char
+ // 0x80 <= ch <= 0xFF Escaped(\ 'hh)
+ // 0x5C, 0x7B, 0x7D (special RTF characters
+ // \,{,})Escaped(\'hh)
// ch > 0xff Escaped (\\ud###?)
if (c < 0x10) {
w.write("\\'0");
@@ -1121,12 +1233,12 @@
w.write("\\ud");
w.write(Integer.toString(c));
// \\uc1 is in the header and in effect
- // so we trail with a replacement character if
+ // so we trail with a replacement char if
// the font lacks that character - '?'
w.write("?");
- } else if ((c < 0x20)
- || (c >= 0x80)
- || (c == 0x5C) || (c == 0x7B) || (c == 0x7D)) {
+ } else if ((c < 0x20) || (c >= 0x80) ||
+ (c == 0x5C) || (c == 0x7B) ||
+ (c == 0x7D)) {
w.write("\\'");
w.write(Integer.toHexString(c));
} else {
--- a/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WindowsBundlerParam.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WindowsBundlerParam.java Mon Aug 27 16:01:38 2018 -0400
@@ -42,14 +42,20 @@
public class WindowsBundlerParam<T> extends StandardBundlerParam<T> {
- private static final ResourceBundle I18N =
- ResourceBundle.getBundle("jdk.packager.internal.resources.windows.WindowsBundlerParam");
+ private static final ResourceBundle I18N = ResourceBundle.getBundle(
+ "jdk.packager.internal.resources.windows.WindowsBundlerParam");
- public WindowsBundlerParam(String name, String description, String id, Class<T> valueType, Function<Map<String, ? super Object>, T> defaultValueFunction, BiFunction<String, Map<String, ? super Object>, T> stringConverter) {
- super(name, description, id, valueType, defaultValueFunction, stringConverter);
+ public WindowsBundlerParam(String name, String description, String id,
+ Class<T> valueType,
+ Function<Map<String, ? super Object>, T> defaultValueFunction,
+ BiFunction<String,
+ Map<String, ? super Object>, T> stringConverter) {
+ super(name, description, id, valueType,
+ defaultValueFunction, stringConverter);
}
- public static final BundlerParamInfo<String> INSTALLER_FILE_NAME = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<String> INSTALLER_FILE_NAME =
+ new StandardBundlerParam<> (
I18N.getString("param.installer-name.name"),
I18N.getString("param.installer-name.description"),
"win.installerName",
@@ -67,7 +73,8 @@
},
(s, p) -> s);
- public static final BundlerParamInfo<String> APP_REGISTRY_NAME = new StandardBundlerParam<> (
+ public static final BundlerParamInfo<String> APP_REGISTRY_NAME =
+ new StandardBundlerParam<> (
I18N.getString("param.registry-name.name"),
I18N.getString("param.registry-name.description"),
Arguments.CLIOptions.WIN_REGISTRY_NAME.getId(),
@@ -110,14 +117,18 @@
I18N.getString("param.runtime-64-bit.description"),
"win.64BitJreRuntime",
Boolean.class,
- params -> {WinAppBundler.extractFlagsFromRuntime(params); return "64".equals(params.get(".runtime.bit-arch"));},
+ params -> {
+ WinAppBundler.extractFlagsFromRuntime(params);
+ return "64".equals(params.get(".runtime.bit-arch"));
+ },
(s, p) -> Boolean.valueOf(s)
);
- //Subsetting of JRE is restricted.
- //JRE README defines what is allowed to strip:
- // http://www.oracle.com/technetwork/java/javase/jre-8-readme-2095710.html
- public static final BundlerParamInfo<JreUtils.Rule[]> WIN_JRE_RULES = new StandardBundlerParam<>(
+ // Subsetting of JRE is restricted.
+ // JRE README defines what is allowed to strip:
+ // http://www.oracle.com/technetwork/java/javase/jre-8-readme-2095710.html
+ public static final BundlerParamInfo<JreUtils.Rule[]> WIN_JRE_RULES =
+ new StandardBundlerParam<>(
"",
"",
".win.runtime.rules",
@@ -131,42 +142,46 @@
JreUtils.Rule.suffixNeg("eula.dll"),
JreUtils.Rule.substrNeg("javacpl"),
JreUtils.Rule.suffixNeg("wsdetect.dll"),
- JreUtils.Rule.substrNeg("eployjava1.dll"), //NP and IE versions
+ JreUtils.Rule.substrNeg("eployjava1.dll"),
+ // NP and IE versions
JreUtils.Rule.substrNeg("bin\\jp2"),
JreUtils.Rule.substrNeg("bin\\jpi"),
- //Rule.suffixNeg("lib\\ext"), //need some of jars there for https to work
+ // Rule.suffixNeg("lib\\ext"),
+ // need some of jars there for https to work
JreUtils.Rule.suffixNeg("ssv.dll"),
JreUtils.Rule.substrNeg("npjpi"),
JreUtils.Rule.substrNeg("npoji"),
JreUtils.Rule.suffixNeg(".exe"),
- //keep core deploy files as JavaFX APIs use them
- //Rule.suffixNeg("deploy.dll"),
+ // keep core deploy files as JavaFX APIs use them
+ // Rule.suffixNeg("deploy.dll"),
JreUtils.Rule.suffixNeg("deploy.jar"),
- //Rule.suffixNeg("javaws.jar"),
- //Rule.suffixNeg("plugin.jar"),
+ // Rule.suffixNeg("javaws.jar"),
+ // Rule.suffixNeg("plugin.jar"),
JreUtils.Rule.suffix(".jar")
},
(s, p) -> null
);
- public static final BundlerParamInfo<RelativeFileSet> WIN_RUNTIME = new StandardBundlerParam<>(
+ public static final BundlerParamInfo<RelativeFileSet> WIN_RUNTIME =
+ new StandardBundlerParam<>(
I18N.getString("param.runtime.name"),
I18N.getString("param.runtime.description"),
BundleParams.PARAM_RUNTIME,
RelativeFileSet.class,
- params -> extractJreAsRelativeFileSet(System.getProperty("java.home"),
+ params -> extractJreAsRelativeFileSet(
+ System.getProperty("java.home"),
WIN_JRE_RULES.fetchFrom(params)),
(s, p) -> extractJreAsRelativeFileSet(s,
WIN_JRE_RULES.fetchFrom(p))
);
- public static final BundlerParamInfo<Boolean> INSTALLDIR_CHOOSER = new StandardBundlerParam<> (
- I18N.getString("param.installdir-chooser.name"),
- I18N.getString("param.installdir-chooser.description"),
- Arguments.CLIOptions.WIN_DIR_CHOOSER.getId(),
- Boolean.class,
- params -> Boolean.FALSE,
- (s, p) -> Boolean.valueOf(s)
+ public static final BundlerParamInfo<Boolean> INSTALLDIR_CHOOSER =
+ new StandardBundlerParam<> (
+ I18N.getString("param.installdir-chooser.name"),
+ I18N.getString("param.installdir-chooser.description"),
+ Arguments.CLIOptions.WIN_DIR_CHOOSER.getId(),
+ Boolean.class,
+ params -> Boolean.FALSE,
+ (s, p) -> Boolean.valueOf(s)
);
-
}
--- a/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WindowsRegistry.java Thu Aug 23 11:09:16 2018 -0400
+++ b/src/jdk.packager/windows/classes/jdk/packager/internal/windows/WindowsRegistry.java Mon Aug 27 16:01:38 2018 -0400
@@ -42,11 +42,13 @@
/**
* Reads the registry value for DisableRealtimeMonitoring.
- * @return true if DisableRealtimeMonitoring is set to 0x1, false otherwise.
+ * @return true if DisableRealtimeMonitoring is set to 0x1,
+ * false otherwise.
*/
public static final boolean readDisableRealtimeMonitoring() {
boolean result = false;
- final String key = "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows Defender\\Real-Time Protection";
+ final String key =
+ "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows Defender\\Real-Time Protection";
final String subkey = "DisableRealtimeMonitoring";
String value = readRegistry(key, subkey);
@@ -129,7 +131,8 @@
ProcessBuilder security = new ProcessBuilder(buildOptions);
exec(security, false, false, ps);
BufferedReader bfReader = new BufferedReader(
- new InputStreamReader(new ByteArrayInputStream(baos.toByteArray())));
+ new InputStreamReader(
+ new ByteArrayInputStream(baos.toByteArray())));
String line = null;
while((line = bfReader.readLine()) != null){