src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java
author herrick
Thu, 28 Mar 2019 13:47:40 -0400
branchJDK-8200758-branch
changeset 57291 f2d429260ad4
parent 57256 d7c27451f759
child 57314 23da9e6f446f
permissions -rw-r--r--
8221582: Rename jvm-args option to java-options Reviewed-by: kbr, ssadetski
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
/*
57106
ea870b9ce89a 8216492: Update copyright of all new jpackage fils to 2019
kcr
parents: 57103
diff changeset
     2
 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
56821
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
 */
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    25
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57038
diff changeset
    26
package jdk.jpackage.internal;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    27
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57038
diff changeset
    28
import jdk.jpackage.internal.BundleParams;
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57038
diff changeset
    29
import jdk.jpackage.internal.AbstractAppImageBuilder;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    30
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    31
import java.io.File;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    32
import java.io.IOException;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    33
import java.io.StringReader;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    34
import java.nio.file.Files;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    35
import java.nio.file.Path;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    36
import java.nio.file.Paths;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    37
import java.text.MessageFormat;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    38
import java.util.ArrayList;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    39
import java.util.Arrays;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    40
import java.util.Collections;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    41
import java.util.Date;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    42
import java.util.HashMap;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    43
import java.util.HashSet;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    44
import java.util.LinkedHashSet;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    45
import java.util.List;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    46
import java.util.Map;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    47
import java.util.Optional;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    48
import java.util.Properties;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    49
import java.util.ResourceBundle;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    50
import java.util.Set;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    51
import java.util.HashSet;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    52
import java.util.function.BiFunction;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    53
import java.util.function.Function;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    54
import java.util.jar.Attributes;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    55
import java.util.jar.JarFile;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    56
import java.util.jar.Manifest;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    57
import java.util.regex.Pattern;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    58
import java.util.stream.Collectors;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    59
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    60
/**
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
    61
 * StandardBundlerParam
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    62
 *
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    63
 * A parameter to a bundler.
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    64
 *
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    65
 * Also contains static definitions of all of the common bundler parameters.
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    66
 * (additional platform specific and mode specific bundler parameters
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    67
 * are defined in each of the specific bundlers)
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    68
 *
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    69
 * Also contains static methods that operate on maps of parameters.
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56989
diff changeset
    70
 */
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
    71
