src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
author herrick
Mon, 07 Jan 2019 16:41:59 -0500
branchJDK-8200758-branch
changeset 57097 6e5eb7855fe2
parent 57096 d06bec27f8c9
child 57099 9a85a7a076ad
permissions -rw-r--r--
8215900: Without --files args, only jars in the top level of --input are added to class-path Reviewed-by: almatvee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     1
/*
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     4
 *
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    10
 *
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    15
 * accompanied this code).
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    16
 *
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    20
 *
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    23
 * questions.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    24
 */
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57038
diff changeset
    25
package jdk.jpackage.internal;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    26
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    27
import java.io.File;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    28
import java.io.FileInputStream;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    29
import java.io.IOException;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    30
import java.nio.file.Files;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    31
import java.nio.file.Path;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    32
import java.text.MessageFormat;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    33
import java.util.ArrayList;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    34
import java.util.Arrays;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    35
import java.util.Collection;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    36
import java.util.EnumSet;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    37
import java.util.HashMap;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    38
import java.util.HashSet;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    39
import java.util.List;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    40
import java.util.Map;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    41
import java.util.Set;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    42
import java.util.Properties;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    43
import java.util.ResourceBundle;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    44
import java.util.jar.Attributes;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    45
import java.util.jar.JarFile;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    46
import java.util.jar.Manifest;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    47
import java.util.stream.Stream;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    48
import java.util.regex.Matcher;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    49
import java.util.regex.Pattern;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    50
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    51
/**
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    52
 * Arguments
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    53
 *
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    54
 * This class encapsulates and processes the command line arguments,
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57038
diff changeset
    55
 * in effect, implementing all the work of jpackage tool.
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    56
 *
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    57
 * The primary entry point, processArguments():
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    58
 * Processes and validates command line arguments, constructing DeployParams.
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    59
 * Validates the DeployParams, and generate the BundleParams.
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    60
 * Generates List of Bundlers from BundleParams valid for this platform.
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    61
 * Executes each Bundler in the list.
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    62
 */
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    63
public class Arguments {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
    64
    private static final ResourceBundle I18N = ResourceBundle.getBundle(
57059
9bb2a4dc3af7 8214143: Reduce Resource files
herrick
parents: 57039
diff changeset
    65
            "jdk.jpackage.internal.resources.MainResources");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    66
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    67
    private static final String IMAGE_MODE = "image";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    68
    private static final String INSTALLER_MODE = "installer";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    69
    private static final String JRE_INSTALLER_MODE = "jre-installer";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    70
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    71
    private static final String FA_EXTENSIONS = "extension";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    72
    private static final String FA_CONTENT_TYPE = "mime-type";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    73
    private static final String FA_DESCRIPTION = "description";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    74
    private static final String FA_ICON = "icon";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    75
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    76
    public static final BundlerParamInfo<Boolean> CREATE_IMAGE =
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    77
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    78
                    I18N.getString("param.create-image.name"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    79
                    I18N.getString("param.create-image.description"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    80
                    IMAGE_MODE,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    81
                    Boolean.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    82
                    p -> Boolean.FALSE,
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
    83
                    (s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
    84
                            true : Boolean.valueOf(s));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    85
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    86
    public static final BundlerParamInfo<Boolean> CREATE_INSTALLER =
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    87
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    88
                    I18N.getString("param.create-installer.name"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    89
                    I18N.getString("param.create-installer.description"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    90
                    INSTALLER_MODE,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    91
                    Boolean.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    92
                    p -> Boolean.FALSE,
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
    93
                    (s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
    94
                            true : Boolean.valueOf(s));
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
    95
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    96
    public static final BundlerParamInfo<Boolean> CREATE_JRE_INSTALLER =
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    97
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    98
                    I18N.getString("param.create-jre-installer.name"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    99
                    I18N.getString("param.create-jre-installer.description"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   100
                    JRE_INSTALLER_MODE,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   101
                    Boolean.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   102
                    p -> Boolean.FALSE,
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   103
                    (s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   104
                            true : Boolean.valueOf(s));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   105
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   106
    // regexp for parsing args (for example, for secondary launchers)
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   107
    private static Pattern pattern = Pattern.compile(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   108
          "(?:(?:([\"'])(?:\\\\\\1|.)*?(?:\\1|$))|(?:\\\\[\"'\\s]|[^\\s]))++");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   109
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   110
    private DeployParams deployParams = null;
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
   111
    private BundlerType bundleType = null;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   112
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   113
    private int pos = 0;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   114
    private List<String> argList = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   115
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   116
    private List<CLIOptions> allOptions = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   117
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   118
    private ArrayList<String> files = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   119
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   120
    private String input = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   121
    private String output = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   122
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   123
    private boolean hasMainJar = false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   124
    private boolean hasMainClass = false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   125
    private boolean hasMainModule = false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   126
    private boolean hasTargetFormat = false;
56882
0ec8559f599a 8210439: Unable to create an installer from a previously created app image on Windows
herrick
parents: 56869
diff changeset
   127
    private boolean hasAppImage = false;
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   128
    private boolean retainBuildRoot = false;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   129
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   130
    private String buildRoot = null; 
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   131
    private String mainJarPath = null;
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   132
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   133
    private static boolean jreInstaller = false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   134
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57038
diff changeset
   135
    private List<jdk.jpackage.internal.Bundler> platformBundlers = null;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   136
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   137
    private List<SecondaryLauncherArguments> secondaryLaunchers = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   138
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   139
    private static Map<String, CLIOptions> argIds = new HashMap<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   140
    private static Map<String, CLIOptions> argShortIds = new HashMap<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   141
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   142
    {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   143
        // init maps for parsing arguments
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   144
        EnumSet<CLIOptions> options = EnumSet.allOf(CLIOptions.class);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   145
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   146
        options.forEach(option -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   147
            argIds.put(option.getIdWithPrefix(), option);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   148
            if (option.getShortIdWithPrefix() != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   149
                argShortIds.put(option.getShortIdWithPrefix(), option);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   150
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   151
        });
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   152
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   153
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   154
    public Arguments(String[] args) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   155
        initArgumentList(args);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   156
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   157
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57065
diff changeset
   158
    // CLIOptions is public for DeployParamsTest
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   159
    public enum CLIOptions {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   160
        CREATE_IMAGE(IMAGE_MODE, OptionCategories.MODE, () -> {
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
   161
            context().bundleType = BundlerType.IMAGE;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   162
            context().deployParams.setTargetFormat("image");
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   163
            setOptionValue(IMAGE_MODE, true);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   164
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   165
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   166
        CREATE_INSTALLER(INSTALLER_MODE, OptionCategories.MODE, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   167
            setOptionValue(INSTALLER_MODE, true);
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
   168
            context().bundleType = BundlerType.INSTALLER;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   169
            String format = "installer";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   170
            if (hasNextArg()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   171
                String arg = popArg();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   172
                if (!arg.startsWith("-")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   173
                    format = arg.toLowerCase();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   174
                    context().hasTargetFormat = true;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   175
                } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   176
                    prevArg();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   177
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   178
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   179
            context().deployParams.setTargetFormat(format);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   180
        }),
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   181
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   182
        CREATE_JRE_INSTALLER(JRE_INSTALLER_MODE, OptionCategories.MODE, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   183
            setOptionValue(JRE_INSTALLER_MODE, true);
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
   184
            context().bundleType = BundlerType.INSTALLER;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   185
            String format = "installer";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   186
            if (hasNextArg()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   187
                String arg = popArg();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   188
                if (!arg.startsWith("-")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   189
                    format = arg.toLowerCase();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   190
                    context().hasTargetFormat = true;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   191
                } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   192
                    prevArg();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   193
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   194
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   195
            jreInstaller = true;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   196
            context().deployParams.setTargetFormat(format);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   197
            context().deployParams.setJreInstaller(true);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   198
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   199
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   200
        INPUT ("input", "i", OptionCategories.PROPERTY, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   201
            context().input = popArg();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   202
            setOptionValue("input", context().input);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   203
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   204
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   205
        OUTPUT ("output", "o", OptionCategories.PROPERTY, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   206
            context().output = popArg();
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
   207
            context().deployParams.setOutput(new File(context().output));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   208
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   209
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   210
        DESCRIPTION ("description", "d", OptionCategories.PROPERTY),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   211
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   212
        VENDOR ("vendor", OptionCategories.PROPERTY),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   213
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   214
        APPCLASS ("class", "c", OptionCategories.PROPERTY, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   215
            context().hasMainClass = true;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   216
            setOptionValue("class", popArg());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   217
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   218
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   219
        SINGLETON ("singleton", OptionCategories.PROPERTY, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   220
            setOptionValue("singleton", true);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   221
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   222
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   223
        NAME ("name", "n", OptionCategories.PROPERTY),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   224
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   225
        IDENTIFIER ("identifier", OptionCategories.PROPERTY),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   226
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   227
        VERBOSE ("verbose", OptionCategories.PROPERTY, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   228
            setOptionValue("verbose", true);
56987
0d2ff0d6bb94 8211297: --verbose does not work with jpackager
herrick
parents: 56982
diff changeset
   229
            Log.setVerbose(true);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   230
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   231
57021
441c020bf626 8213324:jpackager deletes existing app directory without warning
herrick
parents: 57020
diff changeset
   232
        FORCE ("force", OptionCategories.PROPERTY, () -> {
441c020bf626 8213324:jpackager deletes existing app directory without warning
herrick
parents: 57020
diff changeset
   233
            setOptionValue("force", true);
441c020bf626 8213324:jpackager deletes existing app directory without warning
herrick
parents: 57020
diff changeset
   234
        }),
441c020bf626 8213324:jpackager deletes existing app directory without warning
herrick
parents: 57020
diff changeset
   235
57091
06bc4bd64599 8215515: Add a command line option to override internal resources.
herrick
parents: 57071
diff changeset
   236
        RESOURCE_DIR("resource-dir",
06bc4bd64599 8215515: Add a command line option to override internal resources.
herrick
parents: 57071
diff changeset
   237
                OptionCategories.PROPERTY, () -> {
06bc4bd64599 8215515: Add a command line option to override internal resources.
herrick
parents: 57071
diff changeset
   238
            String resourceDir = popArg();
06bc4bd64599 8215515: Add a command line option to override internal resources.
herrick
parents: 57071
diff changeset
   239
            setOptionValue("resource-dir", resourceDir);
06bc4bd64599 8215515: Add a command line option to override internal resources.
herrick
parents: 57071
diff changeset
   240
        }),
57021
441c020bf626 8213324:jpackager deletes existing app directory without warning
herrick
parents: 57020
diff changeset
   241
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   242
        FILES ("files", "f", OptionCategories.PROPERTY, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   243
              context().files = new ArrayList<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   244
              String files = popArg();
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   245
              context().files.addAll(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   246
                      Arrays.asList(files.split(File.pathSeparator)));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   247
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   248
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   249
        ARGUMENTS ("arguments", "a", OptionCategories.PROPERTY, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   250
            List<String> arguments = getArgumentList(popArg());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   251
            setOptionValue("arguments", arguments);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   252
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   253
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   254
        STRIP_NATIVE_COMMANDS ("strip-native-commands",
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   255
                   OptionCategories.PROPERTY, () -> {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   256
            setOptionValue("strip-native-commands", true);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   257
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   258
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   259
        ICON ("icon", OptionCategories.PROPERTY),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   260
        CATEGORY ("category", OptionCategories.PROPERTY),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   261
        COPYRIGHT ("copyright", OptionCategories.PROPERTY),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   262
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   263
        LICENSE_FILE ("license-file", OptionCategories.PROPERTY),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   264
57071
94e9270166f0 8213392: Enhance --help and --version
herrick
parents: 57067
diff changeset
   265
        VERSION ("app-version", OptionCategories.PROPERTY),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   266
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   267
        JVM_ARGS ("jvm-args", OptionCategories.PROPERTY, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   268
            List<String> args = getArgumentList(popArg());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   269
            args.forEach(a -> setOptionValue("jvm-args", a));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   270
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   271
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   272
        FILE_ASSOCIATIONS ("file-associations",
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   273
                OptionCategories.PROPERTY, () -> {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   274
            Map<String, ? super Object> args = new HashMap<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   275
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   276
            // load .properties file
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   277
            Map<String, String> initialMap = getPropertiesFromFile(popArg());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   278
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   279
            String ext = initialMap.get(FA_EXTENSIONS);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   280
            if (ext != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   281
                args.put(StandardBundlerParam.FA_EXTENSIONS.getID(), ext);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   282
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   283
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   284
            String type = initialMap.get(FA_CONTENT_TYPE);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   285
            if (type != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   286
                args.put(StandardBundlerParam.FA_CONTENT_TYPE.getID(), type);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   287
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   288
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   289
            String desc = initialMap.get(FA_DESCRIPTION);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   290
            if (desc != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   291
                args.put(StandardBundlerParam.FA_DESCRIPTION.getID(), desc);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   292
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   293
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   294
            String icon = initialMap.get(FA_ICON);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   295
            if (icon != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   296
                args.put(StandardBundlerParam.FA_ICON.getID(), icon);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   297
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   298
56836
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   299
            ArrayList<Map<String, ? super Object>> associationList =
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   300
                new ArrayList<Map<String, ? super Object>>();
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   301
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   302
            associationList.add(args);
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   303
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   304
            // check that we really add _another_ value to the list
56836
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   305
            setOptionValue("file-associations", associationList);
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   306
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   307
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   308
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   309
        SECONDARY_LAUNCHER ("secondary-launcher",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   310
                    OptionCategories.PROPERTY, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   311
            context().secondaryLaunchers.add(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   312
                new SecondaryLauncherArguments(popArg()));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   313
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   314
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   315
        BUILD_ROOT ("build-root", OptionCategories.PROPERTY, () -> {
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   316
            context().buildRoot = popArg();
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   317
            context().retainBuildRoot = true;
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   318
            setOptionValue("build-root", context().buildRoot);
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   319
        }),
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   320
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   321
        INSTALL_DIR ("install-dir", OptionCategories.PROPERTY),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   322
56882
0ec8559f599a 8210439: Unable to create an installer from a previously created app image on Windows
herrick
parents: 56869
diff changeset
   323
        PREDEFINED_APP_IMAGE ("app-image", OptionCategories.PROPERTY, ()-> {
0ec8559f599a 8210439: Unable to create an installer from a previously created app image on Windows
herrick
parents: 56869
diff changeset
   324
            setOptionValue("app-image", popArg());
0ec8559f599a 8210439: Unable to create an installer from a previously created app image on Windows
herrick
parents: 56869
diff changeset
   325
            context().hasAppImage = true;
0ec8559f599a 8210439: Unable to create an installer from a previously created app image on Windows
herrick
parents: 56869
diff changeset
   326
        }),
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   327
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   328
        PREDEFINED_RUNTIME_IMAGE ("runtime-image", OptionCategories.PROPERTY),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   329
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   330
        MAIN_JAR ("main-jar", "j", OptionCategories.PROPERTY, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   331
            context().mainJarPath = popArg();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   332
            context().hasMainJar = true;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   333
            setOptionValue("main-jar", context().mainJarPath);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   334
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   335
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   336
        MODULE ("module", "m", OptionCategories.MODULAR, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   337
            context().hasMainModule = true;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   338
            setOptionValue("module", popArg());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   339
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   340
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   341
        ADD_MODULES ("add-modules", OptionCategories.MODULAR),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   342
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   343
        MODULE_PATH ("module-path", "p", OptionCategories.MODULAR),
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   344
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   345
        LIMIT_MODULES ("limit-modules", OptionCategories.MODULAR),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   346
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   347
        MAC_SIGN ("mac-sign", "s", OptionCategories.PLATFORM_MAC, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   348
            setOptionValue("mac-sign", true);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   349
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   350
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   351
        MAC_BUNDLE_NAME ("mac-bundle-name", OptionCategories.PLATFORM_MAC),
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   352
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   353
        MAC_BUNDLE_IDENTIFIER("mac-bundle-identifier",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   354
                    OptionCategories.PLATFORM_MAC),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   355
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   356
        MAC_APP_STORE_CATEGORY ("mac-app-store-category",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   357
                    OptionCategories.PLATFORM_MAC),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   358
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   359
        MAC_BUNDLE_SIGNING_PREFIX ("mac-bundle-signing-prefix",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   360
                    OptionCategories.PLATFORM_MAC),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   361
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   362
        MAC_SIGNING_KEY_NAME ("mac-signing-key-user-name",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   363
                    OptionCategories.PLATFORM_MAC),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   364
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   365
        MAC_SIGNING_KEYCHAIN ("mac-signing-keychain",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   366
                    OptionCategories.PLATFORM_MAC),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   367
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   368
        MAC_APP_STORE_ENTITLEMENTS ("mac-app-store-entitlements",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   369
                    OptionCategories.PLATFORM_MAC),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   370
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   371
        WIN_MENU_HINT ("win-menu", OptionCategories.PLATFORM_WIN, () -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   372
            setOptionValue("win-menu", true);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   373
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   374
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   375
        WIN_MENU_GROUP ("win-menu-group", OptionCategories.PLATFORM_WIN),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   376
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   377
        WIN_SHORTCUT_HINT ("win-shortcut",
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   378
                OptionCategories.PLATFORM_WIN, () -> {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   379
            setOptionValue("win-shortcut", true);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   380
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   381
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   382
        WIN_PER_USER_INSTALLATION ("win-per-user-install",
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   383
                OptionCategories.PLATFORM_WIN, () -> {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   384
            setOptionValue("win-per-user-install", false);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   385
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   386
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   387
        WIN_DIR_CHOOSER ("win-dir-chooser",
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   388
                OptionCategories.PLATFORM_WIN, () -> {
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   389
            setOptionValue("win-dir-chooser", true);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   390
        }),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   391
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   392
        WIN_REGISTRY_NAME ("win-registry-name", OptionCategories.PLATFORM_WIN),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   393
57062
044e7a644ee3 8214575: Exe installers will install application to already existing instalation
herrick
parents: 57060
diff changeset
   394
        WIN_UPGRADE_UUID ("win-upgrade-uuid",
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   395
                OptionCategories.PLATFORM_WIN),
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   396
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   397
        WIN_CONSOLE_HINT ("win-console", OptionCategories.PLATFORM_WIN, () -> {
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   398
            setOptionValue("win-console", true);
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   399
        }),
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   400
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   401
        LINUX_BUNDLE_NAME ("linux-bundle-name",
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   402
                OptionCategories.PLATFORM_LINUX),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   403
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   404
        LINUX_DEB_MAINTAINER ("linux-deb-maintainer",
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   405
                OptionCategories.PLATFORM_LINUX),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   406
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   407
        LINUX_RPM_LICENSE_TYPE ("linux-rpm-license-type",
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   408
                OptionCategories.PLATFORM_LINUX),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   409
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   410
        LINUX_PACKAGE_DEPENDENCIES ("linux-package-deps",
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   411
                OptionCategories.PLATFORM_LINUX);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   412
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   413
        private final String id;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   414
        private final String shortId;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   415
        private final OptionCategories category;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   416
        private final ArgAction action;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   417
        private static Arguments argContext;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   418
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   419
        private CLIOptions(String id, OptionCategories category) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   420
            this(id, null, category, null);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   421
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   422
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   423
        private CLIOptions(String id, String shortId,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   424
                           OptionCategories category) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   425
            this(id, shortId, category, null);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   426
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   427
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   428
        private CLIOptions(String id,
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   429
                OptionCategories category, ArgAction action) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   430
            this(id, null, category, action);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   431
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   432
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   433
        private CLIOptions(String id, String shortId,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   434
                           OptionCategories category, ArgAction action) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   435
            this.id = id;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   436
            this.shortId = shortId;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   437
            this.action = action;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   438
            this.category = category;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   439
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   440
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57065
diff changeset
   441
        static void setContext(Arguments context) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   442
            argContext = context;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   443
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   444
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   445
        private static Arguments context() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   446
            if (argContext != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   447
                return argContext;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   448
            } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   449
                throw new RuntimeException("Argument context is not set.");
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   450
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   451
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   452
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   453
        public String getId() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   454
            return this.id;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   455
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   456
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57065
diff changeset
   457
        String getIdWithPrefix() {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   458
            String prefix = isMode() ? "create-" : "--";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   459
            return prefix + this.id;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   460
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   461
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57065
diff changeset
   462
        String getShortIdWithPrefix() {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   463
            return this.shortId == null ? null : "-" + this.shortId;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   464
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   465
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57065
diff changeset
   466
        void execute() {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   467
            if (action != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   468
                action.execute();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   469
            } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   470
                defaultAction();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   471
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   472
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   473
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57065
diff changeset
   474
        boolean isMode() {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   475
            return category == OptionCategories.MODE;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   476
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   477
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57065
diff changeset
   478
        OptionCategories getCategory() {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   479
            return category;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   480
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   481
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   482
        private void defaultAction() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   483
            context().deployParams.addBundleArgument(id, popArg());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   484
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   485
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   486
        private static void setOptionValue(String option, Object value) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   487
            context().deployParams.addBundleArgument(option, value);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   488
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   489
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   490
        private static String popArg() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   491
            nextArg();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   492
            return (context().pos >= context().argList.size()) ?
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   493
                            "" : context().argList.get(context().pos);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   494
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   495
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   496
        private static String getArg() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   497
            return (context().pos >= context().argList.size()) ?
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   498
                        "" : context().argList.get(context().pos);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   499
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   500
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   501
        private static void nextArg() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   502
            context().pos++;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   503
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   504
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   505
        private static void prevArg() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   506
            context().pos--;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   507
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   508
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   509
        private static boolean hasNextArg() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   510
            return context().pos < context().argList.size();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   511
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   512
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   513
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57065
diff changeset
   514
    enum OptionCategories {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   515
        MODE,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   516
        MODULAR,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   517
        PROPERTY,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   518
        PLATFORM_MAC,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   519
        PLATFORM_WIN,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   520
        PLATFORM_LINUX;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   521
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   522
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   523
    private void initArgumentList(String[] args) {
57060
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   524
        argList = new ArrayList<String>(args.length);
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   525
        for (String arg : args) {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   526
            if (arg.startsWith("@")) {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   527
                if (arg.length() > 1) {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   528
                    String filename = arg.substring(1);
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   529
                    argList.addAll(extractArgList(filename));
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   530
                } else {
57065
2446962c555c 8214982: jpackage causes failures in existing HelpFlagsTest and VersionCheck tests
herrick
parents: 57062
diff changeset
   531
                    Log.error("invalid option ["+arg+"]");
57060
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   532
                }
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   533
            } else {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   534
                argList.add(arg);
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   535
            }
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   536
        }
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   537
        Log.debug ("\nJPackage argument list: \n" + argList + "\n");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   538
        pos = 0;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   539
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   540
        deployParams = new DeployParams();
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
   541
        bundleType = BundlerType.NONE;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   542
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   543
        allOptions = new ArrayList<>();
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   544
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   545
        secondaryLaunchers = new ArrayList<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   546
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   547
57060
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   548
    private List<String> extractArgList(String filename) {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   549
        List<String> args = new ArrayList<String>();
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   550
        try {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   551
            File f = new File(filename);
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   552
            if (f.exists()) {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   553
                List<String> lines = Files.readAllLines(f.toPath());
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   554
                for (String line : lines) {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   555
                    String [] qsplit;
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   556
                    String quote = "\"";
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   557
                    if (line.contains("\"")) {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   558
                        qsplit = line.split("\"");
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   559
                    } else {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   560
                        qsplit = line.split("\'");
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   561
                        quote = "\'";
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   562
                    }
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   563
                    for (int i=0; i<qsplit.length; i++) {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   564
                        // every other qsplit of line is a quoted string
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   565
                        if ((i & 1) == 0) {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   566
                            // non-quoted string - split by whitespace
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   567
                            String [] newargs = qsplit[i].split("\\s");
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   568
                            for (String newarg : newargs) {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   569
                                args.add(newarg);
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   570
                            }
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   571
                        } else {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   572
                            // quoted string - don't split by whitespace
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   573
                            args.add(qsplit[i]);
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   574
                        }
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   575
                    }
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   576
                } 
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   577
            } else {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   578
               Log.error("Can not find argument file: " + f);
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   579
            }
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   580
        } catch (IOException ioe) {
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   581
            Log.verbose(ioe.getMessage());
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   582
            Log.verbose(ioe);
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   583
        }
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   584
        return args;
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   585
    }
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   586
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   587
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   588
    public boolean processArguments() throws Exception {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   589
        try {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   590
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   591
            // init context of arguments
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   592
            CLIOptions.setContext(this);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   593
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   594
            // parse cmd line
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   595
            String arg;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   596
            CLIOptions option;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   597
            for (; CLIOptions.hasNextArg(); CLIOptions.nextArg()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   598
                arg = CLIOptions.getArg();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   599
                if ((option = toCLIOption(arg)) != null) {
57060
5103d6d2e796 8213385: jpackager Command-Line Argument File.
herrick
parents: 57059
diff changeset
   600
                    // found a CLI option
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   601
                    allOptions.add(option);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   602
                    option.execute();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   603
                } else {
57065
2446962c555c 8214982: jpackage causes failures in existing HelpFlagsTest and VersionCheck tests
herrick
parents: 57062
diff changeset
   604
                    Log.error("invalid option ["+arg+"]");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   605
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   606
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   607
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   608
            if (allOptions.isEmpty() || !allOptions.get(0).isMode()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   609
                // first argument should always be a mode.
57020
a828547f7e50 8213394: Stop using Log.info() except for expected output.
herrick
parents: 57017
diff changeset
   610
                Log.error("ERROR: Mode is not specified");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   611
                return false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   612
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   613
56882
0ec8559f599a 8210439: Unable to create an installer from a previously created app image on Windows
herrick
parents: 56869
diff changeset
   614
            if (!hasAppImage && !hasMainJar && !hasMainModule &&
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   615
                    !hasMainClass && !jreInstaller) {
57020
a828547f7e50 8213394: Stop using Log.info() except for expected output.
herrick
parents: 57017
diff changeset
   616
                Log.error("ERROR: Main jar, main class, main module, "
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56958
diff changeset
   617
                        + "or app-image must be specified.");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   618
            } else if (!hasMainModule && !hasMainClass) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   619
                // try to get main-class from manifest
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   620
                String mainClass = getMainClassFromManifest();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   621
                if (mainClass != null) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   622
                    CLIOptions.setOptionValue(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   623
                            CLIOptions.APPCLASS.getId(), mainClass);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   624
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   625
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   626
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   627
            // display warning for arguments that are not supported
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   628
            // for current configuration.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   629
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   630
            validateArguments();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   631
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   632
            addResources(deployParams, input, files);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   633
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   634
            deployParams.setBundleType(bundleType);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   635
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   636
            List<Map<String, ? super Object>> launchersAsMap =
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   637
                    new ArrayList<>();
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   638
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   639
            for (SecondaryLauncherArguments sl : secondaryLaunchers) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   640
                launchersAsMap.add(sl.getLauncherMap());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   641
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   642
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   643
            deployParams.addBundleArgument(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   644
                    StandardBundlerParam.SECONDARY_LAUNCHERS.getID(),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   645
                    launchersAsMap);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   646
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   647
            // at this point deployParams should be already configured
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   648
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   649
            deployParams.validate();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   650
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   651
            BundleParams bp = deployParams.getBundleParams();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   652
56958
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   653
            // validate name(s)
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   654
            ArrayList<String> usedNames = new ArrayList<String>();
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   655
            usedNames.add(bp.getName()); // add main app name
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   656
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   657
            for (SecondaryLauncherArguments sl : secondaryLaunchers) {
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   658
                Map<String, ? super Object> slMap = sl.getLauncherMap();
56987
0d2ff0d6bb94 8211297: --verbose does not work with jpackager
herrick
parents: 56982
diff changeset
   659
                String slName =
56958
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   660
                        (String) slMap.get(Arguments.CLIOptions.NAME.getId());
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   661
                if (slName == null) {
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   662
                    throw new PackagerException("ERR_NoSecondaryLauncherName");
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   663
                } else {
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   664
                    for (String usedName : usedNames) {
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   665
                        if (slName.equals(usedName)) {
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   666
                            throw new PackagerException("ERR_NoUniqueName");
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   667
                        }
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   668
                    }
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   669
                }
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   670
                usedNames.add(slName);
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   671
            }
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   672
            if (jreInstaller && bp.getName() == null) {
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   673
                throw new PackagerException("ERR_NoJreInstallerName");
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   674
            }
8880b21d458d 8208578: Need to improve error handling of mandatory arguments
herrick
parents: 56957
diff changeset
   675
57062
044e7a644ee3 8214575: Exe installers will install application to already existing instalation
herrick
parents: 57060
diff changeset
   676
            return generateBundle(bp.getBundleParamsAsMap());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   677
        } catch (Exception e) {
56987
0d2ff0d6bb94 8211297: --verbose does not work with jpackager
herrick
parents: 56982
diff changeset
   678
            if (Log.isVerbose()) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   679
                throw e;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   680
            } else {
57022
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57021
diff changeset
   681
                Log.error(e.getMessage());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   682
                if (e.getCause() != null && e.getCause() != e) {
57022
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57021
diff changeset
   683
                    Log.error(e.getCause().getMessage());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   684
                }
57022
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57021
diff changeset
   685
                return false;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   686
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   687
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   688
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   689
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   690
    private void validateArguments() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   691
        CLIOptions mode = allOptions.get(0);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   692
        for (CLIOptions option : allOptions) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   693
            if(!ValidOptions.checkIfSupported(mode, option)) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   694
              System.out.println("WARNING: argument ["
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   695
                      + option.getId() + "] is not "
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   696
                      + "supported for current configuration.");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   697
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   698
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   699
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   700
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57038
diff changeset
   701
    private List<jdk.jpackage.internal.Bundler> getPlatformBundlers() {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   702
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   703
        if (platformBundlers != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   704
            return platformBundlers;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   705
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   706
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   707
        platformBundlers = new ArrayList<>();
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57038
diff changeset
   708
        for (jdk.jpackage.internal.Bundler bundler :
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   709
                Bundlers.createBundlersInstance().getBundlers(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   710
                        bundleType.toString())) {
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   711
            if (hasTargetFormat && deployParams.getTargetFormat() != null &&
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   712
                    !deployParams.getTargetFormat().equalsIgnoreCase(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   713
                    bundler.getID())) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   714
                continue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   715
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   716
            if (bundler.supported()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   717
                 platformBundlers.add(bundler);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   718
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   719
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   720
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   721
        return platformBundlers;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   722
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   723
57062
044e7a644ee3 8214575: Exe installers will install application to already existing instalation
herrick
parents: 57060
diff changeset
   724
    private boolean generateBundle(Map<String,? super Object> params)
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   725
            throws PackagerException {
57062
044e7a644ee3 8214575: Exe installers will install application to already existing instalation
herrick
parents: 57060
diff changeset
   726
        boolean bundleCreated = false;
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   727
        File imageDir = null;
57062
044e7a644ee3 8214575: Exe installers will install application to already existing instalation
herrick
parents: 57060
diff changeset
   728
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57038
diff changeset
   729
        for (jdk.jpackage.internal.Bundler bundler : getPlatformBundlers()) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   730
            Map<String, ? super Object> localParams = new HashMap<>(params);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   731
            try {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   732
                if (bundler.validate(localParams)) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   733
                    File result =
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   734
                            bundler.execute(localParams, deployParams.outdir);
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   735
                    if (!retainBuildRoot) {
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   736
                        bundler.cleanup(localParams);
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   737
                    }
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   738
                    if (result == null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   739
                        throw new PackagerException("MSG_BundlerFailed",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   740
                                bundler.getID(), bundler.getName());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   741
                    }
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   742
                    bundleCreated = true; // at least one bundle was created
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   743
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   744
            } catch (UnsupportedPlatformException e) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   745
                Log.debug(MessageFormat.format(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   746
                        I18N.getString("MSG_BundlerPlatformException"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   747
                        bundler.getName()));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   748
            } catch (ConfigException e) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   749
                Log.debug(e);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   750
                if (e.getAdvice() != null) {
57020
a828547f7e50 8213394: Stop using Log.info() except for expected output.
herrick
parents: 57017
diff changeset
   751
                    Log.error(MessageFormat.format(
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   752
                            I18N.getString("MSG_BundlerConfigException"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   753
                            bundler.getName(), e.getMessage(), e.getAdvice()));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   754
                } else {
57020
a828547f7e50 8213394: Stop using Log.info() except for expected output.
herrick
parents: 57017
diff changeset
   755
                    Log.error(MessageFormat.format(I18N.getString(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   756
                            "MSG_BundlerConfigExceptionNoAdvice"),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   757
                            bundler.getName(), e.getMessage()));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   758
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   759
            } catch (RuntimeException re) {
57020
a828547f7e50 8213394: Stop using Log.info() except for expected output.
herrick
parents: 57017
diff changeset
   760
                Log.error(MessageFormat.format(
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   761
                        I18N.getString("MSG_BundlerRuntimeException"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   762
                        bundler.getName(), re.toString()));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   763
                Log.debug(re);
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   764
            } finally {
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   765
                if (retainBuildRoot) {
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   766
                    Log.verbose(MessageFormat.format(
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   767
                            I18N.getString("message.debug-working-directory"),
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   768
                            (new File(buildRoot)).getAbsolutePath()));
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   769
                }
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   770
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   771
        }
57062
044e7a644ee3 8214575: Exe installers will install application to already existing instalation
herrick
parents: 57060
diff changeset
   772
044e7a644ee3 8214575: Exe installers will install application to already existing instalation
herrick
parents: 57060
diff changeset
   773
        return bundleCreated;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   774
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   775
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
   776
    private void addResources(DeployParams deployParams,
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   777
            String inputdir, List<String> inputfiles) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   778
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   779
        if (inputdir == null || inputdir.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   780
            return;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   781
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   782
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   783
        File baseDir = new File(inputdir);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   784
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   785
        if (!baseDir.isDirectory()) {
57020
a828547f7e50 8213394: Stop using Log.info() except for expected output.
herrick
parents: 57017
diff changeset
   786
            Log.error(
57096
d06bec27f8c9 8215903: modify behavior of retaining temporary output dir
herrick
parents: 57091
diff changeset
   787
                    "Unable to add resources: \"--input\" is not a directory.");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   788
            return;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   789
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   790
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   791
        List<String> fileNames;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   792
        if (inputfiles != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   793
            fileNames = inputfiles;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   794
        } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   795
            // "-files" is omitted, all files in input cdir (which
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   796
            // is a mandatory argument in this case) will be packaged.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   797
            fileNames = new ArrayList<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   798
            try (Stream<Path> files = Files.list(baseDir.toPath())) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   799
                files.forEach(file -> fileNames.add(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56836
diff changeset
   800
                        file.getFileName().toString()));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   801
            } catch (IOException e) {
57020
a828547f7e50 8213394: Stop using Log.info() except for expected output.
herrick
parents: 57017
diff changeset
   802
                Log.error("Unable to add resources: " + e.getMessage());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   803
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   804
        }
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
   805
        fileNames.forEach(file -> deployParams.addResource(baseDir, file));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   806
57097
6e5eb7855fe2 8215900: Without --files args, only jars in the top level of --input are added to class-path
herrick
parents: 57096
diff changeset
   807
        deployParams.setClasspath();
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   808
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   809
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57065
diff changeset
   810
    static boolean isCLIOption(String arg) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   811
        return toCLIOption(arg) != null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   812
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   813
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57065
diff changeset
   814
    static CLIOptions toCLIOption(String arg) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   815
        CLIOptions option;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   816
        if ((option = argIds.get(arg)) == null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   817
            option = argShortIds.get(arg);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   818
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   819
        return option;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   820
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   822
    static Map<String, String> getArgumentMap(String inputString) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   823
        Map<String, String> map = new HashMap<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   824
        List<String> list = getArgumentList(inputString);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   825
        for (String pair : list) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   826
            int equals = pair.indexOf("=");
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   827
            if (equals != -1) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   828
                String key = pair.substring(0, equals);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   829
                String value = pair.substring(equals+1, pair.length());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   830
                map.put(key, value);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   831
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   832
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   833
        return map;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   834
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   835
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   836
    static Map<String, String> getPropertiesFromFile(String filename) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   837
        Map<String, String> map = new HashMap<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   838
        // load properties file
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   839
        File file = new File(filename);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   840
        Properties properties = new Properties();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   841
        try (FileInputStream in = new FileInputStream(file)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   842
            properties.load(in);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   843
        } catch (IOException e) {
57020
a828547f7e50 8213394: Stop using Log.info() except for expected output.
herrick
parents: 57017
diff changeset
   844
            Log.error("Exception: " + e.getMessage());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   845
        }
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   846
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   847
        for (final String name: properties.stringPropertyNames()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   848
            map.put(name, properties.getProperty(name));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   849
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   850
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   851
        return map;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   852
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   853
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   854
    static List<String> getArgumentList(String inputString) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   855
        List<String> list = new ArrayList<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   856
        if (inputString == null || inputString.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   857
             return list;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   858
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   859
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   860
        // The "pattern" regexp attempts to abide to the rule that
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   861
        // strings are delimited by whitespace unless surrounded by
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   862
        // quotes, then it is anything (including spaces) in the quotes.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   863
        Matcher m = pattern.matcher(inputString);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   864
        while (m.find()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   865
            String s = inputString.substring(m.start(), m.end()).trim();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   866
            // Ensure we do not have an empty string. trim() will take care of
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   867
            // whitespace only strings. The regex preserves quotes and escaped
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   868
            // chars so we need to clean them before adding to the List
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   869
            if (!s.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   870
                list.add(unquoteIfNeeded(s));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   871
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   872
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   873
        return list;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   874
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   875
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   876
    private static String unquoteIfNeeded(String in) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   877
        if (in == null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   878
            return null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   879
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   880
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   881
        if (in.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   882
            return "";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   883
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   884
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   885
        // Use code points to preserve non-ASCII chars
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   886
        StringBuilder sb = new StringBuilder();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   887
        int codeLen = in.codePointCount(0, in.length());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   888
        int quoteChar = -1;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   889
        for (int i = 0; i < codeLen; i++) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   890
            int code = in.codePointAt(i);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   891
            if (code == '"' || code == '\'') {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   892
                // If quote is escaped make sure to copy it
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   893
                if (i > 0 && in.codePointAt(i - 1) == '\\') {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   894
                    sb.deleteCharAt(sb.length() - 1);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   895
                    sb.appendCodePoint(code);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   896
                    continue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   897
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   898
                if (quoteChar != -1) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   899
                    if (code == quoteChar) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   900
                        // close quote, skip char
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   901
                        quoteChar = -1;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   902
                    } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   903
                        sb.appendCodePoint(code);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   904
                    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   905
                } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   906
                    // opening quote, skip char
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   907
                    quoteChar = code;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   908
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   909
            } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   910
                sb.appendCodePoint(code);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   911
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   912
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   913
        return sb.toString();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   914
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   915
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   916
    private String getMainClassFromManifest() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   917
        if (mainJarPath == null ||
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   918
            input == null ) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   919
            return null;
56957
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   920
        }
2f01969ed7cb 8211299: Output of System.out is not printed to CMD on Windows
herrick
parents: 56933
diff changeset
   921
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   922
        JarFile jf;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   923
        try {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   924
            File file = new File(input, mainJarPath);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   925
            if (!file.exists()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   926
                return null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   927
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   928
            jf = new JarFile(file);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   929
            Manifest m = jf.getManifest();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   930
            Attributes attrs = (m != null) ? m.getMainAttributes() : null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   931
            if (attrs != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   932
                return attrs.getValue(Attributes.Name.MAIN_CLASS);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   933
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   934
        } catch (IOException ignore) {}
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   935
        return null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   936
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   937
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57065
diff changeset
   938
    static boolean isJreInstaller() {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   939
        return jreInstaller;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   940
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   941
}