--- old/modules/fxpackager/src/main/java/com/oracle/bundlers/mac/MacBaseInstallerBundler.java 2014-03-13 12:59:30.000000000 -0600 +++ new/modules/fxpackager/src/main/java/com/oracle/bundlers/mac/MacBaseInstallerBundler.java 2014-03-13 12:59:30.000000000 -0600 @@ -31,84 +31,134 @@ 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.io.IOException; -import java.util.Arrays; +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 APP_BUNDLER = new StandardBundlerParam<>( - "Mac App Bundler", - "Creates a .app bundle for the Mac", - "MacAppBundler", + I18N.getString("param.app-bundler.name"), + I18N.getString("param.app-bundle.description"), + "mac.app.bundler", MacAppBundler.class, null, params -> new MacAppBundler(), false, - s -> null); + (s, p) -> null); protected final BundlerParamInfo 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, + 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, File::new); + false, + (s, p) -> new File(s)); + public static final StandardBundlerParam 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)); - public static final StandardBundlerParam 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 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 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 CONFIG_ROOT = new StandardBundlerParam<>( - "", "", "configRoot", File.class, null, + I18N.getString("param.config-root.name"), + I18N.getString("param.config-root.description"), + "configRoot", + File.class, + null, params -> { - File imagesRoot = new File(StandardBundlerParam.BUILD_ROOT.fetchFrom(params), "macosx"); + File imagesRoot = new File(BUILD_ROOT.fetchFrom(params), "macosx"); imagesRoot.mkdirs(); return imagesRoot; }, - false, s -> null); - + false, (s, p) -> null); - public static File getPredefinedImage(Map p) throws ConfigException { + public static File getPredefinedImage(Map p) { 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"); + throw new RuntimeException( + MessageFormat.format(I18N.getString("message.app-image-dir-does-not-exist"), MAC_APP_IMAGE.getID(), applicationImage.toString())); } } return applicationImage; } - protected boolean prepareAppBundle(Map p) throws ConfigException { + protected void validateAppImageAndBundeler(Map 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 p) { if (getPredefinedImage(p) != null) { - return true; + return null; } File appImageRoot = APP_IMAGE_BUILD_ROOT.fetchFrom(p); - File appDir = APP_BUNDLER.fetchFrom(p).doBundle(p, appImageRoot, true); - return appDir != null; + return APP_BUNDLER.fetchFrom(p).doBundle(p, appImageRoot, true); + } + + protected File prepareDaemonBundle(Map p) throws ConfigException { + File daemonImageRoot = DAEMON_IMAGE_BUILD_ROOT.fetchFrom(p); + return DAEMON_BUNDLER.fetchFrom(p).doBundle(p, daemonImageRoot, true); }