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.sun.javafx.tools.packager.bundlers.Bundler.BundleType;
  30 import com.oracle.tools.packager.ConfigException;
  31 import com.oracle.tools.packager.UnsupportedPlatformException;
  32 
  33 import java.io.File;
  34 import java.io.FileInputStream;
  35 import java.io.IOException;
  36 import java.text.MessageFormat;
  37 import java.util.*;
  38 
  39 
  40 public class Main {
  41 
  42     private static final ResourceBundle bundle =
  43             ResourceBundle.getBundle("com/sun/javafx/tools/packager/Bundle");
  44 
  45     private static final String version = bundle.getString("MSG_Version")
  46             + " " + PackagerLib.JAVAFX_VERSION + "\n";
  47     private static final String help = bundle.getString("MSG_Help_1")
  48                                         + bundle.getString("MSG_Help_2")
  49                                         + bundle.getString("MSG_Help_3")
  50                                         + bundle.getString("MSG_Help_4")
  51                                         + bundle.getString("MSG_Help_5")
  52                                         + bundle.getString("MSG_Help_6")
  53                                         + bundle.getString("MSG_Help_7");
  54 
  55     private static String nextArg(String args[], int i) {
  56         return (i == args.length - 1) ? "" : args[i + 1];
  57     }
  58 
  59     private static boolean verbose = false;
  60     private static boolean packageAsJar = false;
  61     private static boolean genJNLP = false;
  62     private static boolean css2Bin = false;
  63     private static boolean signJar = false;
  64     private static boolean makeAll = false;
  65 
  66     private static void addResources(CommonParams commonParams,
  67                                      File baseDir, String s) {
  68         if (s == null || "".equals(s)) {
  69             return;
  70         }
  71 
  72         String[] pathArray = s.split(File.pathSeparator);
  73 
  74         for (final String path: pathArray) {
  75             commonParams.addResource(baseDir, path);
  76         }
  77     }
  78 
  79     private static void addArgument(DeployParams deployParams, String argument) {
  80         if (deployParams.arguments != null) {
  81             deployParams.arguments.add(argument);
  82         } else {
  83             List<String> list = new LinkedList<>();
  84             list.add(argument);
  85             deployParams.setArguments(list);
  86         }
  87     }
  88 
  89     private static void addArgument(CreateJarParams deployParams, String argument) {
  90         if (deployParams.arguments != null) {
  91             deployParams.arguments.add(argument);
  92         } else {
  93             List<String> list = new LinkedList<>();
  94             list.add(argument);
  95             deployParams.setArguments(list);
  96         }
  97     }
  98 
  99     private static Map<String, String> createAttrMap(String arg) {
 100         Map<String, String> map = new HashMap<>();
 101         if (arg == null || "".equals(arg)) {
 102             return null;
 103         }
 104         String[] pairsArray = arg.split(",");
 105         for (String pair: pairsArray) {
 106             String[] attr = pair.split("=");
 107             map.put(attr[0].trim(), attr[1].trim());
 108         }
 109         return map;
 110     }
 111 
 112     private static List<Param> parseParams(String filename) throws IOException {
 113         File paramFile = new File(filename);
 114         Properties properties = new Properties();
 115         FileInputStream in = new FileInputStream(paramFile);
 116         properties.load(in);
 117         in.close();
 118 
 119         List<Param> parameters = new ArrayList<>(properties.size());
 120 
 121         for (Map.Entry en : properties.entrySet()) {
 122             Param p = new Param();
 123             p.setName((String)en.getKey());
 124             p.setValue((String)en.getValue());
 125             parameters.add(p);
 126         }
 127         return parameters;
 128     }
 129 
 130     private static List<HtmlParam> parseHtmlParams(String filename) throws IOException {
 131         File paramFile = new File(filename);
 132         Properties properties = new Properties();
 133         FileInputStream in = new FileInputStream(paramFile);
 134         properties.load(in);
 135         in.close();
 136 
 137         List<HtmlParam> parameters = new ArrayList<>(properties.size());
 138 
 139         for (Map.Entry en : properties.entrySet()) {
 140             HtmlParam p = new HtmlParam();
 141             p.setName((String)en.getKey());
 142             p.setValue((String)en.getValue());
 143             parameters.add(p);
 144         }
 145         return parameters;
 146     }
 147 
 148     private static List<JSCallback> parseCallbacks(String param) {
 149         String[] callbacks = param.split(",");
 150         List<JSCallback> list = new ArrayList<>(callbacks.length);
 151 
 152         for (String cb: callbacks) {
 153             String[] nameCmd = cb.split(":");
 154             if (nameCmd.length == 2) {
 155                 list.add(new JSCallback(nameCmd[0], nameCmd[1]));
 156             }
 157         }
 158         return list;
 159     }
 160 
 161 
 162     @SuppressWarnings("deprecation")
 163     public static void main(String... args) throws Exception {
 164         if (args.length == 0 || args.length == 1 && args[0].equals("-help")) {
 165             System.out.println(help);
 166         } else if (args.length == 1 && args[0].equals("-version")) {
 167             System.out.println(version);
 168         } else {
 169             PackagerLib packager = new PackagerLib();
 170             CreateJarParams createJarParams = new CreateJarParams();
 171             DeployParams deployParams = new DeployParams();
 172             CreateBSSParams createBssParams = new CreateBSSParams();
 173             SignJarParams signJarParams = new SignJarParams();
 174             MakeAllParams makeAllParams = new MakeAllParams();
 175 
 176             File srcdir = null;
 177             try {
 178                 if (args[0].equalsIgnoreCase("-createjar")) {
 179                     boolean srcfilesSet = false;
 180                     for (int i = 1; i < args.length; i++) {
 181                         String arg = args[i];
 182                         if (arg.equalsIgnoreCase("-appclass")) {
 183                             createJarParams.setApplicationClass(nextArg(args, i++));
 184                         } else if (arg.equalsIgnoreCase("-preloader")) {
 185                             createJarParams.setPreloader(nextArg(args, i++));
 186                         } else if (arg.equalsIgnoreCase("-classpath")) {
 187                             createJarParams.setClasspath(nextArg(args, i++));
 188                         } else if (arg.equalsIgnoreCase("-manifestAttrs")) {
 189                             createJarParams.setManifestAttrs(createAttrMap(nextArg(args, i++)));
 190                         } else if (arg.equalsIgnoreCase("-noembedlauncher")) {
 191                             System.out.println("-noembedlauncher is deprecated");
 192                         } else if (arg.equalsIgnoreCase("-nocss2bin")) {
 193                             createJarParams.setCss2bin(false);
 194                         } else if (arg.equalsIgnoreCase("-runtimeVersion")) {
 195                             createJarParams.setFxVersion(nextArg(args, i++));
 196                         } else if (arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
 197                             createJarParams.setVerbose(true);
 198                             verbose = true;
 199                         } else if (arg.equalsIgnoreCase("-outdir")) {
 200                             createJarParams.setOutdir(new File(nextArg(args, i++)));
 201                         } else if (arg.equalsIgnoreCase("-outfile")) {
 202                             createJarParams.setOutfile(nextArg(args, i++));
 203                         } else if (arg.equalsIgnoreCase("-srcdir")) {
 204                             srcdir = new File(nextArg(args, i++));
 205                         } else if (arg.equalsIgnoreCase("-srcfiles")) {
 206                             addResources(createJarParams, srcdir, nextArg(args, i++));
 207                             srcfilesSet = true;
 208                         } else if (arg.equalsIgnoreCase("-argument")) {
 209                             addArgument(createJarParams, nextArg(args, i++));
 210                         }  else if (arg.equalsIgnoreCase("-paramFile")) {
 211                             createJarParams.setParams(parseParams(nextArg(args, i++)));
 212                         } else {
 213                             throw new PackagerException("ERR_UnknownArgument", arg);
 214                         }
 215                     }
 216                     if (srcdir != null && !srcdir.isDirectory()) {
 217                         throw new PackagerException("ERR_InvalidDirectory", srcdir.getAbsolutePath());
 218                     }
 219                     if (!srcfilesSet) {
 220                         //using "." as default dir is confusing. Require explicit list of inputs
 221                         if (srcdir == null) {
 222                             throw new PackagerException("ERR_MissingArgument", "-srcfiles (-srcdir)");
 223                         }
 224                         addResources(createJarParams, srcdir, ".");
 225                     }
 226                     packageAsJar = true;
 227 
 228                 } else if (args[0].equalsIgnoreCase("-deploy")) {
 229                     boolean srcfilesSet = false;
 230                     File templateInFile = null;
 231                     File templateOutFile = null;
 232                     deployParams.setBundleType(BundleType.JNLP);
 233                     deployParams.setTargetFormat("jnlp");
 234 
 235 
 236                     //can only set it to true with command line, reset default
 237                     deployParams.setEmbedJNLP(false);
 238                     for (int i = 1; i < args.length; i++) {
 239                         String arg = args[i];
 240                         if (arg.startsWith("-B")) {
 241                             String key;
 242                             String value;
 243 
 244                             int keyStart = 2;
 245                             int equals = arg.indexOf("=");
 246                             int len = arg.length();
 247                             if (equals < keyStart) {
 248                                 if (keyStart < len) {
 249                                     key = arg.substring(keyStart, len);
 250                                     value = Boolean.TRUE.toString();
 251                                 } else {
 252                                     continue;
 253                                 }
 254                             } else if (keyStart < equals) {
 255                                 key = arg.substring(keyStart, equals);
 256                                 value = arg.substring(equals+1, len);
 257                             } else {
 258                                 continue;
 259                             }
 260                             deployParams.addBundleArgument(key, value);
 261                         } else if (arg.equalsIgnoreCase("-title")) {
 262                             deployParams.setTitle(nextArg(args, i++));
 263                         } else if (arg.equalsIgnoreCase("-vendor")) {
 264                             deployParams.setVendor(nextArg(args, i++));
 265                         } else if (arg.equalsIgnoreCase("-native")) {
 266                             //if no argument is provided we will treat it as ALL
 267                             // for compatibility with FX 2.2
 268                             BundleType type = BundleType.ALL;
 269                             String format = null; //null means ANY
 270                             if (i+1 < args.length && !args[i+1].startsWith("-")) {
 271                                 String v = args[++i];
 272                                 //parsing logic is the same as in DeployFXTask
 273                                 if ("image".equals(v)) {
 274                                     type = BundleType.IMAGE;
 275                                 } else if ("installer".equals(v)) {
 276                                     type = BundleType.INSTALLER;
 277                                 } else {
 278                                     //assume it is request to build only specific format
 279                                     // (like exe or msi)
 280                                     format = (v != null) ? v.toLowerCase() : null;
 281                                 }
 282                             }
 283                             deployParams.setBundleType(type);
 284                             deployParams.setTargetFormat(format);
 285                         } else if (arg.equalsIgnoreCase("-description")) {
 286                             deployParams.setDescription(nextArg(args, i++));
 287                         } else if(arg.equalsIgnoreCase("-appclass")) {
 288                             deployParams.setApplicationClass(nextArg(args, i++));
 289                         } else if(arg.equalsIgnoreCase("-daemon")) {
 290                             deployParams.setServiceHint(true);
 291                         } else if(arg.equalsIgnoreCase("-installdirChooser")) {
 292                             deployParams.setInstalldirChooser(true);
 293                         } else if (arg.equalsIgnoreCase("-preloader")) {
 294                             deployParams.setPreloader(nextArg(args, i++));
 295                         } else if (arg.equalsIgnoreCase("-paramFile")) {
 296                             deployParams.setParams(parseParams(nextArg(args, i++)));
 297                         } else if (arg.equalsIgnoreCase("-htmlParamFile")) {
 298                             deployParams.setHtmlParams(parseHtmlParams(nextArg(args, i++)));
 299                         } else if (arg.equalsIgnoreCase("-width")) {
 300                             deployParams.setWidth(Integer.parseInt(nextArg(args, i++)));
 301                         } else if (arg.equalsIgnoreCase("-height")) {
 302                             deployParams.setHeight(Integer.parseInt(nextArg(args, i++)));
 303                         } else if (arg.equalsIgnoreCase("-name")) {
 304                             deployParams.setAppName(nextArg(args, i++));
 305                         } else if (arg.equalsIgnoreCase("-embedJNLP")) {
 306                             deployParams.setEmbedJNLP(true);
 307                         } else if (arg.equalsIgnoreCase("-embedCertificates")) {
 308                             System.out.println("-embedCertificates is deprecated");
 309                         } else if (arg.equalsIgnoreCase("-allpermissions")) {
 310                             deployParams.setAllPermissions(true);
 311                         } else if (arg.equalsIgnoreCase("-updatemode")) {
 312                             deployParams.setUpdateMode(nextArg(args, i++));
 313                         } else if (arg.equalsIgnoreCase("-isExtension")) {
 314                             deployParams.setExtension(true);
 315                         } else if (arg.equalsIgnoreCase("-callbacks")) {
 316                             deployParams.setJSCallbacks(parseCallbacks(nextArg(args, i++)));
 317                         } else if (arg.equalsIgnoreCase("-templateInFilename")) {
 318                             templateInFile = new File(nextArg(args, i++));
 319                         } else if (arg.equalsIgnoreCase("-templateOutFilename")) {
 320                             templateOutFile = new File(nextArg(args, i++));
 321                         } else if (arg.equalsIgnoreCase("-appId") || arg.equalsIgnoreCase("-templateId")) {
 322                             String appIdArg = nextArg(args, i++);
 323                             deployParams.setAppId(appIdArg);
 324                             deployParams.setId(appIdArg);
 325                         } else if (arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
 326                             deployParams.setVerbose(true);
 327                             verbose = true;
 328                         } else if (arg.equalsIgnoreCase("-includedt")) {
 329                             deployParams.setIncludeDT(true);
 330                         } else if (arg.equalsIgnoreCase("-outdir")) {
 331                             deployParams.setOutdir(new File(nextArg(args, i++)));
 332                         } else if (arg.equalsIgnoreCase("-outfile")) {
 333                             deployParams.setOutfile(nextArg(args, i++));
 334                         } else if (arg.equalsIgnoreCase("-srcdir")) {
 335                             srcdir = new File(nextArg(args, i++));
 336                         } else if (arg.equalsIgnoreCase("-srcfiles")) {
 337                             addResources(deployParams, srcdir, nextArg(args, i++));
 338                             srcfilesSet = true;
 339                         } else if (arg.equalsIgnoreCase("-argument")) {
 340                             addArgument(deployParams, nextArg(args, i++));
 341                         } else if (arg.equalsIgnoreCase("-nosign")) {
 342                             deployParams.setSignBundle(false);
 343                         } else if (arg.equals("-addmods")) {
 344                             deployParams.addModules.add(nextArg(args, i++));
 345                         } else if (arg.equals("-limitmods")) {
 346                             deployParams.limitModules.add(nextArg(args, i++));
 347                         } else if (arg.equals("-detectmods")) {
 348                             deployParams.detectModules = true;
 349                         } else if (arg.equals("-stripexecutables")) {
 350                             deployParams.stripExecutables = true;
 351                         } else if (arg.equals("-modulepath")) {
 352                             if (deployParams.modulePath == null) {
 353                                 deployParams.modulePath = nextArg(args, i++);
 354                             } else {
 355                                 deployParams.modulePath =
 356                                         deployParams.modulePath
 357                                         + File.pathSeparator
 358                                         + nextArg(args, i++);
 359                             }
 360                         } else if (arg.equals("-jdkmodulepath")) {
 361                             if (deployParams.jdkModulePath == null) {
 362                                 deployParams.jdkModulePath = nextArg(args, i++);
 363                             } else {
 364                                 deployParams.jdkModulePath =
 365                                         deployParams.jdkModulePath
 366                                         + File.pathSeparator
 367                                         + nextArg(args, i++);
 368                             }
 369                         } else {
 370                             throw new PackagerException("ERR_UnknownArgument", arg);
 371                         }
 372                     }
 373                     if (templateInFile != null) {
 374                         deployParams.addTemplate(templateInFile, templateOutFile);
 375                     }
 376                     if (srcdir != null && !srcdir.isDirectory()) {
 377                         throw new PackagerException("ERR_InvalidDirectory", srcdir.getAbsolutePath());
 378                     }
 379                     if (!srcfilesSet) {
 380                         //using "." as default dir is confusing. Require explicit list of inputs
 381                         if (srcdir == null) {
 382                             throw new PackagerException("ERR_MissingArgument", "-srcfiles (-srcdir)");
 383                         }
 384                         addResources(deployParams, srcdir, ".");
 385                     }
 386                     genJNLP = true;
 387                 } else if (args[0].equalsIgnoreCase("-createbss")) {
 388                     boolean srcfilesSet = false;
 389                     for (int i = 1; i < args.length; i++) {
 390                         String arg = args[i];
 391                         if (arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
 392                             createBssParams.setVerbose(true);
 393                             verbose = true;
 394                         } else if (arg.equalsIgnoreCase("-outdir")) {
 395                             createBssParams.setOutdir(new File(nextArg(args, i++)));
 396                         } else if (arg.equalsIgnoreCase("-srcdir")) {
 397                             srcdir = new File(nextArg(args, i++));
 398                         } else if (arg.equalsIgnoreCase("-srcfiles")) {
 399                             addResources(createBssParams, srcdir, nextArg(args, i++));
 400                             srcfilesSet = true;
 401                         } else {
 402                             throw new PackagerException("ERR_UnknownArgument", arg);
 403                         }
 404                     }
 405                     if (srcdir != null && !srcdir.isDirectory()) {
 406                         throw new PackagerException("ERR_InvalidDirectory", srcdir.getAbsolutePath());
 407                     }
 408                     if (!srcfilesSet) {
 409                         //using "." as default dir is confusing. Require explicit list of inputs
 410                         if (srcdir == null) {
 411                             throw new PackagerException("ERR_MissingArgument", "-srcfiles (-srcdir)");
 412                         }
 413                         addResources(createBssParams, srcdir, ".");
 414                     }
 415                     css2Bin = true;
 416 
 417                 } else if (args[0].equalsIgnoreCase("-signJar")) {
 418                     boolean srcfilesSet = false;
 419                     for (int i = 1; i < args.length; i++) {
 420                         String arg = args[i];
 421                         if (arg.equalsIgnoreCase("-keyStore")) {
 422                             signJarParams.setKeyStore(new File(nextArg(args, i++)));
 423                         } else if(arg.equalsIgnoreCase("-alias")) {
 424                             signJarParams.setAlias(nextArg(args, i++));
 425                         } else if(arg.equalsIgnoreCase("-storePass")) {
 426                             signJarParams.setStorePass(nextArg(args, i++));
 427                         } else if(arg.equalsIgnoreCase("-keyPass")) {
 428                             signJarParams.setKeyPass(nextArg(args, i++));
 429                         } else if(arg.equalsIgnoreCase("-storeType")) {
 430                             signJarParams.setStoreType(nextArg(args, i++));
 431                         } else if(arg.equalsIgnoreCase("-verbose") || arg.equalsIgnoreCase("-v")) {
 432                             signJarParams.setVerbose(true);
 433                             verbose = true;
 434                         } else if (arg.equalsIgnoreCase("-outdir")) {
 435                             signJarParams.setOutdir(new File(nextArg(args, i++)));
 436                         } else if (arg.equalsIgnoreCase("-srcdir")) {
 437                             srcdir = new File(nextArg(args, i++));
 438                         } else if (arg.equalsIgnoreCase("-srcfiles")) {
 439                             addResources(signJarParams, srcdir, nextArg(args, i++));
 440                             srcfilesSet = true;
 441                         } else {
 442                             throw new PackagerException("ERR_UnknownArgument", arg);
 443                         }
 444                     }
 445                     if (srcdir != null && !srcdir.isDirectory()) {
 446                         throw new PackagerException("ERR_InvalidDirectory", srcdir.getAbsolutePath());
 447                     }
 448                     if (!srcfilesSet) {
 449                         //using "." as default dir is confusing. Require explicit list of inputs
 450                         if (srcdir == null) {
 451                             throw new PackagerException("ERR_MissingArgument", "-srcfiles (-srcdir)");
 452                         }
 453                         addResources(signJarParams, srcdir, ".");
 454                     }
 455                     signJar = true;
 456                 } else if (args[0].equalsIgnoreCase("-makeall")) {
 457                     for (int i = 1; i < args.length; i++) {
 458                         String arg = args[i];
 459                         if (arg.equalsIgnoreCase("-appclass")) {
 460                             makeAllParams.setAppClass(nextArg(args, i++));
 461                         } else if (arg.equalsIgnoreCase("-preloader")) {
 462                             makeAllParams.setPreloader(nextArg(args, i++));
 463                         } else if (arg.equalsIgnoreCase("-classpath")) {
 464                             makeAllParams.setClasspath(nextArg(args, i++));
 465                         } else if (arg.equalsIgnoreCase("-name")) {
 466                             makeAllParams.setAppName(nextArg(args, i++));
 467                         } else if(arg.equalsIgnoreCase("-width")) {
 468                             makeAllParams.setWidth(Integer.parseInt(nextArg(args, i++)));
 469                         } else if(arg.equalsIgnoreCase("-height")) {
 470                             makeAllParams.setHeight(Integer.parseInt(nextArg(args, i++)));
 471                         } else if(arg.equalsIgnoreCase("-v")) {
 472                             makeAllParams.setVerbose(true);
 473                         } else {
 474                             throw new PackagerException("ERR_UnknownArgument", arg);
 475                         }
 476                     }
 477                     makeAll = true;
 478                 } else if (args[0].equalsIgnoreCase("-help")) {
 479                     showBundlerHelp(args[1], args.length > 2 && "-verbose".equals(args[2]));
 480                 } else {
 481                     System.err.println(MessageFormat.format(
 482                                         bundle.getString("ERR_UnknownCommand"),
 483                                         args[0]));
 484                     System.exit(-1);
 485                 }
 486 
 487                 //set default logger
 488                 if (verbose) {
 489                     com.oracle.tools.packager.Log.setLogger(new com.oracle.tools.packager.Log.Logger(true));
 490                 } else {
 491                     com.oracle.tools.packager.Log.setLogger(new com.oracle.tools.packager.Log.Logger(false));
 492                 }
 493 
 494                 if (css2Bin) {
 495                     createBssParams.validate();
 496                     packager.generateBSS(createBssParams);
 497                 }
 498                 if (packageAsJar) {
 499                     createJarParams.validate();
 500                     packager.packageAsJar(createJarParams);
 501                 }
 502                 if (genJNLP) {
 503                     deployParams.validate();
 504                     packager.generateDeploymentPackages(deployParams);
 505                 }
 506                 if (signJar) {
 507                     signJarParams.validate();
 508                     if (signJarParams.storePass == null) {
 509                         char[] passwd = System.console().readPassword(bundle.getString("MSG_EnterKeystorePassword"));
 510                         if (passwd == null) {
 511                             signJarParams.storePass = "";
 512                         } else {
 513                             signJarParams.storePass = new String(passwd);
 514                         }
 515                     }
 516                     if (signJarParams.keyPass == null) {
 517                         char[] passwd = System.console().readPassword(bundle.getString("MSG_EnterKeyPassword"), signJarParams.alias);
 518                         if (passwd == null) {
 519                             signJarParams.keyPass = "";
 520                         } else {
 521                             signJarParams.keyPass = new String(passwd);
 522                         }
 523                     }
 524                     packager.signJar(signJarParams);
 525                 }
 526                 if (makeAll) {
 527                     makeAllParams.validate();
 528                     packager.makeAll(makeAllParams);
 529                 }
 530 
 531             } catch (Exception e) {
 532                 if (verbose) {
 533                     throw e;
 534                 } else {
 535                     System.err.println(e.getMessage());
 536                     if (e.getCause() != null && e.getCause() != e) {
 537                         System.err.println(e.getCause().getMessage());
 538                     }
 539                     System.exit(-1);
 540                 }
 541             }
 542         }
 543     }
 544 
 545     public static void showBundlerHelp(String bundlerName, boolean verbose) {
 546         //TODO I18N
 547         if ("bundlers".equals(bundlerName)) {
 548             // enumerate bundlers
 549             System.out.println("Known Bundlers -- \n");
 550             for (Bundler bundler : Bundlers.createBundlersInstance().getBundlers()) {
 551                 try {
 552                     bundler.validate(new HashMap<>());
 553                 } catch (UnsupportedPlatformException upe) {
 554                     // don't list bundlers this platform cannot run
 555                     continue;
 556                 } catch (ConfigException ignore) {
 557                     // but requiring more than an empty map is perfectly fine.
 558                 //} catch (RuntimeException re) {
 559                 //    re.printStackTrace();
 560                 }
 561 
 562                 if (verbose) {
 563                     System.out.printf(
 564                             "%s - %s - %s\n\t%s\n",
 565                             bundler.getID(),
 566                             bundler.getName(),
 567                             bundler.getBundleType(),
 568                             bundler.getDescription()
 569                     );
 570                 } else {
 571                     System.out.printf(
 572                             "%s - %s - %s\n",
 573                             bundler.getID(),
 574                             bundler.getName(),
 575                             bundler.getBundleType()
 576                     );
 577                 }
 578             }
 579         } else {
 580             // enumerate parameters for a bundler
 581             for (Bundler bundler : Bundlers.createBundlersInstance().getBundlers()) {
 582                 if (bundler.getID().equals(bundlerName)) {
 583                     System.out.printf("Bundler Parameters for %s (%s) --\n", bundler.getName(), bundler.getID());
 584                     for (BundlerParamInfo bpi : bundler.getBundleParameters()) {
 585                         if (bpi.getStringConverter() == null) continue;
 586                         if (verbose) {
 587                             System.out.printf(
 588                                     "%s - %s - %s\n\t%s\n",
 589                                     bpi.getID(),
 590                                     bpi.getName(),
 591                                     bpi.getValueType().getSimpleName(),
 592                                     bpi.getDescription()
 593                             );
 594                         } else {
 595                             System.out.printf(
 596                                     "%s - %s - %s\n",
 597                                     bpi.getID(),
 598                                     bpi.getName(),
 599                                     bpi.getValueType().getSimpleName()
 600                             );
 601                         }
 602                     }
 603                     return;
 604                 }
 605             }
 606             System.out.printf("Sorry, no bundler matching the id %s was found.\n", bundlerName);
 607         }
 608     }
 609 }