modules/fxpackager/src/main/java/com/oracle/bundlers/AbstractBundler.java
Print this page
@@ -24,11 +24,10 @@
*/
package com.oracle.bundlers;
import com.oracle.bundlers.windows.WindowsBundlerParam;
-import com.sun.javafx.tools.ant.DeployFXTask;
import com.sun.javafx.tools.packager.Log;
import com.sun.javafx.tools.packager.bundlers.ConfigException;
import com.sun.javafx.tools.packager.bundlers.IOUtils;
import com.sun.javafx.tools.packager.bundlers.RelativeFileSet;
@@ -38,48 +37,36 @@
import java.io.InputStream;
import java.net.URL;
import java.text.MessageFormat;
import java.util.*;
+import static com.oracle.bundlers.StandardBundlerParam.*;
+
public abstract class AbstractBundler implements Bundler {
private static final ResourceBundle I18N =
ResourceBundle.getBundle("com.oracle.bundlers.AbstractBundler");
- protected boolean verbose = false;
-
public static final BundlerParamInfo<File> IMAGES_ROOT = new WindowsBundlerParam<>(
I18N.getString("param.images-root.name"),
I18N.getString("param.images-root.description"),
- "imagesRoot", //KEY
+ "imagesRoot",
File.class, null,
- params -> {
- File imagesRoot = new File(StandardBundlerParam.BUILD_ROOT.fetchFrom(params), "images");
- imagesRoot.mkdirs();
- return imagesRoot;
- },
- false, s -> null);
+ params -> new File(BUILD_ROOT.fetchFrom(params), "images"),
+ false, (s, p) -> null);
//do not use file separator -
- // we use it for classpath lookup and there / are not platfrom specific
+ // we use it for classpath lookup and there / are not platform specific
public final static String BUNDLER_PREFIX = "package/";
protected static final String JAVAFX_LAUNCHER_CLASS = "com.javafx.main.Main";
protected Class baseResourceLoader = null;
- public boolean isVerbose() {
- return verbose;
- }
-
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
//helper method to test if required files are present in the runtime
public void testRuntime(Map<String, ? super Object> p, String[] file) throws ConfigException {
- RelativeFileSet runtime = StandardBundlerParam.RUNTIME.fetchFrom(p);
+ RelativeFileSet runtime = RUNTIME.fetchFrom(p);
if (runtime == null) {
return; //null runtime is ok (request to use system)
}
Set<String> rfiles = runtime.getIncludedFiles();
for (String aFile : file) {
@@ -92,13 +79,13 @@
I18N.getString("error.jre-missing-file.advice"));
}
protected void fetchResource(
String publicName, String category,
- String defaultName, File result)
+ String defaultName, File result, boolean verbose)
throws IOException {
- URL u = locateResource(publicName, category, defaultName);
+ URL u = locateResource(publicName, category, defaultName, verbose);
if (u != null) {
IOUtils.copyFromURL(u, result);
} else {
if (verbose) {
Log.info(MessageFormat.format(I18N.getString("message.using-default-resource"), category == null ? "" : "[" + category + "] ", publicName));
@@ -106,13 +93,13 @@
}
}
protected void fetchResource(
String publicName, String category,
- File defaultFile, File result)
+ File defaultFile, File result, boolean verbose)
throws IOException {
- URL u = locateResource(publicName, category, null);
+ URL u = locateResource(publicName, category, null, verbose);
if (u != null) {
IOUtils.copyFromURL(u, result);
} else {
IOUtils.copyFile(defaultFile, result);
if (verbose) {
@@ -120,11 +107,11 @@
}
}
}
private URL locateResource(String publicName, String category,
- String defaultName) throws IOException {
+ String defaultName, boolean verbose) throws IOException {
URL u = null;
boolean custom = false;
if (publicName != null) {
u = baseResourceLoader.getClassLoader().getResource(publicName);
custom = (u != null);
@@ -143,12 +130,13 @@
}
return u;
}
protected String preprocessTextResource(String publicName, String category,
- String defaultName, Map<String, String> pairs) throws IOException {
- URL u = locateResource(publicName, category, defaultName);
+ String defaultName, Map<String, String> pairs,
+ boolean verbose) throws IOException {
+ URL u = locateResource(publicName, category, defaultName, verbose);
InputStream inp = u.openStream();
if (inp == null) {
throw new RuntimeException("Jar corrupt? No "+defaultName+" resource!");
}
@@ -175,12 +163,6 @@
Log.info("###### Parameters for " + getName());
for(Map.Entry<String, ? super Object> e: p.entrySet()) {
Log.info(" id: " + e.getKey() + " value: " + e.getValue());
}
}
-
- public void validateDynamicArguments(List<DeployFXTask.BundleArgument> dynamicArgs) {
- for(BundlerParamInfo info: getBundleParameters()) {
- //TODO
- }
- }
}