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 public class CreateJarParams extends CommonParams { 35 36 final List<PackagerResource> resources = new ArrayList<PackagerResource>(); 37 38 String applicationClass; 39 String fallbackClass; 40 String preloader; 41 String classpath; 42 Map<String, String> manifestAttrs; 43 boolean embedLauncher = true; 44 boolean css2bin = true; 45 String outfile; 46 String fxVersion = PackagerLib.JAVAFX_VERSION; 47 Boolean allPermissions = false; 48 String codebase; 49 50 List<String> arguments; 51 List<Param> params; 52 53 public void setArguments(List<String> args) { 54 this.arguments = args; 55 } 56 57 public void setParams(List<Param> params) { 58 this.params = params; 59 } 60 61 public void setApplicationClass(String applicationClass) { 62 this.applicationClass = applicationClass; 63 } 64 65 public void setPreloader(String preloader) { 66 this.preloader = preloader; 67 } 68 69 public void setFallback(String fallback) { 70 this.fallbackClass = fallback; 71 } 72 73 public void setClasspath(String classpath) { 74 this.classpath = classpath; 75 } 76 77 public void setCss2bin(boolean css2bin) { 78 this.css2bin = css2bin; 79 } 80 81 /** 82 * In JKD8/FX8 launcher is never embedded, 83 * app must use main to call Application launcher() 84 * @deprecated 85 * @param embedLauncher 86 */ 87 public void setEmbedLauncher(boolean embedLauncher) { 88 this.embedLauncher = embedLauncher; 89 } 90 91 public void setOutfile(String outfile) { 92 this.outfile = outfile; 93 } 94 95 public void setManifestAttrs(Map<String, String> manifestAttrs) { 96 this.manifestAttrs = manifestAttrs; 97 } 98 99 public void setFxVersion(String fxVersion) { 100 this.fxVersion = fxVersion; 101 } 102 103 public void setAllPermissions(Boolean allPermissions) { 104 this.allPermissions = allPermissions; 105 } 106 107 public void setCodebase(String codebase) { 108 this.codebase = codebase; 109 } 110 111 @Override 112 public void addResource(File baseDir, String path) { 113 resources.add(new PackagerResource(baseDir, path)); 114 } 115 116 @Override 117 public void addResource(File baseDir, File file) { 118 resources.add(new PackagerResource(baseDir, file)); 119 } 120 121 @Override 122 public String toString() { 123 return "CreateJarParams{" + "applicationClass=" + applicationClass 124 + " preloader=" + preloader + " classpath=" + classpath 125 + " manifestAttrs=" + manifestAttrs 126 + " embedLauncher=deprecated" + " css2bin=" + css2bin 127 + " outfile=" + outfile + " sdkHome=" + fxVersion + '}' 128 + " CommonParams{" + "outdir=" + outdir 129 + " verbose=" + verbose + " resources=" + resources + '}'; 130 } 131 132 @Override 133 public void validate() throws PackagerException { 134 if (outfile == null) { 135 throw new PackagerException("ERR_MissingArgument", "-outfile"); 136 } 137 if (resources.isEmpty()) { 138 throw new PackagerException("ERR_MissingArgument", "-srcfiles (-srcdir)"); 139 } 140 //otherwise it could be special case of "update jar" 141 if (resources.size() != 1 && applicationClass == null) { 142 throw new PackagerException("ERR_MissingArgument", "-appclass"); 143 } 144 } 145 }