class StandardBundlerParam<T> extends BundlerParamInfo<T> {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    72
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
    73
    private static final ResourceBundle I18N = ResourceBundle.getBundle(
57059
9bb2a4dc3af7 8214143: Reduce Resource files
herrick
parents: 57039
diff changeset
    74
            "jdk.jpackage.internal.resources.MainResources");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    75
    private static final String JAVABASEJMOD = "java.base.jmod";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    76
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
    77
    StandardBundlerParam(String id, Class<T> valueType,
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
    78
            Function<Map<String, ? super Object>, T> defaultValueFunction,
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
    79
            BiFunction<String, Map<String, ? super Object>, T> stringConverter)
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
    80
    {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    81
        this.id = id;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    82
        this.valueType = valueType;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    83
        this.defaultValueFunction = defaultValueFunction;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    84
        this.stringConverter = stringConverter;
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
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
    87
    static final StandardBundlerParam<RelativeFileSet> APP_RESOURCES =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    88
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    89
                    BundleParams.PARAM_APP_RESOURCES,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    90
                    RelativeFileSet.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    91
                    null, // no default.  Required parameter
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
    92
                    null  // no string translation,
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
    93
                          // tool must provide complex type
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    94
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    95
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    96
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
    97
    static final
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
    98
            StandardBundlerParam<List<RelativeFileSet>> APP_RESOURCES_LIST =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    99
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   100
                    BundleParams.PARAM_APP_RESOURCES + "List",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   101
                    (Class<List<RelativeFileSet>>) (Object) List.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   102
                    // Default is appResources, as a single item list
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   103
                    p -> new ArrayList<>(Collections.singletonList(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   104
                            APP_RESOURCES.fetchFrom(p))),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   105
                    StandardBundlerParam::createAppResourcesListFromString
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   106
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   107
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   108
    static final StandardBundlerParam<String> SOURCE_DIR =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   109
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   110
                    Arguments.CLIOptions.INPUT.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   111
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   112
                    p -> null,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   113
                    (s, p) -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   114
                        String value = String.valueOf(s);
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   115
                        if (value.charAt(value.length() - 1) ==
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   116
                                File.separatorChar) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   117
                            return value.substring(0, value.length() - 1);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   118
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   119
                        else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   120
                            return value;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   121
                        }
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
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   124
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   125
    // note that each bundler is likely to replace this one with
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   126
    // their own converter
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   127
    static final StandardBundlerParam<RelativeFileSet> MAIN_JAR =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   128
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   129
                    Arguments.CLIOptions.MAIN_JAR.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   130
                    RelativeFileSet.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   131
                    params -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   132
                        extractMainClassInfoFromAppResources(params);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   133
                        return (RelativeFileSet) params.get("mainJar");
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   134
                    },
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   135
                    (s, p) -> getMainJar(s, p)
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
56989
0f19096663d1 8212625: Remove --echo-mode and related code
herrick
parents: 56982
diff changeset
   138
    // TODO: test CLASSPATH jar manifest Attributet
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   139
    static final StandardBundlerParam<String> CLASSPATH =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   140
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   141
                    "classpath",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   142
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   143
                    params -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   144
                        extractMainClassInfoFromAppResources(params);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   145
                        String cp = (String) params.get("classpath");
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   146
                        return cp == null ? "" : cp;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   147
                    },
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   148
                    (s, p) -> s.replace(File.pathSeparator, " ")
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   149
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   150
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   151
    static final StandardBundlerParam<String> MAIN_CLASS =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   152
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   153
                    Arguments.CLIOptions.APPCLASS.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   154
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   155
                    params -> {
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   156
                        if (isRuntimeInstaller(params)) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   157
                            return null;
56989
0f19096663d1 8212625: Remove --echo-mode and related code
herrick
parents: 56982
diff changeset
   158
                        }
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   159
                        extractMainClassInfoFromAppResources(params);
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   160
                        String s = (String) params.get(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   161
                                BundleParams.PARAM_APPLICATION_CLASS);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   162
                        if (s == null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   163
                            s = JLinkBundlerHelper.getMainClass(params);
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
                        return s;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   166
                    },
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   167
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   168
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   169
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   170
    static final StandardBundlerParam<String> APP_NAME =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   171
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   172
                    Arguments.CLIOptions.NAME.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   173
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   174
                    params -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   175
                        String s = MAIN_CLASS.fetchFrom(params);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   176
                        if (s == null) return null;
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
                        int idx = s.lastIndexOf(".");
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   179
                        if (idx >= 0) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   180
                            return s.substring(idx+1);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   181
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   182
                        return s;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   183
                    },
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   184
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   185
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   186
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   187
    static final StandardBundlerParam<File> ICON =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   188
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   189
                    Arguments.CLIOptions.ICON.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   190
                    File.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   191
                    params -> null,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   192
                    (s, p) -> new File(s)
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
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   195
    static final StandardBundlerParam<String> VENDOR =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   196
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   197
                    Arguments.CLIOptions.VENDOR.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   198
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   199
                    params -> I18N.getString("param.vendor.default"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   200
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   201
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   202
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   203
    static final StandardBundlerParam<String> DESCRIPTION =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   204
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   205
                    Arguments.CLIOptions.DESCRIPTION.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   206
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   207
                    params -> params.containsKey(APP_NAME.getID())
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   208
                            ? APP_NAME.fetchFrom(params)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   209
                            : I18N.getString("param.description.default"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   210
                    (s, p) -> s
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
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   213
    static final StandardBundlerParam<String> COPYRIGHT =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   214
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   215
                    Arguments.CLIOptions.COPYRIGHT.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   216
                    String.class,
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   217
                    params -> MessageFormat.format(I18N.getString(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   218
                            "param.copyright.default"), new Date()),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   219
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   220
            );
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
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   223
    static final StandardBundlerParam<List<String>> ARGUMENTS =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   224
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   225
                    Arguments.CLIOptions.ARGUMENTS.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   226
                    (Class<List<String>>) (Object) List.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   227
                    params -> Collections.emptyList(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   228
                    (s, p) -> splitStringWithEscapes(s)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   229
            );
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
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   232
    static final StandardBundlerParam<List<String>> JVM_OPTIONS =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   233
            new StandardBundlerParam<>(
57291
f2d429260ad4 8221582: Rename jvm-args option to java-options
herrick
parents: 57256
diff changeset
   234
                    Arguments.CLIOptions.JAVA_OPTIONS.getId(),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   235
                    (Class<List<String>>) (Object) List.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   236
                    params -> Collections.emptyList(),
56835
43caa6ff671a 8207022: jpackager saves VM args incorrectly if --jvm-args contains white spaces
herrick
parents: 56829
diff changeset
   237
                    (s, p) -> Arrays.asList(s.split("\n\n"))
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   238
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   239
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   240
    // note that each bundler is likely to replace this one with
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   241
    // their own converter
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   242
    static final StandardBundlerParam<String> VERSION =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   243
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   244
                    Arguments.CLIOptions.VERSION.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   245
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   246
                    params -> I18N.getString("param.version.default"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   247
                    (s, p) -> s
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   250
    @SuppressWarnings("unchecked")
57080
bd4ce7f9ea2c 8214495: Change behavior of --license-file
herrick
parents: 57078
diff changeset
   251
    public static final StandardBundlerParam<String> LICENSE_FILE =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   252
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   253
                    Arguments.CLIOptions.LICENSE_FILE.getId(),
57080
bd4ce7f9ea2c 8214495: Change behavior of --license-file
herrick
parents: 57078
diff changeset
   254
                    String.class,
bd4ce7f9ea2c 8214495: Change behavior of --license-file
herrick
parents: 57078
diff changeset
   255
                    params -> null,
bd4ce7f9ea2c 8214495: Change behavior of --license-file
herrick
parents: 57078
diff changeset
   256
                    (s, p) -> s
56821
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
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   259
    static final StandardBundlerParam<File> TEMP_ROOT =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   260
            new StandardBundlerParam<>(
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   261
                    Arguments.CLIOptions.TEMP_ROOT.getId(),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   262
                    File.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   263
                    params -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   264
                        try {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   265
                            return Files.createTempDirectory(
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57038
diff changeset
   266
                                    "jdk.jpackage").toFile();
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   267
                        } catch (IOException ioe) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   268
                            return null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   269
                        }
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
                    (s, p) -> new File(s)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   272
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   273
57103
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   274
    public static final StandardBundlerParam<File> CONFIG_ROOT =
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   275
            new StandardBundlerParam<>(
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   276
                "configRoot",
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   277
                File.class,
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   278
                params -> {
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   279
                    File root =
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   280
                            new File(TEMP_ROOT.fetchFrom(params), "config");
57103
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   281
                    root.mkdirs();
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   282
                    return root;
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   283
                },
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   284
                (s, p) -> null
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   285
            );
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   286
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   287
    static final StandardBundlerParam<String> IDENTIFIER =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   288
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   289
                    Arguments.CLIOptions.IDENTIFIER.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   290
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   291
                    params -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   292
                        String s = MAIN_CLASS.fetchFrom(params);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   293
                        if (s == null) return null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   294
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   295
                        int idx = s.lastIndexOf(".");
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   296
                        if (idx >= 1) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   297
                            return s.substring(0, idx);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   298
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   299
                        return s;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   300
                    },
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   301
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   302
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   303
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   304
    static final StandardBundlerParam<String> PREFERENCES_ID =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   305
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   306
                    "preferencesID",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   307
                    String.class,
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   308
                    p -> Optional.ofNullable(IDENTIFIER.fetchFrom(p)).
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   309
                             orElse("").replace('.', '/'),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   310
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   311
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   312
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   313
    static final StandardBundlerParam<Boolean> VERBOSE  =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   314
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   315
                    Arguments.CLIOptions.VERBOSE.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   316
                    Boolean.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   317
                    params -> false,
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   318
                    // valueOf(null) is false, and we actually do want null
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   319
                    (s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   320
                            true : Boolean.valueOf(s)
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   321
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   322
57091
06bc4bd64599 8215515: Add a command line option to override internal resources.
herrick
parents: 57080
diff changeset
   323
    static final StandardBundlerParam<File> RESOURCE_DIR =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   324
            new StandardBundlerParam<>(
57091
06bc4bd64599 8215515: Add a command line option to override internal resources.
herrick
parents: 57080
diff changeset
   325
                    Arguments.CLIOptions.RESOURCE_DIR.getId(),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   326
                    File.class,
57091
06bc4bd64599 8215515: Add a command line option to override internal resources.
herrick
parents: 57080
diff changeset
   327
                    params -> null,
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   328
                    (s, p) -> new File(s)
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
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   331
    static final BundlerParamInfo<String> INSTALL_DIR =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   332
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   333
                    Arguments.CLIOptions.INSTALL_DIR.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   334
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   335
                     params -> null,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   336
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   337
    );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   338
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   339
    static final StandardBundlerParam<File> PREDEFINED_APP_IMAGE =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   340
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   341
            Arguments.CLIOptions.PREDEFINED_APP_IMAGE.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   342
            File.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   343
            params -> null,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   344
            (s, p) -> new File(s));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   345
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   346
    static final StandardBundlerParam<File> PREDEFINED_RUNTIME_IMAGE =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   347
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   348
            Arguments.CLIOptions.PREDEFINED_RUNTIME_IMAGE.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   349
            File.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   350
            params -> null,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   351
            (s, p) -> new File(s));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   352
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   353
    @SuppressWarnings("unchecked")
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   354
    static final StandardBundlerParam<List<Map<String, ? super Object>>> ADD_LAUNCHERS =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   355
            new StandardBundlerParam<>(
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   356
                    Arguments.CLIOptions.ADD_LAUNCHER.getId(),
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   357
                    (Class<List<Map<String, ? super Object>>>) (Object)
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   358
                            List.class,
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   359
                    params -> new ArrayList<>(1),
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   360
                    // valueOf(null) is false, and we actually do want null
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   361
                    (s, p) -> null
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   362
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   363
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   364
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   365
    static final StandardBundlerParam
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   366
            <List<Map<String, ? super Object>>> FILE_ASSOCIATIONS =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   367
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   368
                    Arguments.CLIOptions.FILE_ASSOCIATIONS.getId(),
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   369
                    (Class<List<Map<String, ? super Object>>>) (Object)
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   370
                            List.class,
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   371
                    params -> new ArrayList<>(1),
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   372
                    // valueOf(null) is false, and we actually do want null
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   373
                    (s, p) -> null
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   376
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   377
    static final StandardBundlerParam<List<String>> FA_EXTENSIONS =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   378
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   379
                    "fileAssociation.extension",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   380
                    (Class<List<String>>) (Object) List.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   381
                    params -> null, // null means not matched to an extension
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   382
                    (s, p) -> Arrays.asList(s.split("(,|\\s)+"))
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   383
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   384
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   385
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   386
    static final StandardBundlerParam<List<String>> FA_CONTENT_TYPE =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   387
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   388
                    "fileAssociation.contentType",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   389
                    (Class<List<String>>) (Object) List.class,
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   390
                    params -> null,
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   391
                            // null means not matched to a content/mime type
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   392
                    (s, p) -> Arrays.asList(s.split("(,|\\s)+"))
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   393
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   394
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   395
    static final StandardBundlerParam<String> FA_DESCRIPTION =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   396
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   397
                    "fileAssociation.description",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   398
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   399
                    params -> APP_NAME.fetchFrom(params) + " File",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   400
                    null
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   401
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   402
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   403
    static final StandardBundlerParam<File> FA_ICON =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   404
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   405
                    "fileAssociation.icon",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   406
                    File.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   407
                    ICON::fetchFrom,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   408
                    (s, p) -> new File(s)
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   411
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   412
    static final BundlerParamInfo<List<Path>> MODULE_PATH =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   413
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   414
                    Arguments.CLIOptions.MODULE_PATH.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   415
                    (Class<List<Path>>) (Object)List.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   416
                    p -> { return getDefaultModulePath(); },
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   417
                    (s, p) -> {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   418
                        List<Path> modulePath = Arrays.asList(s
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   419
                                .split(File.pathSeparator)).stream()
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   420
                                .map(ss -> new File(ss).toPath())
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   421
                                .collect(Collectors.toList());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   422
                        Path javaBasePath = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   423
                        if (modulePath != null) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   424
                            javaBasePath = JLinkBundlerHelper
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   425
                                    .findPathOfModule(modulePath, JAVABASEJMOD);
57015
5d2008115309 JDK-8213244: Fix all warnings in jpackager java code
herrick
parents: 56994
diff changeset
   426
                        } else {
5d2008115309 JDK-8213244: Fix all warnings in jpackager java code
herrick
parents: 56994
diff changeset
   427
                            modulePath = new ArrayList<Path>();
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   428
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   429
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   430
                        // Add the default JDK module path to the module path.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   431
                        if (javaBasePath == null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   432
                            List<Path> jdkModulePath = getDefaultModulePath();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   433
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   434
                            if (jdkModulePath != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   435
                                modulePath.addAll(jdkModulePath);
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   436
                                javaBasePath =
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   437
                                        JLinkBundlerHelper.findPathOfModule(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   438
                                        modulePath, JAVABASEJMOD);
56821
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
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   441
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   442
                        if (javaBasePath == null ||
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   443
                                !Files.exists(javaBasePath)) {
57020
a828547f7e50 8213394: Stop using Log.info() except for expected output.
herrick
parents: 57017
diff changeset
   444
                            Log.error(String.format(I18N.getString(
a828547f7e50 8213394: Stop using Log.info() except for expected output.
herrick
parents: 57017
diff changeset
   445
                                    "warning.no.jdk.modules.found")));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   446
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   447
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   448
                        return modulePath;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   449
                    });
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   450
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   451
    static final BundlerParamInfo<String> MODULE =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   452
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   453
                    Arguments.CLIOptions.MODULE.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   454
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   455
                    p -> null,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   456
                    (s, p) -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   457
                        return String.valueOf(s);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   458
                    });
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   459
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   460
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   461
    static final BundlerParamInfo<Set<String>> ADD_MODULES =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   462
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   463
                    Arguments.CLIOptions.ADD_MODULES.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   464
                    (Class<Set<String>>) (Object) Set.class,
57015
5d2008115309 JDK-8213244: Fix all warnings in jpackager java code
herrick
parents: 56994
diff changeset
   465
                    p -> new LinkedHashSet<String>(),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   466
                    (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split(",")))
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   467
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   468
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   469
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   470
    static final BundlerParamInfo<Set<String>> LIMIT_MODULES =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   471
            new StandardBundlerParam<>(
57150
fa68c2ab636d 8217894: jpackage CLI syntax changes
herrick
parents: 57119
diff changeset
   472
                    "limit-modules",
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   473
                    (Class<Set<String>>) (Object) Set.class,
57015
5d2008115309 JDK-8213244: Fix all warnings in jpackager java code
herrick
parents: 56994
diff changeset
   474
                    p -> new LinkedHashSet<String>(),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   475
                    (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split(",")))
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
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   478
    static boolean isRuntimeInstaller(Map<String, ? super Object> p) {
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   479
        if (p.containsKey(MODULE.getID()) ||
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   480
                p.containsKey(MAIN_JAR.getID()) ||
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   481
                p.containsKey(PREDEFINED_APP_IMAGE.getID())) {
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   482
            return false; // we are building or are given an application
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   483
        }
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   484
        // runtime installer requires --runtime-image, if this is false
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   485
        // here then we should have thrown error validating args.
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   486
        return p.containsKey(PREDEFINED_RUNTIME_IMAGE.getID());
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   487
    }
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   488
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   489
    static File getPredefinedAppImage(Map<String, ? super Object> p) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   490
        File applicationImage = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   491
        if (PREDEFINED_APP_IMAGE.fetchFrom(p) != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   492
            applicationImage = PREDEFINED_APP_IMAGE.fetchFrom(p);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   493
            Log.debug("Using App Image from " + applicationImage);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   494
            if (!applicationImage.exists()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   495
                throw new RuntimeException(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   496
                        MessageFormat.format(I18N.getString(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   497
                                "message.app-image-dir-does-not-exist"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   498
                                PREDEFINED_APP_IMAGE.getID(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   499
                                applicationImage.toString()));
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
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   502
        return applicationImage;
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
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   505
    static void copyPredefinedRuntimeImage(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   506
            Map<String, ? super Object> p,
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   507
            AbstractAppImageBuilder appBuilder)
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   508
            throws IOException , ConfigException {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   509
        File image = PREDEFINED_RUNTIME_IMAGE.fetchFrom(p);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   510
        if (!image.exists()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   511
            throw new ConfigException(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   512
                    MessageFormat.format(I18N.getString(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   513
                    "message.runtime-image-dir-does-not-exist"),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   514
                    PREDEFINED_RUNTIME_IMAGE.getID(),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   515
                    image.toString()),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   516
                    MessageFormat.format(I18N.getString(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   517
                    "message.runtime-image-dir-does-not-exist.advice"),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   518
                    PREDEFINED_RUNTIME_IMAGE.getID()));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   519
        }
57077
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   520
        // copy whole runtime, need to skip jmods and src.zip
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   521
        final List<String> excludes = Arrays.asList("jmods", "src.zip");
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   522
        IOUtils.copyRecursive(image.toPath(), appBuilder.getRoot(), excludes);
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   523
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   524
        // if module-path given - copy modules to appDir/mods
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   525
        List<Path> modulePath =
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   526
                StandardBundlerParam.MODULE_PATH.fetchFrom(p);
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   527
        List<Path> defaultModulePath = getDefaultModulePath();
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   528
        Path dest = appBuilder.getAppModsDir();
57108
f1c13cb0e713 8217269: jpackage Makefile improvments
herrick
parents: 57106
diff changeset
   529
57077
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   530
        if (dest != null) {
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   531
            for (Path mp : modulePath) {
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   532
                if (!defaultModulePath.contains(mp)) {
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   533
                    Files.createDirectories(dest);
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   534
                    IOUtils.copyRecursive(mp, dest);
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   535
                }
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   536
            }
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   537
        }
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   538
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   539
        appBuilder.prepareApplicationFiles();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   540
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   541
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   542
    static void extractMainClassInfoFromAppResources(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   543
            Map<String, ? super Object> params) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   544
        boolean hasMainClass = params.containsKey(MAIN_CLASS.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   545
        boolean hasMainJar = params.containsKey(MAIN_JAR.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   546
        boolean hasMainJarClassPath = params.containsKey(CLASSPATH.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   547
        boolean hasModule = params.containsKey(MODULE.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   548
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   549
        if (hasMainClass && hasMainJar && hasMainJarClassPath || hasModule ||
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   550
                isRuntimeInstaller(params)) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   551
            return;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   552
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   553
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   554
        // it's a pair.
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   555
        // The [0] is the srcdir [1] is the file relative to sourcedir
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   556
        List<String[]> filesToCheck = new ArrayList<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   557
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   558
        if (hasMainJar) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   559
            RelativeFileSet rfs = MAIN_JAR.fetchFrom(params);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   560
            for (String s : rfs.getIncludedFiles()) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   561
                filesToCheck.add(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   562
                        new String[] {rfs.getBaseDirectory().toString(), s});
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   563
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   564
        } else if (hasMainJarClassPath) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   565
            for (String s : CLASSPATH.fetchFrom(params).split("\\s+")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   566
                if (APP_RESOURCES.fetchFrom(params) != null) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   567
                    filesToCheck.add(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   568
                            new String[] {APP_RESOURCES.fetchFrom(params)
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   569
                            .getBaseDirectory().toString(), s});
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   570
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   571
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   572
        } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   573
            List<RelativeFileSet> rfsl = APP_RESOURCES_LIST.fetchFrom(params);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   574
            if (rfsl == null || rfsl.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   575
                return;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   576
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   577
            for (RelativeFileSet rfs : rfsl) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   578
                if (rfs == null) continue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   579
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   580
                for (String s : rfs.getIncludedFiles()) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   581
                    filesToCheck.add(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   582
                            new String[]{rfs.getBaseDirectory().toString(), s});
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   583
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   584
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   585
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   586
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   587
        // presume the set iterates in-order
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   588
        for (String[] fnames : filesToCheck) {
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
                // only sniff jars
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   591
                if (!fnames[1].toLowerCase().endsWith(".jar")) continue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   592
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   593
                File file = new File(fnames[0], fnames[1]);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   594
                // that actually exist
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   595
                if (!file.exists()) continue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   596
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   597
                try (JarFile jf = new JarFile(file)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   598
                    Manifest m = jf.getManifest();
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   599
                    Attributes attrs = (m != null) ?
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   600
                            m.getMainAttributes() : null;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   601
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   602
                    if (attrs != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   603
                        if (!hasMainJar) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   604
                            if (fnames[0] == null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   605
                                fnames[0] = file.getParentFile().toString();
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
                            params.put(MAIN_JAR.getID(), new RelativeFileSet(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   608
                                    new File(fnames[0]),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   609
                                    new LinkedHashSet<>(Collections
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   610
                                    .singletonList(file))));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   611
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   612
                        if (!hasMainJarClassPath) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   613
                            String cp =
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   614
                                    attrs.getValue(Attributes.Name.CLASS_PATH);
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   615
                            params.put(CLASSPATH.getID(),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   616
                                    cp == null ? "" : cp);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   617
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   618
                        break;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   619
                    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   620
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   621
            } catch (IOException ignore) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   622
                ignore.printStackTrace();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   623
            }
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
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   627
    static void validateMainClassInfoFromAppResources(
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   628
            Map<String, ? super Object> params) throws ConfigException {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   629
        boolean hasMainClass = params.containsKey(MAIN_CLASS.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   630
        boolean hasMainJar = params.containsKey(MAIN_JAR.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   631
        boolean hasMainJarClassPath = params.containsKey(CLASSPATH.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   632
        boolean hasModule = params.containsKey(MODULE.getID());
56882
0ec8559f599a 8210439: Unable to create an installer from a previously created app image on Windows
herrick
parents: 56869
diff changeset
   633
        boolean hasAppImage = params.containsKey(PREDEFINED_APP_IMAGE.getID());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   634
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   635
        if (hasMainClass && hasMainJar && hasMainJarClassPath ||
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   636
               hasModule || hasAppImage || isRuntimeInstaller(params)) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   637
            return;
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   640
        extractMainClassInfoFromAppResources(params);
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
        if (!params.containsKey(MAIN_CLASS.getID())) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   643
            if (hasMainJar) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   644
                throw new ConfigException(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   645
                        MessageFormat.format(I18N.getString(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   646
                        "error.no-main-class-with-main-jar"),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   647
                        MAIN_JAR.fetchFrom(params)),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   648
                        MessageFormat.format(I18N.getString(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   649
                        "error.no-main-class-with-main-jar.advice"),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   650
                        MAIN_JAR.fetchFrom(params)));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   651
            } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   652
                throw new ConfigException(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   653
                        I18N.getString("error.no-main-class"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   654
                        I18N.getString("error.no-main-class.advice"));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   655
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   656
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   657
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   658
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   659
    private static List<String> splitStringWithEscapes(String s) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   660
        List<String> l = new ArrayList<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   661
        StringBuilder current = new StringBuilder();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   662
        boolean quoted = false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   663
        boolean escaped = false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   664
        for (char c : s.toCharArray()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   665
            if (escaped) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   666
                current.append(c);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   667
            } else if ('"' == c) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   668
                quoted = !quoted;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   669
            } else if (!quoted && Character.isWhitespace(c)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   670
                l.add(current.toString());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   671
                current = new StringBuilder();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   672
            } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   673
                current.append(c);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   674
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   675
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   676
        l.add(current.toString());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   677
        return l;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   678
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   679
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   680
    private static List<RelativeFileSet>
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   681
            createAppResourcesListFromString(String s,
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   682
            Map<String, ? super Object> objectObjectMap) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   683
        List<RelativeFileSet> result = new ArrayList<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   684
        for (String path : s.split("[:;]")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   685
            File f = new File(path);
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   686
            if (f.getName().equals("*") || path.endsWith("/") ||
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   687
                    path.endsWith("\\")) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   688
                if (f.getName().equals("*")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   689
                    f = f.getParentFile();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   690
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   691
                Set<File> theFiles = new HashSet<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   692
                try {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   693
                    Files.walk(f.toPath())
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   694
                            .filter(Files::isRegularFile)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   695
                            .forEach(p -> theFiles.add(p.toFile()));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   696
                } catch (IOException e) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   697
                    e.printStackTrace();
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
                result.add(new RelativeFileSet(f, theFiles));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   700
            } else {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   701
                result.add(new RelativeFileSet(f.getParentFile(),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   702
                        Collections.singleton(f)));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   703
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   704
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   705
        return result;
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
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   708
    private static RelativeFileSet getMainJar(
57078
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   709
            String mainJarValue, Map<String, ? super Object> params) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   710
        for (RelativeFileSet rfs : APP_RESOURCES_LIST.fetchFrom(params)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   711
            File appResourcesRoot = rfs.getBaseDirectory();
57078
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   712
            File mainJarFile = new File(appResourcesRoot, mainJarValue);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   713
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   714
            if (mainJarFile.exists()) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   715
                return new RelativeFileSet(appResourcesRoot,
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   716
                     new LinkedHashSet<>(Collections.singletonList(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   717
                     mainJarFile)));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   718
            }
57078
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   719
            mainJarFile = new File(mainJarValue);
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   720
            if (mainJarFile.exists()) {
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   721
                // absolute path for main-jar may fail is only legal if
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   722
                // path is within the appResourceRoot directory
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   723
                try {
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   724
                    return new RelativeFileSet(appResourcesRoot,
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   725
                         new LinkedHashSet<>(Collections.singletonList(
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   726
                         mainJarFile)));
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   727
                } catch (Exception e) {
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   728
                    // if not within, RelativeFileSet constructor throws a
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   729
                    // RuntimeException, but the IllegalArgumentException
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   730
                    // below contains a more explicit error message.
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   731
                }
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   732
            } else {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   733
                List<Path> modulePath = MODULE_PATH.fetchFrom(params);
57078
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   734
                modulePath.removeAll(getDefaultModulePath());
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   735
                if (!modulePath.isEmpty()) {
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   736
                    Path modularJarPath = JLinkBundlerHelper.findPathOfModule(
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   737
                            modulePath, mainJarValue);
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   738
                    if (modularJarPath != null &&
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   739
                            Files.exists(modularJarPath)) {
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   740
                        return new RelativeFileSet(appResourcesRoot,
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   741
                                new LinkedHashSet<>(Collections.singletonList(
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   742
                                modularJarPath.toFile())));
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   743
                    }
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   744
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   745
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   746
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   747
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   748
        throw new IllegalArgumentException(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   749
                new ConfigException(MessageFormat.format(I18N.getString(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   750
                        "error.main-jar-does-not-exist"),
57078
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   751
                        mainJarValue), I18N.getString(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   752
                        "error.main-jar-does-not-exist.advice")));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   753
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   754
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   755
    static List<Path> getDefaultModulePath() {
57015
5d2008115309 JDK-8213244: Fix all warnings in jpackager java code
herrick
parents: 56994
diff changeset
   756
        List<Path> result = new ArrayList<Path>();
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   757
        Path jdkModulePath = Paths.get(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   758
                System.getProperty("java.home"), "jmods").toAbsolutePath();
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   759
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   760
        if (jdkModulePath != null && Files.exists(jdkModulePath)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   761
            result.add(jdkModulePath);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   762
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   763
        else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   764
            // On a developer build the JDK Home isn't where we expect it
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   765
            // relative to the jmods directory. Do some extra
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   766
            // processing to find it.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   767
            Map<String, String> env = System.getenv();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   768
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   769
            if (env.containsKey("JDK_HOME")) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   770
                jdkModulePath = Paths.get(env.get("JDK_HOME"),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   771
                        ".." + File.separator + "images"
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   772
                        + File.separator + "jmods").toAbsolutePath();
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   773
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   774
                if (jdkModulePath != null && Files.exists(jdkModulePath)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   775
                    result.add(jdkModulePath);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   776
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   777
            }
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   780
        return result;
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
}