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