src/jdk.jpackager/share/classes/jdk/jpackager/internal/DeployParams.java
author herrick
Thu, 08 Nov 2018 13:56:26 -0500
branchJDK-8200758-branch
changeset 57022 81021f910bc2
parent 57017 1b08af362a30
child 57030 902f4c4fba42
permissions -rw-r--r--
8213333: Fix issues found in jpackager with automated tests Submitten-by: almatvee Reviewed-by: herrick. kcr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     1
/*
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     2
 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     4
 *
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    10
 *
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    15
 * accompanied this code).
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    16
 *
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    20
 *
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    23
 * questions.
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    24
 */
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    25
57017
1b08af362a30 8213156:rename packages for jpackager
herrick
parents: 56994
diff changeset
    26
package jdk.jpackager.internal;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    27
57017
1b08af362a30 8213156:rename packages for jpackager
herrick
parents: 56994
diff changeset
    28
import jdk.jpackager.internal.bundlers.BundlerType;
1b08af362a30 8213156:rename packages for jpackager
herrick
parents: 56994
diff changeset
    29
import jdk.jpackager.internal.bundlers.BundleParams;
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56933
diff changeset
    30
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    31
import java.io.File;
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56933
diff changeset
    32
import java.nio.file.Files;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    33
import java.util.ArrayList;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    34
import java.util.Arrays;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    35
import java.util.Collection;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    36
import java.util.LinkedHashMap;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    37
import java.util.LinkedHashSet;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    38
import java.util.LinkedList;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    39
import java.util.List;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    40
import java.util.Map;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    41
import java.util.Set;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    42
import java.util.TreeMap;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    43
import java.util.TreeSet;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    44
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
    45
/**
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
    46
 * DeployParams
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
    47
 *
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
    48
 * This class is generated and used in Arguments.processArguments() as
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
    49
 * intermediate step in generating the BundleParams and ultimately the Bundles
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
    50
 */
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
    51
