modules/fxpackager/src/main/java/com/oracle/bundlers/mac/MacBaseInstallerBundler.java

Print this page

        

*** 29,116 **** import com.oracle.bundlers.BundlerParamInfo; import com.oracle.bundlers.StandardBundlerParam; import com.sun.javafx.tools.packager.bundlers.BundleType; import com.sun.javafx.tools.packager.bundlers.ConfigException; import com.sun.javafx.tools.packager.bundlers.MacAppBundler; import java.io.File; ! import java.io.IOException; ! import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashSet; import java.util.Map; public abstract class MacBaseInstallerBundler extends AbstractBundler { //This could be generalized more to be for any type of Image Bundler protected final BundlerParamInfo<MacAppBundler> APP_BUNDLER = new StandardBundlerParam<>( ! "Mac App Bundler", ! "Creates a .app bundle for the Mac", ! "MacAppBundler", MacAppBundler.class, null, params -> new MacAppBundler(), false, ! s -> null); protected final BundlerParamInfo<File> APP_IMAGE_BUILD_ROOT = new StandardBundlerParam<>( ! "", ! "This is temporary location built by the packager that is the root of the image application", ! "appImageRoot", File.class, null, params -> { File imageDir = IMAGES_ROOT.fetchFrom(params); return new File(imageDir, getID()+ ".image"); }, ! false, File::new); ! ! ! public static final StandardBundlerParam<File> MAC_APP_IMAGE = ! new StandardBundlerParam<>( ! "Image Directory", ! "Location of the image that will be used to build either a DMG or PKG installer.", "mac.app.image", File.class, null, params -> null, false, ! File::new ! ); protected final BundlerParamInfo<File> CONFIG_ROOT = new StandardBundlerParam<>( ! "", "", "configRoot", File.class, null, params -> { ! File imagesRoot = new File(StandardBundlerParam.BUILD_ROOT.fetchFrom(params), "macosx"); imagesRoot.mkdirs(); return imagesRoot; }, ! false, s -> null); ! ! public static File getPredefinedImage(Map<String, ? super Object> p) throws ConfigException { File applicationImage = null; if (MAC_APP_IMAGE.fetchFrom(p) != null) { applicationImage = MAC_APP_IMAGE.fetchFrom(p); if (!applicationImage.exists()) { ! throw new ConfigException( ! "Specified image directory " + MAC_APP_IMAGE.getID()+ ": " + applicationImage.toString() + " does not exists", ! "Confirm that the value for " + MAC_APP_IMAGE.getID()+ " exists"); } } return applicationImage; } ! protected boolean prepareAppBundle(Map<String, ? super Object> p) throws ConfigException { if (getPredefinedImage(p) != null) { ! return true; } File appImageRoot = APP_IMAGE_BUILD_ROOT.fetchFrom(p); ! File appDir = APP_BUNDLER.fetchFrom(p).doBundle(p, appImageRoot, true); ! return appDir != null; } @Override public Collection<BundlerParamInfo<?>> getBundleParameters() { --- 29,166 ---- import com.oracle.bundlers.BundlerParamInfo; import com.oracle.bundlers.StandardBundlerParam; import com.sun.javafx.tools.packager.bundlers.BundleType; import com.sun.javafx.tools.packager.bundlers.ConfigException; import com.sun.javafx.tools.packager.bundlers.MacAppBundler; + import com.sun.javafx.tools.packager.bundlers.UnsupportedPlatformException; import java.io.File; ! import java.text.MessageFormat;import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashSet; import java.util.Map; + import java.util.ResourceBundle; + + import static com.oracle.bundlers.StandardBundlerParam.*; public abstract class MacBaseInstallerBundler extends AbstractBundler { + private static final ResourceBundle I18N = + ResourceBundle.getBundle("com.oracle.bundlers.mac.MacBaseInstallerBundler"); + //This could be generalized more to be for any type of Image Bundler protected final BundlerParamInfo<MacAppBundler> APP_BUNDLER = new StandardBundlerParam<>( ! I18N.getString("param.app-bundler.name"), ! I18N.getString("param.app-bundle.description"), ! "mac.app.bundler", MacAppBundler.class, null, params -> new MacAppBundler(), false, ! (s, p) -> null); protected final BundlerParamInfo<File> APP_IMAGE_BUILD_ROOT = new StandardBundlerParam<>( ! I18N.getString("param.app-image-build-root.name"), ! I18N.getString("param.app-image-build-root.description"), ! "mac.app.imageRoot", ! File.class, ! null, params -> { File imageDir = IMAGES_ROOT.fetchFrom(params); + if (!imageDir.exists()) imageDir.mkdirs(); return new File(imageDir, getID()+ ".image"); }, ! false, ! (s, p) -> new File(s)); ! public static final StandardBundlerParam<File> MAC_APP_IMAGE = new StandardBundlerParam<>( ! I18N.getString("param.app-image.name"), ! I18N.getString("param.app-image.description"), "mac.app.image", File.class, null, params -> null, false, ! (s, p) -> new File(s)); ! + protected final BundlerParamInfo<MacDaemonBundler> DAEMON_BUNDLER = new StandardBundlerParam<>( + I18N.getString("param.daemon-bundler.name"), + I18N.getString("param.daemon-bundler.description"), + "mac.daemon.bundler", + MacDaemonBundler.class, + null, + params -> new MacDaemonBundler(), + false, + (s, p) -> null); + + + protected final BundlerParamInfo<File> DAEMON_IMAGE_BUILD_ROOT = new StandardBundlerParam<>( + I18N.getString("param.daemon-image-build-root.name"), + I18N.getString("param.daemon-image-build-root.description"), + "mac.daemon.image", + File.class, + null, + params -> { + File imageDir = IMAGES_ROOT.fetchFrom(params); + if (!imageDir.exists()) imageDir.mkdirs(); + return new File(imageDir, getID()+ ".daemon"); + }, + false, + (s, p) -> new File(s)); protected final BundlerParamInfo<File> CONFIG_ROOT = new StandardBundlerParam<>( ! I18N.getString("param.config-root.name"), ! I18N.getString("param.config-root.description"), ! "configRoot", ! File.class, ! null, params -> { ! File imagesRoot = new File(BUILD_ROOT.fetchFrom(params), "macosx"); imagesRoot.mkdirs(); return imagesRoot; }, ! false, (s, p) -> null); ! public static File getPredefinedImage(Map<String, ? super Object> p) { File applicationImage = null; if (MAC_APP_IMAGE.fetchFrom(p) != null) { applicationImage = MAC_APP_IMAGE.fetchFrom(p); if (!applicationImage.exists()) { ! throw new RuntimeException( ! MessageFormat.format(I18N.getString("message.app-image-dir-does-not-exist"), MAC_APP_IMAGE.getID(), applicationImage.toString())); } } return applicationImage; } ! protected void validateAppImageAndBundeler(Map<String, ? super Object> params) throws ConfigException, UnsupportedPlatformException { ! if (MAC_APP_IMAGE.fetchFrom(params) != null) { ! File applicationImage = MAC_APP_IMAGE.fetchFrom(params); ! if (!applicationImage.exists()) { ! throw new ConfigException( ! MessageFormat.format(I18N.getString("message.app-image-dir-does-not-exist"), MAC_APP_IMAGE.getID(), applicationImage.toString()), ! MessageFormat.format(I18N.getString("message.app-image-dir-does-not-exist.advice"), MAC_APP_IMAGE.getID())); ! } ! } else { ! APP_BUNDLER.fetchFrom(params).doValidate(params); ! } ! } ! ! protected File prepareAppBundle(Map<String, ? super Object> p) { if (getPredefinedImage(p) != null) { ! return null; } File appImageRoot = APP_IMAGE_BUILD_ROOT.fetchFrom(p); ! return APP_BUNDLER.fetchFrom(p).doBundle(p, appImageRoot, true); ! } ! ! protected File prepareDaemonBundle(Map<String, ? super Object> p) throws ConfigException { ! File daemonImageRoot = DAEMON_IMAGE_BUILD_ROOT.fetchFrom(p); ! return DAEMON_BUNDLER.fetchFrom(p).doBundle(p, daemonImageRoot, true); } @Override public Collection<BundlerParamInfo<?>> getBundleParameters() {