1 /*
   2  * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.tools.packager;
  27 
  28 import com.sun.javafx.tools.resource.PackagerResource;
  29 import java.io.File;
  30 import java.util.ArrayList;
  31 import java.util.List;
  32 import java.util.Map;
  33 
  34 /**
  35  * @deprecated use {@link ToolProvider} to locate the {@code "javapackager"} tool instead.
  36  */
  37 @Deprecated(since="10", forRemoval=true)
  38 public class CreateJarParams extends CommonParams {
  39     final List<PackagerResource> resources = new ArrayList<PackagerResource>();
  40 
  41     String applicationClass;
  42     String fallbackClass;
  43     String preloader;
  44     String classpath;
  45     Map<String, String> manifestAttrs;
  46     boolean embedLauncher = true;
  47     boolean css2bin = true;
  48     String outfile;
  49     String fxVersion = PackagerLib.JAVAFX_VERSION;
  50     Boolean allPermissions = false;
  51     String codebase;
  52 
  53     List<String> arguments;
  54     List<Param> params;
  55 
  56     public void setArguments(List<String> args) {
  57         this.arguments = args;
  58     }
  59 
  60     public void setParams(List<Param> params) {
  61         this.params = params;
  62     }
  63 
  64     public void setApplicationClass(String applicationClass) {
  65         this.applicationClass = applicationClass;
  66     }
  67 
  68     public void setPreloader(String preloader) {
  69         this.preloader = preloader;
  70     }
  71 
  72     public void setFallback(String fallback) {
  73         this.fallbackClass = fallback;
  74     }
  75 
  76     public void setClasspath(String classpath) {
  77         this.classpath = classpath;
  78     }
  79 
  80     public void setCss2bin(boolean css2bin) {
  81         this.css2bin = css2bin;
  82     }
  83 
  84     /**
  85      * In JKD8/FX8 launcher is never embedded,
  86      * app must use main to call Application launcher()
  87      * @deprecated
  88      * @param embedLauncher
  89      */
  90     public void setEmbedLauncher(boolean embedLauncher) {
  91         this.embedLauncher = embedLauncher;
  92     }
  93 
  94     public void setOutfile(String outfile) {
  95         this.outfile = outfile;
  96     }
  97 
  98     public void setManifestAttrs(Map<String, String> manifestAttrs) {
  99         this.manifestAttrs = manifestAttrs;
 100     }
 101 
 102     public void setFxVersion(String fxVersion) {
 103         this.fxVersion = fxVersion;
 104     }
 105 
 106     public void setAllPermissions(Boolean allPermissions) {
 107         this.allPermissions = allPermissions;
 108     }
 109 
 110     public void setCodebase(String codebase) {
 111         this.codebase = codebase;
 112     }
 113 
 114     @Override
 115     public void addResource(File baseDir, String path) {
 116         resources.add(new PackagerResource(baseDir, path));
 117     }
 118 
 119     @Override
 120     public void addResource(File baseDir, File file) {
 121         resources.add(new PackagerResource(baseDir, file));
 122     }
 123 
 124     @Override
 125     public String toString() {
 126         return "CreateJarParams{" + "applicationClass=" + applicationClass
 127                 + " preloader=" + preloader + " classpath=" + classpath
 128                 + " manifestAttrs=" + manifestAttrs
 129                 + " embedLauncher=deprecated" + " css2bin=" + css2bin
 130                 + " outfile=" + outfile + " sdkHome=" + fxVersion + '}'
 131                 + "            CommonParams{" + "outdir=" + outdir
 132                 + " verbose=" + verbose + " resources=" + resources + '}';
 133     }
 134 
 135     @Override
 136     public void validate() throws PackagerException {
 137         if (outfile == null) {
 138             throw new PackagerException("ERR_MissingArgument", "-outfile");
 139         }
 140         if (resources.isEmpty()) {
 141             throw new PackagerException("ERR_MissingArgument", "-srcfiles (-srcdir)");
 142         }
 143         //otherwise it could be special case of "update jar"
 144         if (resources.size() != 1 && applicationClass == null) {
 145             throw new PackagerException("ERR_MissingArgument", "-appclass");
 146         }
 147     }
 148 }