1 /*
   2  * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.tools.packager;
  27 
  28 import com.oracle.tools.packager.*;
  29 import com.oracle.tools.packager.ConfigException;
  30 import com.oracle.tools.packager.UnsupportedPlatformException;
  31 import com.sun.javafx.tools.packager.bundlers.Bundler.BundleType;
  32 import com.oracle.tools.packager.Log;
  33 
  34 import java.io.File;
  35 import java.io.FileInputStream;
  36 import java.io.IOException;
  37 import java.text.MessageFormat;
  38 import java.util.*;
  39 import java.util.stream.Stream;
  40 import java.nio.file.Files;
  41 import java.nio.file.Path;
  42 
  43 import jdk.packager.internal.JLinkBundlerHelper;
  44 
  45 
  46 public class Main {
  47 
  48     private static final ResourceBundle bundle =
  49             ResourceBundle.getBundle("com/sun/javafx/tools/packager/Bundle");
  50 
  51     private static final String version = bundle.getString("MSG_Version")
  52             + " " + PackagerLib.JAVAFX_VERSION + "\n";
  53     private static final String help = bundle.getString("MSG_Help_1")
  54                                         + bundle.getString("MSG_Help_2")
  55                                         + MessageFormat.format(bundle.getString("MSG_Help_3"), File.pathSeparator)
  56                                         + bundle.getString("MSG_Help_4")
  57                                         + bundle.getString("MSG_Help_5")
  58                                         + bundle.getString("MSG_Help_6")
  59                                         + bundle.getString("MSG_Help_7");
  60 
  61     private static String nextArg(String args[], int i) {
  62         return (i == args.length - 1) ? "" : args[i + 1];
  63     }
  64 
  65     private static boolean verbose = false;
  66     private static boolean packageAsJar = false;
  67     private static boolean genJNLP = false;
  68     private static boolean genPackages = false;
  69     private static boolean css2Bin = false;
  70     private static boolean signJar = false;
  71     private static boolean makeAll = false;
  72 
  73     private static void addResources(CommonParams commonParams,
  74                                      String srcdir, String srcfiles) {
  75         if (srcdir == null || "".equals(srcdir)) {
  76             return;
  77         }
  78 
  79         File baseDir = new File(srcdir);
  80 
  81         if (!baseDir.isDirectory()) {
  82             Log.info("Unable to add resources: \"-srcdir\" is not a directory.");
  83             return;
  84         }
  85 
  86         List<String> fileNames;
  87         if (srcfiles != null) {
  88             fileNames = Arrays.asList(srcfiles.split(File.pathSeparator));
  89         } else {
  90             // "-srcfiles" is omitted, all files in srcdir (which
  91             // is a mandatory argument in this case) will be packaged.
  92             fileNames = new ArrayList<>();
  93             try (Stream<Path> files = Files.list(baseDir.toPath())) {
  94                 files.forEach(file -> fileNames.add(file.getFileName().toString()));
  95             } catch (IOException e) {
  96                 Log.info("Unable to add resources: " + e.getMessage());
  97             }
  98         }
  99 
 100         fileNames.forEach(file -> commonParams.addResource(baseDir, file));
 101     }
 102 
 103     private static void addArgument(DeployParams deployParams, String argument) {
 104         if (deployParams.arguments != null) {
 105             deployParams.arguments.add(argument);
 106         } else {
 107             List<String> list = new LinkedList<>();
 108             list.add(argument);
 109             deployParams.setArguments(list);
 110         }
 111     }
 112 
 113     private static void addArgument(CreateJarParams deployParams, String argument) {
 114         if (deployParams.arguments != null) {
 115             deployParams.arguments.add(argument);
 116         } else {
 117             List<String> list = new LinkedList<>();
 118             list.add(argument);
 119             deployParams.setArguments(list);
 120         }
 121     }
 122 
 123     private static Map<String, String> createAttrMap(String arg) {
 124         Map<String, String> map = new HashMap<>();
 125         if (arg == null || "".equals(arg)) {
 126             return null;
 127         }
 128         String[] pairsArray = arg.split(",");
 129         for (String pair: pairsArray) {
 130             String[] attr = pair.split("=");
 131             map.put(attr[0].trim(), attr[1].trim());
 132         }
 133         return map;
 134     }
 135 
 136     private static List<Param> parseParams(String filename) throws IOException {
 137         File paramFile = new File(filename);
 138         Properties properties = new Properties();
 139         FileInputStream in = new FileInputStream(paramFile);
 140         properties.load(in);
 141         in.close();
 142 
 143         List<Param> parameters = new ArrayList<>(properties.size());
 144 
 145         for (Map.Entry en : properties.entrySet()) {
 146             Param p = new Param();
 147             p.setName((String)en.getKey());
 148             p.setValue((String)en.getValue());
 149             parameters.add(p);
 150         }
 151         return parameters;
 152     }
 153 
 154     private static List<HtmlParam> parseHtmlParams(String filename) throws IOException {
 155         File paramFile = new File(filename);
 156         Properties properties = new Properties();
 157         FileInputStream in = new FileInputStream(paramFile);
 158         properties.load(in);
 159         in.close();
 160 
 161         List<HtmlParam> parameters = new ArrayList<>(properties.size());
 162 
 163         for (Map.Entry en : properties.entrySet()) {
 164             HtmlParam p = new HtmlParam();
 165             p.setName((String)en.getKey());
 166             p.setValue((String)en.getValue());
 167             parameters.add(p);
 168         }
 169         return parameters;
 170     }
 171 
 172     private static List<JSCallback> parseCallbacks(String param) {
 173         String[] callbacks = param.split(",");
 174         List<JSCallback> list = new ArrayList<>(callbacks.length);
 175 
 176         for (String cb: callbacks) {
 177             String[] nameCmd = cb.split(":");
 178             if (nameCmd.length == 2) {
 179                 list.add(new JSCallback(nameCmd[0], nameCmd[1]));
 180             }
 181         }
 182         return list;
 183     }
 184 
 185 
 186     @SuppressWarnings("deprecation")
 187     public static void main(String... args) throws Exception {
 188         BundleType bundleType = BundleType.NONE;
 189 
 190         if (args.length == 0 || args.length == 1 && args[0].equals("-help")) {
 191             System.out.println(help);
 192         } else if (args.length == 1 && args[0].equals("-version")) {
 193             System.out.println(version);
 194         } else {
 195             PackagerLib packager = new PackagerLib();
 196             CreateJarParams createJarParams = new CreateJarParams();
 197             DeployParams deployParams = new DeployParams();
 198             CreateBSSParams createBssParams = new CreateBSSParams();
 199             SignJarParams signJarParams = new SignJarParams();
 200             MakeAllParams makeAllParams = new MakeAllParams();
 201             String srcdir = null;
 202             String srcfiles = null;
 203 
 204             try {
 205                 if (args[0].equalsIgnoreCase("-createjar")) {
 206                     for (int i = 1; i < args.length; i++) {
 207                         String arg = args[i];
 208                         if (arg.equalsIgnoreCase("-appclass")) {
 209                             createJarParams.setApplicationClass(nextArg(args, i++));
 210                         } else if (arg.equalsIgnoreCase("-preloader")) {
 211                             createJarParams.setPreloader(nextArg(args, i++));
 212                         } else if (arg.equalsIgnoreCase("-classpath")) {
 213                             createJarParams.setClasspath(nextArg(args, i++));
 214                         } else if (arg.equalsIgnoreCase("-manifestAttrs")) {
 215                             createJarParams.setManifestAttrs(createAttrMap(nextArg(args, i++)));
 216                         } else if (arg.equalsIgnoreCase("-noembedlauncher")) {
 217                             System.err.println("-noembedlauncher is deprecated");
 218                         } else if (arg.equalsIgnoreCase("-nocss2bin")) {
 219                             createJarParams.setCss2bin(false);
 220                         } else if (arg.equalsIgnoreCase("-runtimeVersion")) {
 221                             createJarParams.setFxVersion(nextArg(args, i++));
 222                             System.err.println("-runtimeVersion is deprecated");
 223                         } else if (arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
 224                             createJarParams.setVerbose(true);
 225                             verbose = true;
 226                         } else if (arg.equalsIgnoreCase("-outdir")) {
 227                             createJarParams.setOutdir(new File(nextArg(args, i++)));
 228                         } else if (arg.equalsIgnoreCase("-outfile")) {
 229                             createJarParams.setOutfile(nextArg(args, i++));
 230                         } else if (arg.equalsIgnoreCase("-" + StandardBundlerParam.SOURCE_DIR.getID())) {
 231                             srcdir = nextArg(args, i++);
 232                         } else if (arg.equalsIgnoreCase("-srcfiles")) {
 233                             srcfiles = nextArg(args, i++);
 234                         } else if (arg.equalsIgnoreCase("-argument")) {
 235                             addArgument(createJarParams, nextArg(args, i++));
 236                         }  else if (arg.equalsIgnoreCase("-paramFile")) {
 237                             createJarParams.setParams(parseParams(nextArg(args, i++)));
 238                         } else {
 239                             throw new PackagerException("ERR_UnknownArgument", arg);
 240                         }
 241                     }
 242 
 243                     addResources(createJarParams, srcdir, srcfiles);
 244                     packageAsJar = true;
 245                 } else if (args[0].equalsIgnoreCase("-deploy")) {
 246                     File templateInFile = null;
 247                     File templateOutFile = null;
 248                     deployParams.setBundleType(BundleType.JNLP);
 249                     deployParams.setTargetFormat("jnlp");
 250 
 251                     //can only set it to true with command line, reset default
 252                     deployParams.setEmbedJNLP(false);
 253 
 254                     for (int i = 1; i < args.length; i++) {
 255                         String arg = args[i];
 256                         if (arg.startsWith("-B")) {
 257                             String key;
 258                             String value;
 259 
 260                             int keyStart = 2;
 261                             int equals = arg.indexOf("=");
 262                             int len = arg.length();
 263                             if (equals < keyStart) {
 264                                 if (keyStart < len) {
 265                                     key = arg.substring(keyStart, len);
 266                                     value = Boolean.TRUE.toString();
 267                                 } else {
 268                                     continue;
 269                                 }
 270                             } else if (keyStart < equals) {
 271                                 key = arg.substring(keyStart, equals);
 272                                 value = arg.substring(equals+1, len);
 273                             } else {
 274                                 continue;
 275                             }
 276                             deployParams.addBundleArgument(key, value);
 277                         } else if (arg.equalsIgnoreCase("-title")) {
 278                             deployParams.setTitle(nextArg(args, i++));
 279                         } else if (arg.equalsIgnoreCase("-vendor")) {
 280                             deployParams.setVendor(nextArg(args, i++));
 281                         } else if (arg.equalsIgnoreCase("-native")) {
 282                             bundleType = BundleType.NATIVE;
 283                             String format = null; //null means ANY
 284                             if (i+1 < args.length && !args[i+1].startsWith("-")) {
 285                                 String v = args[++i];
 286                                 com.sun.javafx.tools.packager.bundlers.Bundler.Bundle bundle =
 287                                         com.sun.javafx.tools.packager.bundlers.Bundler.stringToBundle(v);
 288                                 bundleType = bundle.type;
 289                                 format = bundle.format;
 290                             }
 291                             deployParams.setBundleType(bundleType);
 292                             deployParams.setTargetFormat(format);
 293                         } else if (arg.equalsIgnoreCase("-description")) {
 294                             deployParams.setDescription(nextArg(args, i++));
 295                         } else if(arg.equalsIgnoreCase("-appclass")) {
 296                             deployParams.setApplicationClass(nextArg(args, i++));
 297                         } else if(arg.equalsIgnoreCase("-daemon")) {
 298                             deployParams.setServiceHint(true);
 299                         } else if(arg.equalsIgnoreCase("-singleton")) {
 300                             deployParams.setSingleton(true);
 301                         } else if(arg.equalsIgnoreCase("-installdirChooser")) {
 302                             deployParams.setInstalldirChooser(true);
 303                         } else if (arg.equalsIgnoreCase("-preloader")) {
 304                             deployParams.setPreloader(nextArg(args, i++));
 305                         } else if (arg.equalsIgnoreCase("-paramFile")) {
 306                             deployParams.setParams(parseParams(nextArg(args, i++)));
 307                         } else if (arg.equalsIgnoreCase("-htmlParamFile")) {
 308                             deployParams.setHtmlParams(parseHtmlParams(nextArg(args, i++)));
 309                         } else if (arg.equalsIgnoreCase("-width")) {
 310                             deployParams.setWidth(Integer.parseInt(nextArg(args, i++)));
 311                         } else if (arg.equalsIgnoreCase("-height")) {
 312                             deployParams.setHeight(Integer.parseInt(nextArg(args, i++)));
 313                         } else if (arg.equalsIgnoreCase("-name")) {
 314                             deployParams.setAppName(nextArg(args, i++));
 315                         } else if (arg.equalsIgnoreCase("-embedJNLP")) {
 316                             deployParams.setEmbedJNLP(true);
 317                         } else if (arg.equalsIgnoreCase("-embedCertificates")) {
 318                             System.err.println("-embedCertificates is deprecated");
 319                         } else if (arg.equalsIgnoreCase("-allpermissions")) {
 320                             deployParams.setAllPermissions(true);
 321                         } else if (arg.equalsIgnoreCase("-updatemode")) {
 322                             deployParams.setUpdateMode(nextArg(args, i++));
 323                         } else if (arg.equalsIgnoreCase("-isExtension")) {
 324                             deployParams.setExtension(true);
 325                         } else if (arg.equalsIgnoreCase("-callbacks")) {
 326                             deployParams.setJSCallbacks(parseCallbacks(nextArg(args, i++)));
 327                         } else if (arg.equalsIgnoreCase("-templateInFilename")) {
 328                             templateInFile = new File(nextArg(args, i++));
 329                         } else if (arg.equalsIgnoreCase("-templateOutFilename")) {
 330                             templateOutFile = new File(nextArg(args, i++));
 331                         } else if (arg.equalsIgnoreCase("-appId") || arg.equalsIgnoreCase("-templateId")) {
 332                             String appIdArg = nextArg(args, i++);
 333                             deployParams.setAppId(appIdArg);
 334                             deployParams.setId(appIdArg);
 335                         } else if (arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
 336                             deployParams.setVerbose(true);
 337                             verbose = true;
 338                         } else if (arg.equalsIgnoreCase("-includedt")) {
 339                             deployParams.setIncludeDT(true);
 340                         } else if (arg.equalsIgnoreCase("-outdir")) {
 341                             deployParams.setOutdir(new File(nextArg(args, i++)));
 342                         } else if (arg.equalsIgnoreCase("-outfile")) {
 343                             deployParams.setOutfile(nextArg(args, i++));
 344                         } else if (arg.equalsIgnoreCase("-" + StandardBundlerParam.SOURCE_DIR.getID())) {
 345                             srcdir = nextArg(args, i++);
 346                             deployParams.srcdir = srcdir;
 347                         } else if (arg.equalsIgnoreCase("-srcfiles")) {
 348                             srcfiles = nextArg(args, i++);
 349                         } else if (arg.equalsIgnoreCase("-argument")) {
 350                             addArgument(deployParams, nextArg(args, i++));
 351                         } else if (arg.equalsIgnoreCase("-nosign")) {
 352                             deployParams.setSignBundle(false);
 353                         } else if (arg.equals(ADD_MODULES)) {
 354                             deployParams.addAddModule(nextArg(args, i++));
 355                         } else if (arg.startsWith(ADD_MODULES + "=")) {
 356                             deployParams.addAddModule(arg.replace(ADD_MODULES + "=", ""));
 357                         } else if (arg.equals(LIMIT_MODULES)) {
 358                             deployParams.addLimitModule(nextArg(args, i++));
 359                         } else if (arg.startsWith(LIMIT_MODULES + "=")) {
 360                             deployParams.addLimitModule(arg.replace(LIMIT_MODULES + "=", ""));
 361                         } else if (arg.equals(STRIP_NATIVE_COMMANDS)) {
 362                             deployParams.setStripNativeCommands(Boolean.valueOf(nextArg(args, i++)));
 363                         } else if (arg.equals(STRIP_NATIVE_COMMANDS + "=")) {
 364                             deployParams.setStripNativeCommands(Boolean.valueOf(arg.replace(STRIP_NATIVE_COMMANDS + "=", "")));
 365                         } else if (arg.equals(DETECT_MODULES)) {
 366                             deployParams.setDetectModules(true);
 367                         } else if (arg.equals(MODULE_PATH) || arg.equals(P)) {
 368                             deployParams.modulePath = nextArg(args, i++);
 369                         } else if (arg.equals(MODULE_PATH + "=")) {
 370                             deployParams.modulePath = arg.replace(MODULE_PATH + "=", "");
 371                         } else if (arg.equals(MODULE) || arg.equals(M)) {
 372                             deployParams.setModule(nextArg(args, i++));
 373                         } else if (arg.equals(MODULE + "=")) {
 374                             deployParams.setModule(arg.replace(MODULE + "=", ""));
 375                         } else if (arg.startsWith(J_XDEBUG)) {
 376                             deployParams.setDebug(arg.replace(J_XDEBUG, ""));
 377                         } else {
 378                             throw new PackagerException("ERR_UnknownArgument", arg);
 379                         }
 380                     }
 381                     if (templateInFile != null) {
 382                         deployParams.addTemplate(templateInFile, templateOutFile);
 383                     }
 384 
 385                     if (deployParams.validateForJNLP()) {
 386                         genJNLP = true;
 387                     }
 388 
 389                     if (deployParams.validateForBundle()) {
 390                         genPackages = true;
 391                     }
 392 
 393                     addResources(deployParams, srcdir, srcfiles);
 394                 } else if (args[0].equalsIgnoreCase("-createbss")) {
 395                     for (int i = 1; i < args.length; i++) {
 396                         String arg = args[i];
 397                         if (arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
 398                             createBssParams.setVerbose(true);
 399                             verbose = true;
 400                         } else if (arg.equalsIgnoreCase("-outdir")) {
 401                             createBssParams.setOutdir(new File(nextArg(args, i++)));
 402                         } else if (arg.equalsIgnoreCase("-srcdir")) {
 403                             srcdir = nextArg(args, i++);
 404                         } else if (arg.equalsIgnoreCase("-srcfiles")) {
 405                             srcfiles = nextArg(args, i++);
 406                         } else {
 407                             throw new PackagerException("ERR_UnknownArgument", arg);
 408                         }
 409                     }
 410 
 411                     addResources(createBssParams, srcdir, srcfiles);
 412                     css2Bin = true;
 413                 } else if (args[0].equalsIgnoreCase("-signJar")) {
 414                     Log.info("Warning: -signJar has been deprecated and will be removed in a future release.");
 415                     for (int i = 1; i < args.length; i++) {
 416                         String arg = args[i];
 417                         if (arg.equalsIgnoreCase("-keyStore")) {
 418                             signJarParams.setKeyStore(new File(nextArg(args, i++)));
 419                         } else if(arg.equalsIgnoreCase("-alias")) {
 420                             signJarParams.setAlias(nextArg(args, i++));
 421                         } else if(arg.equalsIgnoreCase("-storePass")) {
 422                             signJarParams.setStorePass(nextArg(args, i++));
 423                         } else if(arg.equalsIgnoreCase("-keyPass")) {
 424                             signJarParams.setKeyPass(nextArg(args, i++));
 425                         } else if(arg.equalsIgnoreCase("-storeType")) {
 426                             signJarParams.setStoreType(nextArg(args, i++));
 427                         } else if(arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
 428                             signJarParams.setVerbose(true);
 429                             verbose = true;
 430                         } else if (arg.equalsIgnoreCase("-outdir")) {
 431                             signJarParams.setOutdir(new File(nextArg(args, i++)));
 432                         } else if (arg.equalsIgnoreCase("-srcdir")) {
 433                             srcdir = nextArg(args, i++);
 434                         } else if (arg.equalsIgnoreCase("-srcfiles")) {
 435                             srcfiles = nextArg(args, i++);
 436                         } else {
 437                             throw new PackagerException("ERR_UnknownArgument", arg);
 438                         }
 439                     }
 440 
 441                     addResources(signJarParams, srcdir, srcfiles);
 442                     signJar = true;
 443                 } else if (args[0].equalsIgnoreCase("-makeall")) {
 444                     System.err.println("-makeall is deprecated");
 445                     for (int i = 1; i < args.length; i++) {
 446                         String arg = args[i];
 447                         if (arg.equalsIgnoreCase("-appclass")) {
 448                             makeAllParams.setAppClass(nextArg(args, i++));
 449                         } else if (arg.equalsIgnoreCase("-preloader")) {
 450                             makeAllParams.setPreloader(nextArg(args, i++));
 451                         } else if (arg.equalsIgnoreCase("-classpath")) {
 452                             makeAllParams.setClasspath(nextArg(args, i++));
 453                         } else if (arg.equalsIgnoreCase("-name")) {
 454                             makeAllParams.setAppName(nextArg(args, i++));
 455                         } else if(arg.equalsIgnoreCase("-width")) {
 456                             makeAllParams.setWidth(Integer.parseInt(nextArg(args, i++)));
 457                         } else if(arg.equalsIgnoreCase("-height")) {
 458                             makeAllParams.setHeight(Integer.parseInt(nextArg(args, i++)));
 459                         } else if(arg.equalsIgnoreCase("-v")) {
 460                             makeAllParams.setVerbose(true);
 461                         } else {
 462                             throw new PackagerException("ERR_UnknownArgument", arg);
 463                         }
 464                     }
 465                     makeAll = true;
 466                 } else if (args[0].equalsIgnoreCase("-help")) {
 467                     showBundlerHelp(args[1], args.length > 2 && "-verbose".equals(args[2]));
 468                 } else {
 469                     System.err.println(MessageFormat.format(
 470                                         bundle.getString("ERR_UnknownCommand"),
 471                                         args[0]));
 472                     System.exit(-1);
 473                 }
 474 
 475                 //set default logger
 476                 if (verbose) {
 477                     com.oracle.tools.packager.Log.setLogger(new com.oracle.tools.packager.Log.Logger(true));
 478                 } else {
 479                     com.oracle.tools.packager.Log.setLogger(new com.oracle.tools.packager.Log.Logger(false));
 480                 }
 481 
 482                 if (css2Bin) {
 483                     createBssParams.validate();
 484                     packager.generateBSS(createBssParams);
 485                 }
 486                 if (packageAsJar) {
 487                     createJarParams.validate();
 488                     packager.packageAsJar(createJarParams);
 489                 }
 490                 if (genJNLP) {
 491                     deployParams.setBundleType(BundleType.JNLP);
 492                     deployParams.validate();
 493                     packager.generateDeploymentPackages(deployParams);
 494                 }
 495                 if (genPackages) {
 496                     deployParams.setBundleType(bundleType);
 497                     deployParams.validate();
 498                     packager.generateDeploymentPackages(deployParams);
 499                 }
 500                 if (signJar) {
 501                     signJarParams.validate();
 502                     if (signJarParams.storePass == null) {
 503                         char[] passwd = System.console().readPassword(bundle.getString("MSG_EnterKeystorePassword"));
 504                         if (passwd == null) {
 505                             signJarParams.storePass = "";
 506                         } else {
 507                             signJarParams.storePass = new String(passwd);
 508                         }
 509                     }
 510                     if (signJarParams.keyPass == null) {
 511                         char[] passwd = System.console().readPassword(bundle.getString("MSG_EnterKeyPassword"), signJarParams.alias);
 512                         if (passwd == null) {
 513                             signJarParams.keyPass = "";
 514                         } else {
 515                             signJarParams.keyPass = new String(passwd);
 516                         }
 517                     }
 518                     packager.signJar(signJarParams);
 519                 }
 520                 if (makeAll) {
 521                     makeAllParams.validate();
 522                     packager.makeAll(makeAllParams);
 523                 }
 524 
 525             } catch (Exception e) {
 526                 if (verbose) {
 527                     throw e;
 528                 } else {
 529                     System.err.println(e.getMessage());
 530                     if (e.getCause() != null && e.getCause() != e) {
 531                         System.err.println(e.getCause().getMessage());
 532                     }
 533                     System.exit(-1);
 534                 }
 535             }
 536         }
 537     }
 538 
 539     private static final String MODULE = "--" + StandardBundlerParam.MODULE.getID();
 540     private static final String M = "-m";
 541     private static final String MODULE_PATH = "--" + StandardBundlerParam.MODULE_PATH.getID();
 542     private static final String P = "-p";
 543     private static final String ADD_MODULES = "--" + StandardBundlerParam.ADD_MODULES.getID();
 544     private static final String LIMIT_MODULES = "--" + StandardBundlerParam.LIMIT_MODULES.getID();
 545     private static final String STRIP_NATIVE_COMMANDS = "--" + StandardBundlerParam.STRIP_NATIVE_COMMANDS.getID();
 546 
 547     private static final String J_XDEBUG = JLinkBundlerHelper.DEBUG.getID() + ":";
 548     private static final String DETECT_MODULES = "--" + JLinkBundlerHelper.DETECT_MODULES.getID();
 549 
 550     public static void showBundlerHelp(String bundlerName, boolean verbose) {
 551         //TODO I18N
 552         if ("bundlers".equals(bundlerName)) {
 553             // enumerate bundlers
 554             System.out.println("Known Bundlers -- \n");
 555             for (Bundler bundler : Bundlers.createBundlersInstance().getBundlers()) {
 556                 try {
 557                     bundler.validate(new HashMap<>());
 558                 } catch (UnsupportedPlatformException upe) {
 559                     // don't list bundlers this platform cannot run
 560                     continue;
 561                 } catch (ConfigException ignore) {
 562                     // but requiring more than an empty map is perfectly fine.
 563                 //} catch (RuntimeException re) {
 564                 //    re.printStackTrace();
 565                 }
 566 
 567                 if (verbose) {
 568                     System.out.printf(
 569                             "%s - %s - %s\n\t%s\n",
 570                             bundler.getID(),
 571                             bundler.getName(),
 572                             bundler.getBundleType(),
 573                             bundler.getDescription()
 574                     );
 575                 } else {
 576                     System.out.printf(
 577                             "%s - %s - %s\n",
 578                             bundler.getID(),
 579                             bundler.getName(),
 580                             bundler.getBundleType()
 581                     );
 582                 }
 583             }
 584         } else {
 585             // enumerate parameters for a bundler
 586             for (Bundler bundler : Bundlers.createBundlersInstance().getBundlers()) {
 587                 if (bundler.getID().equals(bundlerName)) {
 588                     System.out.printf("Bundler Parameters for %s (%s) --\n", bundler.getName(), bundler.getID());
 589                     for (BundlerParamInfo bpi : bundler.getBundleParameters()) {
 590                         if (bpi.getStringConverter() == null) continue;
 591                         if (verbose) {
 592                             System.out.printf(
 593                                     "%s - %s - %s\n\t%s\n",
 594                                     bpi.getID(),
 595                                     bpi.getName(),
 596                                     bpi.getValueType().getSimpleName(),
 597                                     bpi.getDescription()
 598                             );
 599                         } else {
 600                             System.out.printf(
 601                                     "%s - %s - %s\n",
 602                                     bpi.getID(),
 603                                     bpi.getName(),
 604                                     bpi.getValueType().getSimpleName()
 605                             );
 606                         }
 607                     }
 608                     return;
 609                 }
 610             }
 611             System.out.printf("Sorry, no bundler matching the id %s was found.\n", bundlerName);
 612         }
 613     }
 614 }