public class DeployParams {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    52
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    53
    final List<RelativeFileSet> resources = new ArrayList<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    54
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    55
    String id;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    56
    String title;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    57
    String vendor;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    58
    String email;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    59
    String description;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    60
    String category;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    61
    String licenseType;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    62
    String copyright;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    63
    String version;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    64
    Boolean systemWide;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    65
    Boolean serviceHint;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    66
    Boolean signBundle;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    67
    Boolean installdirChooser;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    68
    Boolean singleton;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    69
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    70
    String applicationClass;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    71
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    72
    List<Param> params;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    73
    List<String> arguments; //unnamed arguments
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    74
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    75
    // Java 9 modules support
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    76
    String addModules = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    77
    String limitModules = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    78
    Boolean stripNativeCommands = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    79
    String modulePath = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    80
    String module = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    81
    String debugPort = null;
56902
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
    82
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    83
    boolean jreInstaller = false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    84
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
    85
    File outdir = null;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    86
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    87
    String appId = null;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    88
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
    89
    // list of jvm args
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
    90
    // (in theory string can contain spaces and need to be escaped
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    91
    List<String> jvmargs = new LinkedList<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    92
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
    93
    // list of jvm properties (can also be passed as VM args
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    94
    // but keeping them separate make it a bit more convinient
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    95
    Map<String, String> properties = new LinkedHashMap<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    96
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    97
    // raw arguments to the bundler
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    98
    Map<String, ? super Object> bundlerArguments = new LinkedHashMap<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
    99
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   100
    public void setId(String id) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   101
        this.id = id;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   102
    }
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
    public void setCategory(String category) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   105
        this.category = category;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   106
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   107
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   108
    public void setLicenseType(String licenseType) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   109
        this.licenseType = licenseType;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   110
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   111
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   112
    public void setCopyright(String copyright) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   113
        this.copyright = copyright;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   114
    }
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
    public void setVersion(String version) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   117
        this.version = version;
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
    public void setSystemWide(Boolean systemWide) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   121
        this.systemWide = systemWide;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   122
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   123
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   124
    public void setServiceHint(Boolean serviceHint) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   125
        this.serviceHint = serviceHint;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   126
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   127
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   128
    public void setInstalldirChooser(Boolean installdirChooser) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   129
        this.installdirChooser = installdirChooser;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   130
    }
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
    public void setSingleton(Boolean singleton) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   133
        this.singleton = singleton;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   134
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   135
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   136
    public void setSignBundle(Boolean signBundle) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   137
        this.signBundle = signBundle;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   138
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   139
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   140
    public void addJvmArg(String v) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   141
        jvmargs.add(v);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   142
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   143
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   144
    public void addJvmProperty(String n, String v) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   145
        properties.put(n, v);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   146
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   147
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   148
    public void setArguments(List<String> args) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   149
        this.arguments = args;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   150
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   151
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   152
    public List<String> getArguments() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   153
        return this.arguments;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   154
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   155
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   156
    public void addArgument(String arg) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   157
        this.arguments.add(arg);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   158
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   159
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   160
    public void addAddModule(String value) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   161
        if (addModules == null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   162
            addModules = value;
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
        else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   165
            addModules += "," + value;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   166
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   167
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   168
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   169
    public void addLimitModule(String value) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   170
        if (limitModules == null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   171
            limitModules = value;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   172
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   173
        else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   174
            limitModules += "," + value;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   175
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   176
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   177
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   178
    public String getModulePath() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   179
        return this.modulePath;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   180
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   181
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   182
    public void setModulePath(String value) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   183
        this.modulePath = value;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   184
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   185
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   186
    public void setModule(String value) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   187
        this.module = value;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   188
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   189
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   190
    public void setDebug(String value) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   191
        this.debugPort = value;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   192
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   193
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   194
    public void setStripNativeCommands(boolean value) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   195
        this.stripNativeCommands = value;
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   198
    public void setDescription(String description) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   199
        this.description = description;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   200
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   201
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   202
    public void setAppId(String id) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   203
        appId = id;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   204
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   205
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   206
    public void setParams(List<Param> params) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   207
        this.params = params;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   208
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   209
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   210
    public void setTitle(String title) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   211
        this.title = title;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   212
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   213
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   214
    public void setVendor(String vendor) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   215
        this.vendor = vendor;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   216
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   217
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   218
    public void setEmail(String email) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   219
        this.email = email;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   220
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   221
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   222
    public void setApplicationClass(String applicationClass) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   223
        this.applicationClass = applicationClass;
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   226
    public void setJreInstaller(boolean value) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   227
        jreInstaller = value;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   228
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   229
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   230
    public File getOutput() {
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   231
        return outdir;
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   232
    }
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   233
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   234
    public void setOutput(File output) {
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   235
        outdir = output;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   236
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   237
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   238
    static class Template {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   239
        File in;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   240
        File out;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   241
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   242
        Template(File in, File out) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   243
            this.in = in;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   244
            this.out = out;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   245
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   246
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   247
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   248
    // we need to expand as in some cases
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56933
diff changeset
   249
    // (most notably jpackager)
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   250
    // we may get "." as filename and assumption is we include
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   251
    // everything in the given folder
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   252
    // (IOUtils.copyfiles() have recursive behavior)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   253
    List<File> expandFileset(File root) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   254
        List<File> files = new LinkedList<>();
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56933
diff changeset
   255
        if (!Files.isSymbolicLink(root.toPath())) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   256
            if (root.isDirectory()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   257
                File[] children = root.listFiles();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   258
                if (children != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   259
                    for (File f : children) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   260
                        files.addAll(expandFileset(f));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   261
                    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   262
                }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   263
            } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   264
                files.add(root);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   265
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   266
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   267
        return files;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   268
    }
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
    public void addResource(File baseDir, String path) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   271
        File file = new File(baseDir, path);
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   272
        // normalize top level dir
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   273
        // to strip things like "." in the path
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   274
        // or it can confuse symlink detection logic
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   275
        file = file.getAbsoluteFile();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   276
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   277
        if (baseDir == null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   278
            baseDir = file.getParentFile();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   279
        }
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   280
        resources.add(new RelativeFileSet(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   281
                baseDir, new LinkedHashSet<>(expandFileset(file))));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   282
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   283
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   284
    public void addResource(File baseDir, File file) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   285
        // normalize initial file
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   286
        // to strip things like "." in the path
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   287
        // or it can confuse symlink detection logic
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   288
        file = file.getAbsoluteFile();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   289
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   290
        if (baseDir == null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   291
            baseDir = file.getParentFile();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   292
        }
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   293
        resources.add(new RelativeFileSet(
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   294
                baseDir, new LinkedHashSet<>(expandFileset(file))));
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   295
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   296
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   297
    private static File createFile(final File baseDir, final String path) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   298
        final File testFile = new File(path);
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   299
        return testFile.isAbsolute() ?
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   300
                testFile : new File(baseDir == null ?
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   301
                        null : baseDir.getAbsolutePath(), path);
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   302
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   303
56985
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   304
    public static void validateAppName(String s) throws PackagerException {
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   305
        if (s == null || s.length() == 0) {
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   306
            // empty or null string - there is no unsupported char
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   307
            return;
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   308
        }
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   309
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   310
        int last = s.length() - 1;
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   311
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   312
        char fc = s.charAt(0);
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   313
        char lc = s.charAt(last);
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   314
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   315
        // illegal to end in backslash escape char
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   316
        if (lc == '\\') {
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   317
            throw new PackagerException("ERR_InvalidCharacterInArgument", "--name");
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   318
        }
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   319
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   320
        for (int i = 0; i < s.length(); i++) {
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   321
            char a = s.charAt(i);
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   322
            // We check for ASCII codes first which we accept. If check fails,
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   323
            // then check if it is acceptable extended ASCII or unicode character.
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   324
            if (a < ' ' || a > '~' || a == '%') {
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   325
                // Reject '%', whitespaces and ISO Control.
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   326
                // Accept anything else including special characters like copyright
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   327
                // symbols. Note: space will be included by ASCII check above,
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   328
                // but other whitespace like tabs or new line will be ignored.
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   329
                if (Character.isISOControl(a) || Character.isWhitespace(a) || a == '%') {
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   330
                    throw new PackagerException("ERR_InvalidCharacterInArgument", "--name");
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   331
                }
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   332
            }
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   333
            if (a == '"') {
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   334
                throw new PackagerException("ERR_InvalidCharacterInArgument", "--name");
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   335
            }
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   336
        }
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   337
    }
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   338
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   339
    public void validate() throws PackagerException {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   340
        if (outdir == null) {
56848
f8a7c83f31f1 JDK-8208456: [packager] Remove some unused Strings
herrick
parents: 56836
diff changeset
   341
            throw new PackagerException("ERR_MissingArgument", "--output");
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   342
        }
56888
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   343
57022
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   344
        if (getBundleType() == BundlerType.IMAGE) {
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   345
            String input = (String)bundlerArguments.get(Arguments.CLIOptions.INPUT.getId());
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   346
            if (input == null) {
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   347
                throw new PackagerException("ERR_MissingArgument", "--input");
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   348
            }
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   349
        } else if (getBundleType() == BundlerType.INSTALLER) {
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   350
            if (!Arguments.isJreInstaller()) {
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   351
                String input = (String)bundlerArguments.get(Arguments.CLIOptions.INPUT.getId());
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   352
                String appImage = (String)bundlerArguments.get(
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   353
                    Arguments.CLIOptions.PREDEFINED_APP_IMAGE.getId());
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   354
                if (input == null && appImage == null) {
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   355
                    throw new PackagerException("ERR_MissingArgument", "--input or --app-image");
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   356
                }
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   357
            }
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   358
        }
81021f910bc2 8213333: Fix issues found in jpackager with automated tests
herrick
parents: 57017
diff changeset
   359
56888
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   360
        boolean hasModule = (bundlerArguments.get(
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   361
                Arguments.CLIOptions.MODULE.getId()) != null);
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   362
        boolean hasImage = (bundlerArguments.get(
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   363
                Arguments.CLIOptions.PREDEFINED_APP_IMAGE.getId()) != null);
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   364
        boolean hasClass = (bundlerArguments.get(
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   365
                Arguments.CLIOptions.APPCLASS.getId()) != null);
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   366
        boolean hasMain = (bundlerArguments.get(
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   367
                Arguments.CLIOptions.MAIN_JAR.getId()) != null);
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   368
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   369
        // if bundling non-modular image, or installer without app-image
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   370
        // then we need some resources and a main class
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   371
        if (!hasModule && !hasImage && !jreInstaller) {
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   372
            if (resources.isEmpty()) {
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   373
                throw new PackagerException("ERR_MissingAppResources");
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   374
            }
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   375
            if (!hasClass) {
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   376
                throw new PackagerException("ERR_MissingArgument", "--class");
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   377
            }
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   378
            if (!hasMain) {
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56933
diff changeset
   379
                throw new PackagerException("ERR_MissingArgument",
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56933
diff changeset
   380
                        "--main-jar");
56888
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   381
            }
628a283daa6c 8210505: Unable to create an installer from an app-image on linux
herrick
parents: 56882
diff changeset
   382
        }
56902
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   383
56985
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   384
        String name = (String)bundlerArguments.get(Arguments.CLIOptions.NAME.getId());
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   385
        validateAppName(name);
5e6ced665587 8211285: Better app validation
herrick
parents: 56982
diff changeset
   386
56902
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   387
        // Validate app image if set
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56933
diff changeset
   388
        String appImage = (String)bundlerArguments.get(
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56933
diff changeset
   389
                Arguments.CLIOptions.PREDEFINED_APP_IMAGE.getId());
56902
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   390
        if (appImage != null) {
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   391
            File appImageDir = new File(appImage);
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   392
            if (!appImageDir.exists()) {
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   393
                throw new PackagerException("ERR_AppImageNotExist", appImage);
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   394
            }
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   395
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   396
            File appImageAppDir = new File(appImage + File.separator + "app");
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56933
diff changeset
   397
            File appImageRuntimeDir = new File(appImage
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56933
diff changeset
   398
                    + File.separator + "runtime");
56902
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   399
            if (!appImageAppDir.exists() || !appImageRuntimeDir.exists()) {
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   400
                throw new PackagerException("ERR_AppImageInvalid", appImage);
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   401
            }
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   402
        }
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   403
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   404
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   405
    public boolean validateForBundle() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   406
        boolean result = false;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   407
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   408
        // Success
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   409
        if (((applicationClass != null && !applicationClass.isEmpty()) ||
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   410
            (module != null && !module.isEmpty()))) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   411
            result = true;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   412
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   413
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   414
        return result;
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
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   417
    BundlerType bundleType = BundlerType.NONE;
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   418
    String targetFormat = null; //means any
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   419
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   420
    public void setBundleType(BundlerType type) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   421
        bundleType = type;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   422
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   423
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   424
    public BundlerType getBundleType() {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   425
        return bundleType;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   426
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   427
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   428
    public void setTargetFormat(String t) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   429
        targetFormat = t;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   430
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   431
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   432
    public String getTargetFormat() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   433
        return targetFormat;
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
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   436
    private String getArch() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   437
        String arch = System.getProperty("os.arch").toLowerCase();
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 ("x86".equals(arch) || "i386".equals(arch) || "i486".equals(arch)
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   440
                || "i586".equals(arch) || "i686".equals(arch)) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   441
            arch = "x86";
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   442
        } else if ("x86_64".equals(arch) || "amd64".equals("arch")) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   443
            arch = "x86_64";
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
        return arch;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   447
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   448
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   449
    static final Set<String> multi_args = new TreeSet<>(Arrays.asList(
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   450
            StandardBundlerParam.JVM_PROPERTIES.getID(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   451
            StandardBundlerParam.JVM_OPTIONS.getID(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   452
            StandardBundlerParam.ARGUMENTS.getID(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   453
            StandardBundlerParam.MODULE_PATH.getID(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   454
            StandardBundlerParam.ADD_MODULES.getID(),
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   455
            StandardBundlerParam.LIMIT_MODULES.getID(),
56982
e094d5483bd6 8212048: Cleanup source code and fix issues discussed in preliminary review
herrick
parents: 56933
diff changeset
   456
            StandardBundlerParam.FILE_ASSOCIATIONS.getID()
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   457
    ));
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   458
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   459
    @SuppressWarnings("unchecked")
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   460
    public void addBundleArgument(String key, Object value) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   461
        // special hack for multi-line arguments
56836
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   462
        if (multi_args.contains(key)) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   463
            Object existingValue = bundlerArguments.get(key);
56836
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   464
            if (existingValue instanceof String && value instanceof String) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   465
                bundlerArguments.put(key, existingValue + "\n\n" + value);
56836
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   466
            } else if (existingValue instanceof List && value instanceof List) {
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   467
                ((List)existingValue).addAll((List)value);
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   468
            } else if (existingValue instanceof Map &&
40abf95122b0 8207143: jpackager fails to parse file associations
herrick
parents: 56821
diff changeset
   469
                value instanceof String && ((String)value).contains("=")) {
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   470
                String[] mapValues = ((String)value).split("=", 2);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   471
                ((Map)existingValue).put(mapValues[0], mapValues[1]);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   472
            } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   473
                bundlerArguments.put(key, value);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   474
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   475
        } else {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   476
            bundlerArguments.put(key, value);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   477
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   478
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   479
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   480
    public BundleParams getBundleParams() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   481
        BundleParams bundleParams = new BundleParams();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   482
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   483
        //construct app resources
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   484
        //  relative to output folder!
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   485
        String currentOS = System.getProperty("os.name").toLowerCase();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   486
        String currentArch = getArch();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   487
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   488
        bundleParams.setAppResourcesList(resources);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   489
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   490
        bundleParams.setIdentifier(id);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   491
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   492
        bundleParams.setApplicationClass(applicationClass);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   493
        bundleParams.setAppVersion(version);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   494
        bundleParams.setType(bundleType);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   495
        bundleParams.setBundleFormat(targetFormat);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   496
        bundleParams.setVendor(vendor);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   497
        bundleParams.setEmail(email);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   498
        bundleParams.setServiceHint(serviceHint);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   499
        bundleParams.setInstalldirChooser(installdirChooser);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   500
        bundleParams.setSingleton(singleton);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   501
        bundleParams.setCopyright(copyright);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   502
        bundleParams.setApplicationCategory(category);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   503
        bundleParams.setDescription(description);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   504
        bundleParams.setTitle(title);
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
        bundleParams.setJvmProperties(properties);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   507
        bundleParams.setJvmargs(jvmargs);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   508
        bundleParams.setArguments(arguments);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   509
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   510
        if (addModules != null && !addModules.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   511
            bundleParams.setAddModules(addModules);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   512
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   513
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   514
        if (limitModules != null && !limitModules.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   515
            bundleParams.setLimitModules(limitModules);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   516
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   517
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   518
        if (stripNativeCommands != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   519
            bundleParams.setStripNativeCommands(stripNativeCommands);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   520
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   521
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   522
        if (modulePath != null && !modulePath.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   523
            bundleParams.setModulePath(modulePath);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   524
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   525
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   526
        if (module != null && !module.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   527
            bundleParams.setMainModule(module);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   528
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   529
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   530
        if (debugPort != null && !debugPort.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   531
            bundleParams.setDebug(debugPort);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   532
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   533
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   534
        Map<String, String> paramsMap = new TreeMap<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   535
        if (params != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   536
            for (Param p : params) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   537
                paramsMap.put(p.name, p.value);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   538
            }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   539
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   540
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   541
        Map<String, String> unescapedHtmlParams = new TreeMap<>();
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   542
        Map<String, String> escapedHtmlParams = new TreeMap<>();
56902
6972c0e75e23 8210367: invalid --app-image arg causes exception runnning light.exe in windows
herrick
parents: 56888
diff changeset
   543
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   544
        // check for collisions
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   545
        TreeSet<String> keys = new TreeSet<>(bundlerArguments.keySet());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   546
        keys.retainAll(bundleParams.getBundleParamsAsMap().keySet());
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   547
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   548
        if (!keys.isEmpty()) {
56869
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   549
            throw new RuntimeException("Deploy Params and Bundler Arguments "
41e17fe9fbeb 8208522: removed unreferenced class and minor formatting of java source
herrick
parents: 56848
diff changeset
   550
                    + "overlap in the following values:" + keys.toString());
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   551
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   552
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   553
        bundleParams.addAllBundleParams(bundlerArguments);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   554
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   555
        return bundleParams;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   556
    }
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
    public Map<String, ? super Object> getBundlerArguments() {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   559
        return this.bundlerArguments;
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   560
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   561
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   562
    public void putUnlessNull(String param, Object value) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   563
        if (value != null) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   564
            bundlerArguments.put(param, value);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   565
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   566
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   567
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   568
    public void putUnlessNullOrEmpty(String param, Map<?, ?> value) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   569
        if (value != null && !value.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   570
            bundlerArguments.put(param, value);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   571
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   572
    }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   573
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   574
    public void putUnlessNullOrEmpty(String param, Collection<?> value) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   575
        if (value != null && !value.isEmpty()) {
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   576
            bundlerArguments.put(param, value);
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   577
        }
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   578
    }
56994
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   579
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   580
    @Override
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   581
    public String toString() {
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   582
        return "DeployParams{" + "outdir=" + outdir + '}';
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   583
    }
b4aca2dbe2b5 8212537: Create method and class description comments for main functionality
herrick
parents: 56987
diff changeset
   584
56821
565d54ca1f41 8206005: Move prototype jpackager from closed sandbox to open sandbox
herrick
parents:
diff changeset
   585
}