1 /*
   2  * Copyright (c) 2011, 2016, 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("-installdirChooser")) {
 300                             deployParams.setInstalldirChooser(true);
 301                         } else if (arg.equalsIgnoreCase("-preloader")) {
 302                             deployParams.setPreloader(nextArg(args, i++));
 303                         } else if (arg.equalsIgnoreCase("-paramFile")) {
 304                             deployParams.setParams(parseParams(nextArg(args, i++)));
 305                         } else if (arg.equalsIgnoreCase("-htmlParamFile")) {
 306                             deployParams.setHtmlParams(parseHtmlParams(nextArg(args, i++)));
 307                         } else if (arg.equalsIgnoreCase("-width")) {
 308                             deployParams.setWidth(Integer.parseInt(nextArg(args, i++)));
 309                         } else if (arg.equalsIgnoreCase("-height")) {
 310                             deployParams.setHeight(Integer.parseInt(nextArg(args, i++)));
 311                         } else if (arg.equalsIgnoreCase("-name")) {
 312                             deployParams.setAppName(nextArg(args, i++));
 313                         } else if (arg.equalsIgnoreCase("-embedJNLP")) {
 314                             deployParams.setEmbedJNLP(true);
 315                         } else if (arg.equalsIgnoreCase("-embedCertificates")) {
 316                             System.err.println("-embedCertificates is deprecated");
 317                         } else if (arg.equalsIgnoreCase("-allpermissions")) {
 318                             deployParams.setAllPermissions(true);
 319                         } else if (arg.equalsIgnoreCase("-updatemode")) {
 320                             deployParams.setUpdateMode(nextArg(args, i++));
 321                         } else if (arg.equalsIgnoreCase("-isExtension")) {
 322                             deployParams.setExtension(true);
 323                         } else if (arg.equalsIgnoreCase("-callbacks")) {
 324                             deployParams.setJSCallbacks(parseCallbacks(nextArg(args, i++)));
 325                         } else if (arg.equalsIgnoreCase("-templateInFilename")) {
 326                             templateInFile = new File(nextArg(args, i++));
 327                         } else if (arg.equalsIgnoreCase("-templateOutFilename")) {
 328                             templateOutFile = new File(nextArg(args, i++));
 329                         } else if (arg.equalsIgnoreCase("-appId") || arg.equalsIgnoreCase("-templateId")) {
 330                             String appIdArg = nextArg(args, i++);
 331                             deployParams.setAppId(appIdArg);
 332                             deployParams.setId(appIdArg);
 333                         } else if (arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
 334                             deployParams.setVerbose(true);
 335                             verbose = true;
 336                         } else if (arg.equalsIgnoreCase("-includedt")) {
 337                             deployParams.setIncludeDT(true);
 338                         } else if (arg.equalsIgnoreCase("-outdir")) {
 339                             deployParams.setOutdir(new File(nextArg(args, i++)));
 340                         } else if (arg.equalsIgnoreCase("-outfile")) {
 341                             deployParams.setOutfile(nextArg(args, i++));
 342                         } else if (arg.equalsIgnoreCase("-" + StandardBundlerParam.SOURCE_DIR.getID())) {
 343                             srcdir = nextArg(args, i++);
 344                             deployParams.srcdir = srcdir;
 345                         } else if (arg.equalsIgnoreCase("-srcfiles")) {
 346                             srcfiles = nextArg(args, i++);
 347                         } else if (arg.equalsIgnoreCase("-argument")) {
 348                             addArgument(deployParams, nextArg(args, i++));
 349                         } else if (arg.equalsIgnoreCase("-nosign")) {
 350                             deployParams.setSignBundle(false);
 351                         } else if (arg.equals(ADD_MODULES)) {
 352                             deployParams.addAddModule(nextArg(args, i++));
 353                         } else if (arg.startsWith(ADD_MODULES + "=")) {
 354                             deployParams.addAddModule(arg.replace(ADD_MODULES + "=", ""));
 355                         } else if (arg.equals(LIMIT_MODULES)) {
 356                             deployParams.addLimitModule(nextArg(args, i++));
 357                         } else if (arg.startsWith(LIMIT_MODULES + "=")) {
 358                             deployParams.addLimitModule(arg.replace(LIMIT_MODULES + "=", ""));
 359                         } else if (arg.equals(STRIP_NATIVE_COMMANDS)) {
 360                             deployParams.setStripNativeCommands(Boolean.valueOf(nextArg(args, i++)));
 361                         } else if (arg.equals(STRIP_NATIVE_COMMANDS + "=")) {
 362                             deployParams.setStripNativeCommands(Boolean.valueOf(arg.replace(STRIP_NATIVE_COMMANDS + "=", "")));
 363                         } else if (arg.equals(DETECT_MODULES)) {
 364                             deployParams.setDetectModules(true);
 365                         } else if (arg.equals(MODULE_PATH) || arg.equals(P)) {
 366                             deployParams.modulePath = nextArg(args, i++);
 367                         } else if (arg.equals(MODULE_PATH + "=")) {
 368                             deployParams.modulePath = arg.replace(MODULE_PATH + "=", "");
 369                         } else if (arg.equals(MODULE) || arg.equals(M)) {
 370                             deployParams.setModule(nextArg(args, i++));
 371                         } else if (arg.equals(MODULE + "=")) {
 372                             deployParams.setModule(arg.replace(MODULE + "=", ""));
 373                         } else if (arg.startsWith(J_XDEBUG)) {
 374                             deployParams.setDebug(arg.replace(J_XDEBUG, ""));
 375                         } else {
 376                             throw new PackagerException("ERR_UnknownArgument", arg);
 377                         }
 378                     }
 379                     if (templateInFile != null) {
 380                         deployParams.addTemplate(templateInFile, templateOutFile);
 381                     }
 382 
 383                     if (deployParams.validateForJNLP()) {
 384                         genJNLP = true;
 385                     }
 386 
 387                     if (deployParams.validateForBundle()) {
 388                         genPackages = true;
 389                     }
 390 
 391                     addResources(deployParams, srcdir, srcfiles);
 392                 } else if (args[0].equalsIgnoreCase("-createbss")) {
 393                     for (int i = 1; i < args.length; i++) {
 394                         String arg = args[i];
 395                         if (arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
 396                             createBssParams.setVerbose(true);
 397                             verbose = true;
 398                         } else if (arg.equalsIgnoreCase("-outdir")) {
 399                             createBssParams.setOutdir(new File(nextArg(args, i++)));
 400                         } else if (arg.equalsIgnoreCase("-srcdir")) {
 401                             srcdir = nextArg(args, i++);
 402                         } else if (arg.equalsIgnoreCase("-srcfiles")) {
 403                             srcfiles = nextArg(args, i++);
 404                         } else {
 405                             throw new PackagerException("ERR_UnknownArgument", arg);
 406                         }
 407                     }
 408 
 409                     addResources(createBssParams, srcdir, srcfiles);
 410                     css2Bin = true;
 411                 } else if (args[0].equalsIgnoreCase("-signJar")) {
 412                     Log.info("Warning: -signJar has been deprecated and will be removed in a future release.");
 413                     for (int i = 1; i < args.length; i++) {
 414                         String arg = args[i];
 415                         if (arg.equalsIgnoreCase("-keyStore")) {
 416                             signJarParams.setKeyStore(new File(nextArg(args, i++)));
 417                         } else if(arg.equalsIgnoreCase("-alias")) {
 418                             signJarParams.setAlias(nextArg(args, i++));
 419                         } else if(arg.equalsIgnoreCase("-storePass")) {
 420                             signJarParams.setStorePass(nextArg(args, i++));
 421                         } else if(arg.equalsIgnoreCase("-keyPass")) {
 422                             signJarParams.setKeyPass(nextArg(args, i++));
 423                         } else if(arg.equalsIgnoreCase("-storeType")) {
 424                             signJarParams.setStoreType(nextArg(args, i++));
 425                         } else if(arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
 426                             signJarParams.setVerbose(true);
 427                             verbose = true;
 428                         } else if (arg.equalsIgnoreCase("-outdir")) {
 429                             signJarParams.setOutdir(new File(nextArg(args, i++)));
 430                         } else if (arg.equalsIgnoreCase("-srcdir")) {
 431                             srcdir = nextArg(args, i++);
 432                         } else if (arg.equalsIgnoreCase("-srcfiles")) {
 433                             srcfiles = nextArg(args, i++);
 434                         } else {
 435                             throw new PackagerException("ERR_UnknownArgument", arg);
 436                         }
 437                     }
 438 
 439                     addResources(signJarParams, srcdir, srcfiles);
 440                     signJar = true;
 441                 } else if (args[0].equalsIgnoreCase("-makeall")) {
 442                     System.err.println("-makeall is deprecated");
 443                     for (int i = 1; i < args.length; i++) {
 444                         String arg = args[i];
 445                         if (arg.equalsIgnoreCase("-appclass")) {
 446                             makeAllParams.setAppClass(nextArg(args, i++));
 447                         } else if (arg.equalsIgnoreCase("-preloader")) {
 448                             makeAllParams.setPreloader(nextArg(args, i++));
 449                         } else if (arg.equalsIgnoreCase("-classpath")) {
 450                             makeAllParams.setClasspath(nextArg(args, i++));
 451                         } else if (arg.equalsIgnoreCase("-name")) {
 452                             makeAllParams.setAppName(nextArg(args, i++));
 453                         } else if(arg.equalsIgnoreCase("-width")) {
 454                             makeAllParams.setWidth(Integer.parseInt(nextArg(args, i++)));
 455                         } else if(arg.equalsIgnoreCase("-height")) {
 456                             makeAllParams.setHeight(Integer.parseInt(nextArg(args, i++)));
 457                         } else if(arg.equalsIgnoreCase("-v")) {
 458                             makeAllParams.setVerbose(true);
 459                         } else {
 460                             throw new PackagerException("ERR_UnknownArgument", arg);
 461                         }
 462                     }
 463                     makeAll = true;
 464                 } else if (args[0].equalsIgnoreCase("-help")) {
 465                     showBundlerHelp(args[1], args.length > 2 && "-verbose".equals(args[2]));
 466                 } else {
 467                     System.err.println(MessageFormat.format(
 468                                         bundle.getString("ERR_UnknownCommand"),
 469                                         args[0]));
 470                     System.exit(-1);
 471                 }
 472 
 473                 //set default logger
 474                 if (verbose) {
 475                     com.oracle.tools.packager.Log.setLogger(new com.oracle.tools.packager.Log.Logger(true));
 476                 } else {
 477                     com.oracle.tools.packager.Log.setLogger(new com.oracle.tools.packager.Log.Logger(false));
 478                 }
 479 
 480                 if (css2Bin) {
 481                     createBssParams.validate();
 482                     packager.generateBSS(createBssParams);
 483                 }
 484                 if (packageAsJar) {
 485                     createJarParams.validate();
 486                     packager.packageAsJar(createJarParams);
 487                 }
 488                 if (genJNLP) {
 489                     deployParams.setBundleType(BundleType.JNLP);
 490                     deployParams.validate();
 491                     packager.generateDeploymentPackages(deployParams);
 492                 }
 493                 if (genPackages) {
 494                     deployParams.setBundleType(bundleType);
 495                     deployParams.validate();
 496                     packager.generateDeploymentPackages(deployParams);
 497                 }
 498                 if (signJar) {
 499                     signJarParams.validate();
 500                     if (signJarParams.storePass == null) {
 501                         char[] passwd = System.console().readPassword(bundle.getString("MSG_EnterKeystorePassword"));
 502                         if (passwd == null) {
 503                             signJarParams.storePass = "";
 504                         } else {
 505                             signJarParams.storePass = new String(passwd);
 506                         }
 507                     }
 508                     if (signJarParams.keyPass == null) {
 509                         char[] passwd = System.console().readPassword(bundle.getString("MSG_EnterKeyPassword"), signJarParams.alias);
 510                         if (passwd == null) {
 511                             signJarParams.keyPass = "";
 512                         } else {
 513                             signJarParams.keyPass = new String(passwd);
 514                         }
 515                     }
 516                     packager.signJar(signJarParams);
 517                 }
 518                 if (makeAll) {
 519                     makeAllParams.validate();
 520                     packager.makeAll(makeAllParams);
 521                 }
 522 
 523             } catch (Exception e) {
 524                 if (verbose) {
 525                     throw e;
 526                 } else {
 527                     System.err.println(e.getMessage());
 528                     if (e.getCause() != null && e.getCause() != e) {
 529                         System.err.println(e.getCause().getMessage());
 530                     }
 531                     System.exit(-1);
 532                 }
 533             }
 534         }
 535     }
 536 
 537     private static final String MODULE = "--" + StandardBundlerParam.MODULE.getID();
 538     private static final String M = "-m";
 539     private static final String MODULE_PATH = "--" + StandardBundlerParam.MODULE_PATH.getID();
 540     private static final String P = "-p";
 541     private static final String ADD_MODULES = "--" + StandardBundlerParam.ADD_MODULES.getID();
 542     private static final String LIMIT_MODULES = "--" + StandardBundlerParam.LIMIT_MODULES.getID();
 543     private static final String STRIP_NATIVE_COMMANDS = "--" + StandardBundlerParam.STRIP_NATIVE_COMMANDS.getID();
 544 
 545     private static final String J_XDEBUG = JLinkBundlerHelper.DEBUG.getID() + ":";
 546     private static final String DETECT_MODULES = "--" + JLinkBundlerHelper.DETECT_MODULES.getID();
 547 
 548     public static void showBundlerHelp(String bundlerName, boolean verbose) {
 549         //TODO I18N
 550         if ("bundlers".equals(bundlerName)) {
 551             // enumerate bundlers
 552             System.out.println("Known Bundlers -- \n");
 553             for (Bundler bundler : Bundlers.createBundlersInstance().getBundlers()) {
 554                 try {
 555                     bundler.validate(new HashMap<>());
 556                 } catch (UnsupportedPlatformException upe) {
 557                     // don't list bundlers this platform cannot run
 558                     continue;
 559                 } catch (ConfigException ignore) {
 560                     // but requiring more than an empty map is perfectly fine.
 561                 //} catch (RuntimeException re) {
 562                 //    re.printStackTrace();
 563                 }
 564 
 565                 if (verbose) {
 566                     System.out.printf(
 567                             "%s - %s - %s\n\t%s\n",
 568                             bundler.getID(),
 569                             bundler.getName(),
 570                             bundler.getBundleType(),
 571                             bundler.getDescription()
 572                     );
 573                 } else {
 574                     System.out.printf(
 575                             "%s - %s - %s\n",
 576                             bundler.getID(),
 577                             bundler.getName(),
 578                             bundler.getBundleType()
 579                     );
 580                 }
 581             }
 582         } else {
 583             // enumerate parameters for a bundler
 584             for (Bundler bundler : Bundlers.createBundlersInstance().getBundlers()) {
 585                 if (bundler.getID().equals(bundlerName)) {
 586                     System.out.printf("Bundler Parameters for %s (%s) --\n", bundler.getName(), bundler.getID());
 587                     for (BundlerParamInfo bpi : bundler.getBundleParameters()) {
 588                         if (bpi.getStringConverter() == null) continue;
 589                         if (verbose) {
 590                             System.out.printf(
 591                                     "%s - %s - %s\n\t%s\n",
 592                                     bpi.getID(),
 593                                     bpi.getName(),
 594                                     bpi.getValueType().getSimpleName(),
 595                                     bpi.getDescription()
 596                             );
 597                         } else {
 598                             System.out.printf(
 599                                     "%s - %s - %s\n",
 600                                     bpi.getID(),
 601                                     bpi.getName(),
 602                                     bpi.getValueType().getSimpleName()
 603                             );
 604                         }
 605                     }
 606                     return;
 607                 }
 608             }
 609             System.out.printf("Sorry, no bundler matching the id %s was found.\n", bundlerName);
 610         }
 611     }
 612 }