src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java
author herrick
Thu, 06 Jun 2019 19:07:18 -0400
branchJDK-8200758-branch
changeset 57389 cce526c681dc
parent 57323 66c1dbc008c5
child 57391 970f28090a06
permissions -rw-r--r--
8222901: different behavior when --name option not used Reviewed-by: asemenyuk, almatvee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     1
/*
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);
57389
cce526c681dc 8222901: different behavior when --name option not used
herrick
parents: 57323
diff changeset
   164
                            if (s.length() == 0) {
cce526c681dc 8222901: different behavior when --name option not used
herrick
parents: 57323
diff changeset
   165
                                s = null;
cce526c681dc 8222901: different behavior when --name option not used
herrick
parents: 57323
diff changeset
   166
                            }
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   167
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   168
                        return s;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   169
                    },
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   170
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   171
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   172
57314
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   173
    static final StandardBundlerParam<File> PREDEFINED_RUNTIME_IMAGE =
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   174
            new StandardBundlerParam<>(
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   175
                    Arguments.CLIOptions.PREDEFINED_RUNTIME_IMAGE.getId(),
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   176
                    File.class,
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   177
                    params -> null,
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   178
                    (s, p) -> new File(s)
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   179
            );
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   180
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   181
    static final StandardBundlerParam<String> APP_NAME =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   182
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   183
                    Arguments.CLIOptions.NAME.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   184
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   185
                    params -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   186
                        String s = MAIN_CLASS.fetchFrom(params);
57314
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   187
                        if (s != null) {
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   188
                            int idx = s.lastIndexOf(".");
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   189
                            if (idx >= 0) {
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   190
                                return s.substring(idx+1);
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   191
                            }
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   192
                            return s;
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   193
                        } else if (isRuntimeInstaller(params)) {
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   194
                            File f = PREDEFINED_RUNTIME_IMAGE.fetchFrom(params);
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   195
                            if (f != null) {
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   196
                                return f.getName();
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   197
                            }
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   198
                        }
57314
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   199
                        return null;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   200
                    },
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   201
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   202
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   203
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   204
    static final StandardBundlerParam<File> ICON =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   205
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   206
                    Arguments.CLIOptions.ICON.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   207
                    File.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   208
                    params -> null,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   209
                    (s, p) -> new File(s)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   210
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   211
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   212
    static final StandardBundlerParam<String> VENDOR =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   213
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   214
                    Arguments.CLIOptions.VENDOR.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   215
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   216
                    params -> I18N.getString("param.vendor.default"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   217
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   218
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   219
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   220
    static final StandardBundlerParam<String> DESCRIPTION =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   221
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   222
                    Arguments.CLIOptions.DESCRIPTION.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   223
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   224
                    params -> params.containsKey(APP_NAME.getID())
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   225
                            ? APP_NAME.fetchFrom(params)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   226
                            : I18N.getString("param.description.default"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   227
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   228
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   229
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   230
    static final StandardBundlerParam<String> COPYRIGHT =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   231
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   232
                    Arguments.CLIOptions.COPYRIGHT.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   233
                    String.class,
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   234
                    params -> MessageFormat.format(I18N.getString(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   235
                            "param.copyright.default"), new Date()),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   236
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   237
            );
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
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   240
    static final StandardBundlerParam<List<String>> ARGUMENTS =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   241
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   242
                    Arguments.CLIOptions.ARGUMENTS.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   243
                    (Class<List<String>>) (Object) List.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   244
                    params -> Collections.emptyList(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   245
                    (s, p) -> splitStringWithEscapes(s)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   246
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   247
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   248
    @SuppressWarnings("unchecked")
57316
2891b3ae222d 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57314
diff changeset
   249
    static final StandardBundlerParam<List<String>> JAVA_OPTIONS =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   250
            new StandardBundlerParam<>(
57291
f2d429260ad4 8221582: Rename jvm-args option to java-options
herrick
parents: 57256
diff changeset
   251
                    Arguments.CLIOptions.JAVA_OPTIONS.getId(),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   252
                    (Class<List<String>>) (Object) List.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   253
                    params -> Collections.emptyList(),
56835
43caa6ff671a 8207022: jpackager saves VM args incorrectly if --jvm-args contains white spaces
herrick
parents: 56829
diff changeset
   254
                    (s, p) -> Arrays.asList(s.split("\n\n"))
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   255
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   256
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   257
    // 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
   258
    // their own converter
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   259
    static final StandardBundlerParam<String> VERSION =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   260
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   261
                    Arguments.CLIOptions.VERSION.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   262
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   263
                    params -> I18N.getString("param.version.default"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   264
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   265
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   266
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   267
    @SuppressWarnings("unchecked")
57080
bd4ce7f9ea2c 8214495: Change behavior of --license-file
herrick
parents: 57078
diff changeset
   268
    public static final StandardBundlerParam<String> LICENSE_FILE =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   269
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   270
                    Arguments.CLIOptions.LICENSE_FILE.getId(),
57080
bd4ce7f9ea2c 8214495: Change behavior of --license-file
herrick
parents: 57078
diff changeset
   271
                    String.class,
bd4ce7f9ea2c 8214495: Change behavior of --license-file
herrick
parents: 57078
diff changeset
   272
                    params -> null,
bd4ce7f9ea2c 8214495: Change behavior of --license-file
herrick
parents: 57078
diff changeset
   273
                    (s, p) -> s
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   274
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   275
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   276
    static final StandardBundlerParam<File> TEMP_ROOT =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   277
            new StandardBundlerParam<>(
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   278
                    Arguments.CLIOptions.TEMP_ROOT.getId(),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   279
                    File.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   280
                    params -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   281
                        try {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   282
                            return Files.createTempDirectory(
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57038
diff changeset
   283
                                    "jdk.jpackage").toFile();
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   284
                        } catch (IOException ioe) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   285
                            return null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   286
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   287
                    },
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   288
                    (s, p) -> new File(s)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   289
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   290
57103
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   291
    public static final StandardBundlerParam<File> CONFIG_ROOT =
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   292
            new StandardBundlerParam<>(
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   293
                "configRoot",
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   294
                File.class,
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   295
                params -> {
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   296
                    File root =
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   297
                            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
   298
                    root.mkdirs();
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   299
                    return root;
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   300
                },
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   301
                (s, p) -> null
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
diff changeset
   302
            );
fe6bf39ac415 8216373: temporary build-root left behind when using secondary launcher(s)
herrick
parents: 57099
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> IDENTIFIER =
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
                    Arguments.CLIOptions.IDENTIFIER.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   307
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   308
                    params -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   309
                        String s = MAIN_CLASS.fetchFrom(params);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   310
                        if (s == null) return null;
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
                        int idx = s.lastIndexOf(".");
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   313
                        if (idx >= 1) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   314
                            return s.substring(0, idx);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   315
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   316
                        return s;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   317
                    },
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   318
                    (s, p) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   319
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   320
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   321
    static final StandardBundlerParam<Boolean> VERBOSE  =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   322
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   323
                    Arguments.CLIOptions.VERBOSE.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   324
                    Boolean.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   325
                    params -> false,
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   326
                    // 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
   327
                    (s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   328
                            true : Boolean.valueOf(s)
56821
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
57091
06bc4bd64599 8215515: Add a command line option to override internal resources.
herrick
parents: 57080
diff changeset
   331
    static final StandardBundlerParam<File> RESOURCE_DIR =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   332
            new StandardBundlerParam<>(
57091
06bc4bd64599 8215515: Add a command line option to override internal resources.
herrick
parents: 57080
diff changeset
   333
                    Arguments.CLIOptions.RESOURCE_DIR.getId(),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   334
                    File.class,
57091
06bc4bd64599 8215515: Add a command line option to override internal resources.
herrick
parents: 57080
diff changeset
   335
                    params -> null,
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   336
                    (s, p) -> new File(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 BundlerParamInfo<String> INSTALL_DIR =
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.INSTALL_DIR.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   342
                    String.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) -> s
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   345
    );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   346
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   347
    static final StandardBundlerParam<File> PREDEFINED_APP_IMAGE =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   348
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   349
            Arguments.CLIOptions.PREDEFINED_APP_IMAGE.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   350
            File.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   351
            params -> null,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   352
            (s, p) -> new File(s));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   353
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   354
    @SuppressWarnings("unchecked")
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   355
    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
   356
            new StandardBundlerParam<>(
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   357
                    Arguments.CLIOptions.ADD_LAUNCHER.getId(),
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   358
                    (Class<List<Map<String, ? super Object>>>) (Object)
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   359
                            List.class,
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   360
                    params -> new ArrayList<>(1),
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   361
                    // 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
   362
                    (s, p) -> null
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   365
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   366
    static final StandardBundlerParam
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   367
            <List<Map<String, ? super Object>>> FILE_ASSOCIATIONS =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   368
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   369
                    Arguments.CLIOptions.FILE_ASSOCIATIONS.getId(),
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   370
                    (Class<List<Map<String, ? super Object>>>) (Object)
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   371
                            List.class,
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   372
                    params -> new ArrayList<>(1),
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   373
                    // 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
   374
                    (s, p) -> null
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   377
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   378
    static final StandardBundlerParam<List<String>> FA_EXTENSIONS =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   379
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   380
                    "fileAssociation.extension",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   381
                    (Class<List<String>>) (Object) List.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   382
                    params -> null, // null means not matched to an extension
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   383
                    (s, p) -> Arrays.asList(s.split("(,|\\s)+"))
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   386
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   387
    static final StandardBundlerParam<List<String>> FA_CONTENT_TYPE =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   388
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   389
                    "fileAssociation.contentType",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   390
                    (Class<List<String>>) (Object) List.class,
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   391
                    params -> null,
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   392
                            // 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
   393
                    (s, p) -> Arrays.asList(s.split("(,|\\s)+"))
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   394
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   395
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   396
    static final StandardBundlerParam<String> FA_DESCRIPTION =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   397
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   398
                    "fileAssociation.description",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   399
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   400
                    params -> APP_NAME.fetchFrom(params) + " File",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   401
                    null
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   402
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   403
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   404
    static final StandardBundlerParam<File> FA_ICON =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   405
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   406
                    "fileAssociation.icon",
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   407
                    File.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   408
                    ICON::fetchFrom,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   409
                    (s, p) -> new File(s)
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   412
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   413
    static final BundlerParamInfo<List<Path>> MODULE_PATH =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   414
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   415
                    Arguments.CLIOptions.MODULE_PATH.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   416
                    (Class<List<Path>>) (Object)List.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   417
                    p -> { return getDefaultModulePath(); },
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   418
                    (s, p) -> {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   419
                        List<Path> modulePath = Arrays.asList(s
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   420
                                .split(File.pathSeparator)).stream()
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   421
                                .map(ss -> new File(ss).toPath())
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   422
                                .collect(Collectors.toList());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   423
                        Path javaBasePath = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   424
                        if (modulePath != null) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   425
                            javaBasePath = JLinkBundlerHelper
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   426
                                    .findPathOfModule(modulePath, JAVABASEJMOD);
57015
5d2008115309 JDK-8213244: Fix all warnings in jpackager java code
herrick
parents: 56994
diff changeset
   427
                        } else {
5d2008115309 JDK-8213244: Fix all warnings in jpackager java code
herrick
parents: 56994
diff changeset
   428
                            modulePath = new ArrayList<Path>();
56821
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   431
                        // 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
   432
                        if (javaBasePath == null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   433
                            List<Path> jdkModulePath = getDefaultModulePath();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   434
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   435
                            if (jdkModulePath != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   436
                                modulePath.addAll(jdkModulePath);
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   437
                                javaBasePath =
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   438
                                        JLinkBundlerHelper.findPathOfModule(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   439
                                        modulePath, JAVABASEJMOD);
56821
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
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   442
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   443
                        if (javaBasePath == null ||
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   444
                                !Files.exists(javaBasePath)) {
57020
a828547f7e50 8213394: Stop using Log.info() except for expected output.
herrick
parents: 57017
diff changeset
   445
                            Log.error(String.format(I18N.getString(
a828547f7e50 8213394: Stop using Log.info() except for expected output.
herrick
parents: 57017
diff changeset
   446
                                    "warning.no.jdk.modules.found")));
56821
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   449
                        return modulePath;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   450
                    });
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   451
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   452
    static final BundlerParamInfo<String> MODULE =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   453
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   454
                    Arguments.CLIOptions.MODULE.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   455
                    String.class,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   456
                    p -> null,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   457
                    (s, p) -> {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   458
                        return String.valueOf(s);
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   461
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   462
    static final BundlerParamInfo<Set<String>> ADD_MODULES =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   463
            new StandardBundlerParam<>(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   464
                    Arguments.CLIOptions.ADD_MODULES.getId(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   465
                    (Class<Set<String>>) (Object) Set.class,
57015
5d2008115309 JDK-8213244: Fix all warnings in jpackager java code
herrick
parents: 56994
diff changeset
   466
                    p -> new LinkedHashSet<String>(),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   467
                    (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split(",")))
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   470
    @SuppressWarnings("unchecked")
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   471
    static final BundlerParamInfo<Set<String>> LIMIT_MODULES =
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   472
            new StandardBundlerParam<>(
57150
fa68c2ab636d 8217894: jpackage CLI syntax changes
herrick
parents: 57119
diff changeset
   473
                    "limit-modules",
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   474
                    (Class<Set<String>>) (Object) Set.class,
57015
5d2008115309 JDK-8213244: Fix all warnings in jpackager java code
herrick
parents: 56994
diff changeset
   475
                    p -> new LinkedHashSet<String>(),
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   476
                    (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split(",")))
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   477
            );
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   478
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   479
    static boolean isRuntimeInstaller(Map<String, ? super Object> p) {
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   480
        if (p.containsKey(MODULE.getID()) ||
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   481
                p.containsKey(MAIN_JAR.getID()) ||
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   482
                p.containsKey(PREDEFINED_APP_IMAGE.getID())) {
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   483
            return false; // we are building or are given an application
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   484
        }
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   485
        // runtime installer requires --runtime-image, if this is false
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   486
        // here then we should have thrown error validating args.
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   487
        return p.containsKey(PREDEFINED_RUNTIME_IMAGE.getID());
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   488
    }
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   489
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   490
    static File getPredefinedAppImage(Map<String, ? super Object> p) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   491
        File applicationImage = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   492
        if (PREDEFINED_APP_IMAGE.fetchFrom(p) != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   493
            applicationImage = PREDEFINED_APP_IMAGE.fetchFrom(p);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   494
            Log.debug("Using App Image from " + applicationImage);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   495
            if (!applicationImage.exists()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   496
                throw new RuntimeException(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   497
                        MessageFormat.format(I18N.getString(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   498
                                "message.app-image-dir-does-not-exist"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   499
                                PREDEFINED_APP_IMAGE.getID(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   500
                                applicationImage.toString()));
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
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   503
        return applicationImage;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   504
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   505
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   506
    static void copyPredefinedRuntimeImage(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   507
            Map<String, ? super Object> p,
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   508
            AbstractAppImageBuilder appBuilder)
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   509
            throws IOException , ConfigException {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   510
        File image = PREDEFINED_RUNTIME_IMAGE.fetchFrom(p);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   511
        if (!image.exists()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   512
            throw new ConfigException(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   513
                    MessageFormat.format(I18N.getString(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   514
                    "message.runtime-image-dir-does-not-exist"),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   515
                    PREDEFINED_RUNTIME_IMAGE.getID(),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   516
                    image.toString()),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   517
                    MessageFormat.format(I18N.getString(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   518
                    "message.runtime-image-dir-does-not-exist.advice"),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   519
                    PREDEFINED_RUNTIME_IMAGE.getID()));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   520
        }
57077
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   521
        // copy whole runtime, need to skip jmods and src.zip
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   522
        final List<String> excludes = Arrays.asList("jmods", "src.zip");
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   523
        IOUtils.copyRecursive(image.toPath(), appBuilder.getRoot(), excludes);
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   524
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   525
        // if module-path given - copy modules to appDir/mods
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   526
        List<Path> modulePath =
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   527
                StandardBundlerParam.MODULE_PATH.fetchFrom(p);
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   528
        List<Path> defaultModulePath = getDefaultModulePath();
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   529
        Path dest = appBuilder.getAppModsDir();
57108
f1c13cb0e713 8217269: jpackage Makefile improvments
herrick
parents: 57106
diff changeset
   530
57077
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   531
        if (dest != null) {
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   532
            for (Path mp : modulePath) {
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   533
                if (!defaultModulePath.contains(mp)) {
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   534
                    Files.createDirectories(dest);
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   535
                    IOUtils.copyRecursive(mp, dest);
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
        }
8f9cf6ad59f0 8213962: JPackageCreateImageRuntimeModuleTest fails
herrick
parents: 57067
diff changeset
   539
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   540
        appBuilder.prepareApplicationFiles();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   541
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   542
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   543
    static void extractMainClassInfoFromAppResources(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   544
            Map<String, ? super Object> params) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   545
        boolean hasMainClass = params.containsKey(MAIN_CLASS.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   546
        boolean hasMainJar = params.containsKey(MAIN_JAR.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   547
        boolean hasMainJarClassPath = params.containsKey(CLASSPATH.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   548
        boolean hasModule = params.containsKey(MODULE.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   549
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   550
        if (hasMainClass && hasMainJar && hasMainJarClassPath || hasModule ||
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   551
                isRuntimeInstaller(params)) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   552
            return;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   553
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   554
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   555
        // it's a pair.
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   556
        // 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
   557
        List<String[]> filesToCheck = new ArrayList<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   558
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   559
        if (hasMainJar) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   560
            RelativeFileSet rfs = MAIN_JAR.fetchFrom(params);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   561
            for (String s : rfs.getIncludedFiles()) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   562
                filesToCheck.add(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   563
                        new String[] {rfs.getBaseDirectory().toString(), s});
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   564
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   565
        } else if (hasMainJarClassPath) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   566
            for (String s : CLASSPATH.fetchFrom(params).split("\\s+")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   567
                if (APP_RESOURCES.fetchFrom(params) != null) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   568
                    filesToCheck.add(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   569
                            new String[] {APP_RESOURCES.fetchFrom(params)
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   570
                            .getBaseDirectory().toString(), s});
56821
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
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   573
        } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   574
            List<RelativeFileSet> rfsl = APP_RESOURCES_LIST.fetchFrom(params);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   575
            if (rfsl == null || rfsl.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   576
                return;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   577
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   578
            for (RelativeFileSet rfs : rfsl) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   579
                if (rfs == null) continue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   580
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   581
                for (String s : rfs.getIncludedFiles()) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   582
                    filesToCheck.add(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   583
                            new String[]{rfs.getBaseDirectory().toString(), s});
56821
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   588
        // presume the set iterates in-order
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   589
        for (String[] fnames : filesToCheck) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   590
            try {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   591
                // only sniff jars
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   592
                if (!fnames[1].toLowerCase().endsWith(".jar")) continue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   593
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   594
                File file = new File(fnames[0], fnames[1]);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   595
                // that actually exist
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   596
                if (!file.exists()) continue;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   597
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   598
                try (JarFile jf = new JarFile(file)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   599
                    Manifest m = jf.getManifest();
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   600
                    Attributes attrs = (m != null) ?
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   601
                            m.getMainAttributes() : null;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   602
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   603
                    if (attrs != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   604
                        if (!hasMainJar) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   605
                            if (fnames[0] == null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   606
                                fnames[0] = file.getParentFile().toString();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   607
                            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   608
                            params.put(MAIN_JAR.getID(), new RelativeFileSet(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   609
                                    new File(fnames[0]),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   610
                                    new LinkedHashSet<>(Collections
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   611
                                    .singletonList(file))));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   612
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   613
                        if (!hasMainJarClassPath) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   614
                            String cp =
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   615
                                    attrs.getValue(Attributes.Name.CLASS_PATH);
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   616
                            params.put(CLASSPATH.getID(),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   617
                                    cp == null ? "" : cp);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   618
                        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   619
                        break;
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
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   622
            } catch (IOException ignore) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   623
                ignore.printStackTrace();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   624
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   625
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   626
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   627
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   628
    static void validateMainClassInfoFromAppResources(
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   629
            Map<String, ? super Object> params) throws ConfigException {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   630
        boolean hasMainClass = params.containsKey(MAIN_CLASS.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   631
        boolean hasMainJar = params.containsKey(MAIN_JAR.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   632
        boolean hasMainJarClassPath = params.containsKey(CLASSPATH.getID());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   633
        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
   634
        boolean hasAppImage = params.containsKey(PREDEFINED_APP_IMAGE.getID());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   635
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   636
        if (hasMainClass && hasMainJar && hasMainJarClassPath ||
57256
d7c27451f759 8219678: CLI changes in jpackage
herrick
parents: 57255
diff changeset
   637
               hasModule || hasAppImage || isRuntimeInstaller(params)) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   638
            return;
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   641
        extractMainClassInfoFromAppResources(params);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   642
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   643
        if (!params.containsKey(MAIN_CLASS.getID())) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   644
            if (hasMainJar) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   645
                throw new ConfigException(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   646
                        MessageFormat.format(I18N.getString(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   647
                        "error.no-main-class-with-main-jar"),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   648
                        MAIN_JAR.fetchFrom(params)),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   649
                        MessageFormat.format(I18N.getString(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   650
                        "error.no-main-class-with-main-jar.advice"),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   651
                        MAIN_JAR.fetchFrom(params)));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   652
            } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   653
                throw new ConfigException(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   654
                        I18N.getString("error.no-main-class"),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   655
                        I18N.getString("error.no-main-class.advice"));
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   660
    private static List<String> splitStringWithEscapes(String s) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   661
        List<String> l = new ArrayList<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   662
        StringBuilder current = new StringBuilder();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   663
        boolean quoted = false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   664
        boolean escaped = false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   665
        for (char c : s.toCharArray()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   666
            if (escaped) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   667
                current.append(c);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   668
            } else if ('"' == c) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   669
                quoted = !quoted;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   670
            } else if (!quoted && Character.isWhitespace(c)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   671
                l.add(current.toString());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   672
                current = new StringBuilder();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   673
            } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   674
                current.append(c);
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
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   677
        l.add(current.toString());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   678
        return l;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   679
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   680
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   681
    private static List<RelativeFileSet>
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   682
            createAppResourcesListFromString(String s,
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   683
            Map<String, ? super Object> objectObjectMap) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   684
        List<RelativeFileSet> result = new ArrayList<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   685
        for (String path : s.split("[:;]")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   686
            File f = new File(path);
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   687
            if (f.getName().equals("*") || path.endsWith("/") ||
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   688
                    path.endsWith("\\")) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   689
                if (f.getName().equals("*")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   690
                    f = f.getParentFile();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   691
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   692
                Set<File> theFiles = new HashSet<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   693
                try {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   694
                    Files.walk(f.toPath())
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   695
                            .filter(Files::isRegularFile)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   696
                            .forEach(p -> theFiles.add(p.toFile()));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   697
                } catch (IOException e) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   698
                    e.printStackTrace();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   699
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   700
                result.add(new RelativeFileSet(f, theFiles));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   701
            } else {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   702
                result.add(new RelativeFileSet(f.getParentFile(),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   703
                        Collections.singleton(f)));
56821
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
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   706
        return result;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   707
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   708
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   709
    private static RelativeFileSet getMainJar(
57078
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   710
            String mainJarValue, Map<String, ? super Object> params) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   711
        for (RelativeFileSet rfs : APP_RESOURCES_LIST.fetchFrom(params)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   712
            File appResourcesRoot = rfs.getBaseDirectory();
57078
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   713
            File mainJarFile = new File(appResourcesRoot, mainJarValue);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   714
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   715
            if (mainJarFile.exists()) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   716
                return new RelativeFileSet(appResourcesRoot,
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   717
                     new LinkedHashSet<>(Collections.singletonList(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   718
                     mainJarFile)));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   719
            }
57078
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   720
            mainJarFile = new File(mainJarValue);
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   721
            if (mainJarFile.exists()) {
57314
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   722
                // absolute path for main-jar may fail is not legal
23da9e6f446f 8221641: Follow up code clean up for JDK-8221582
herrick
parents: 57291
diff changeset
   723
                // below contains explicit error message.
57078
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   724
            } else {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   725
                List<Path> modulePath = MODULE_PATH.fetchFrom(params);
57078
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   726
                modulePath.removeAll(getDefaultModulePath());
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   727
                if (!modulePath.isEmpty()) {
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   728
                    Path modularJarPath = JLinkBundlerHelper.findPathOfModule(
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   729
                            modulePath, mainJarValue);
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   730
                    if (modularJarPath != null &&
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   731
                            Files.exists(modularJarPath)) {
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   732
                        return new RelativeFileSet(appResourcesRoot,
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   733
                                new LinkedHashSet<>(Collections.singletonList(
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   734
                                modularJarPath.toFile())));
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   735
                    }
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   736
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   737
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   738
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   739
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   740
        throw new IllegalArgumentException(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   741
                new ConfigException(MessageFormat.format(I18N.getString(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   742
                        "error.main-jar-does-not-exist"),
57078
db003bfc5bf7 JDK-8215453: remove unused BundlerParams and fix misleading messages
herrick
parents: 57077
diff changeset
   743
                        mainJarValue), I18N.getString(
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   744
                        "error.main-jar-does-not-exist.advice")));
56821
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
57067
9c17d779808e 8213425: Analyze output from Source code scanner and fix where needed.
herrick
parents: 57059
diff changeset
   747
    static List<Path> getDefaultModulePath() {
57015
5d2008115309 JDK-8213244: Fix all warnings in jpackager java code
herrick
parents: 56994
diff changeset
   748
        List<Path> result = new ArrayList<Path>();
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   749
        Path jdkModulePath = Paths.get(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   750
                System.getProperty("java.home"), "jmods").toAbsolutePath();
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   751
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   752
        if (jdkModulePath != null && Files.exists(jdkModulePath)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   753
            result.add(jdkModulePath);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   754
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   755
        else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   756
            // 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
   757
            // relative to the jmods directory. Do some extra
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   758
            // processing to find it.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   759
            Map<String, String> env = System.getenv();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   760
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   761
            if (env.containsKey("JDK_HOME")) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   762
                jdkModulePath = Paths.get(env.get("JDK_HOME"),
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   763
                        ".." + File.separator + "images"
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56835
diff changeset
   764
                        + File.separator + "jmods").toAbsolutePath();
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   765
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   766
                if (jdkModulePath != null && Files.exists(jdkModulePath)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   767
                    result.add(jdkModulePath);
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
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   770
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   771
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   772
        return result;
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
}