< prev index next >

src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java

Print this page




 455                     });
 456 
 457     @SuppressWarnings("unchecked")
 458     static final BundlerParamInfo<Set<String>> ADD_MODULES =
 459             new StandardBundlerParam<>(
 460                     Arguments.CLIOptions.ADD_MODULES.getId(),
 461                     (Class<Set<String>>) (Object) Set.class,
 462                     p -> new LinkedHashSet<String>(),
 463                     (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split(",")))
 464             );
 465 
 466     @SuppressWarnings("unchecked")
 467     static final BundlerParamInfo<Set<String>> LIMIT_MODULES =
 468             new StandardBundlerParam<>(
 469                     "limit-modules",
 470                     (Class<Set<String>>) (Object) Set.class,
 471                     p -> new LinkedHashSet<String>(),
 472                     (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split(",")))
 473             );
 474 
 475     static boolean isRuntimeInstaller(Map<String, ? super Object> p) {
 476         if (p.containsKey(MODULE.getID()) ||
 477                 p.containsKey(MAIN_JAR.getID()) ||
 478                 p.containsKey(PREDEFINED_APP_IMAGE.getID())) {
 479             return false; // we are building or are given an application
 480         }
 481         // runtime installer requires --runtime-image, if this is false
 482         // here then we should have thrown error validating args.
 483         return p.containsKey(PREDEFINED_RUNTIME_IMAGE.getID());
 484     }
 485 
 486     static File getPredefinedAppImage(Map<String, ? super Object> p) {
 487         File applicationImage = null;
 488         if (PREDEFINED_APP_IMAGE.fetchFrom(p) != null) {
 489             applicationImage = PREDEFINED_APP_IMAGE.fetchFrom(p);
 490             Log.debug("Using App Image from " + applicationImage);
 491             if (!applicationImage.exists()) {
 492                 throw new RuntimeException(
 493                         MessageFormat.format(I18N.getString(
 494                                 "message.app-image-dir-does-not-exist"),
 495                                 PREDEFINED_APP_IMAGE.getID(),
 496                                 applicationImage.toString()));
 497             }
 498         }
 499         return applicationImage;
 500     }
 501 
 502     static void copyPredefinedRuntimeImage(
 503             Map<String, ? super Object> p,
 504             AbstractAppImageBuilder appBuilder)
 505             throws IOException , ConfigException {
 506         File image = PREDEFINED_RUNTIME_IMAGE.fetchFrom(p);
 507         if (!image.exists()) {
 508             throw new ConfigException(
 509                     MessageFormat.format(I18N.getString(
 510                     "message.runtime-image-dir-does-not-exist"),
 511                     PREDEFINED_RUNTIME_IMAGE.getID(),
 512                     image.toString()),
 513                     MessageFormat.format(I18N.getString(
 514                     "message.runtime-image-dir-does-not-exist.advice"),
 515                     PREDEFINED_RUNTIME_IMAGE.getID()));
 516         }
 517         // copy whole runtime, need to skip jmods and src.zip
 518         final List<String> excludes = Arrays.asList("jmods", "src.zip");
 519         IOUtils.copyRecursive(image.toPath(), appBuilder.getRoot(), excludes);
 520 
 521         // if module-path given - copy modules to appDir/mods
 522         List<Path> modulePath =
 523                 StandardBundlerParam.MODULE_PATH.fetchFrom(p);
 524         List<Path> defaultModulePath = getDefaultModulePath();
 525         Path dest = appBuilder.getAppModsDir();
 526 
 527         if (dest != null) {
 528             for (Path mp : modulePath) {
 529                 if (!defaultModulePath.contains(mp)) {
 530                     Files.createDirectories(dest);
 531                     IOUtils.copyRecursive(mp, dest);
 532                 }
 533             }
 534         }
 535 
 536         appBuilder.prepareApplicationFiles();
 537     }
 538 
 539     static void extractMainClassInfoFromAppResources(
 540             Map<String, ? super Object> params) {
 541         boolean hasMainClass = params.containsKey(MAIN_CLASS.getID());
 542         boolean hasMainJar = params.containsKey(MAIN_JAR.getID());
 543         boolean hasMainJarClassPath = params.containsKey(CLASSPATH.getID());




 455                     });
 456 
 457     @SuppressWarnings("unchecked")
 458     static final BundlerParamInfo<Set<String>> ADD_MODULES =
 459             new StandardBundlerParam<>(
 460                     Arguments.CLIOptions.ADD_MODULES.getId(),
 461                     (Class<Set<String>>) (Object) Set.class,
 462                     p -> new LinkedHashSet<String>(),
 463                     (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split(",")))
 464             );
 465 
 466     @SuppressWarnings("unchecked")
 467     static final BundlerParamInfo<Set<String>> LIMIT_MODULES =
 468             new StandardBundlerParam<>(
 469                     "limit-modules",
 470                     (Class<Set<String>>) (Object) Set.class,
 471                     p -> new LinkedHashSet<String>(),
 472                     (s, p) -> new LinkedHashSet<>(Arrays.asList(s.split(",")))
 473             );
 474 
 475     static boolean isRuntimeInstaller(Map<String, ? super Object> params) {
 476         if (params.containsKey(MODULE.getID()) ||
 477                 params.containsKey(MAIN_JAR.getID()) ||
 478                 params.containsKey(PREDEFINED_APP_IMAGE.getID())) {
 479             return false; // we are building or are given an application
 480         }
 481         // runtime installer requires --runtime-image, if this is false
 482         // here then we should have thrown error validating args.
 483         return params.containsKey(PREDEFINED_RUNTIME_IMAGE.getID());
 484     }
 485 
 486     static File getPredefinedAppImage(Map<String, ? super Object> params) {
 487         File applicationImage = null;
 488         if (PREDEFINED_APP_IMAGE.fetchFrom(params) != null) {
 489             applicationImage = PREDEFINED_APP_IMAGE.fetchFrom(params);
 490             Log.debug("Using App Image from " + applicationImage);
 491             if (!applicationImage.exists()) {
 492                 throw new RuntimeException(
 493                         MessageFormat.format(I18N.getString(
 494                                 "message.app-image-dir-does-not-exist"),
 495                                 PREDEFINED_APP_IMAGE.getID(),
 496                                 applicationImage.toString()));
 497             }
 498         }
 499         return applicationImage;
 500     }
 501 
 502     static void copyPredefinedRuntimeImage(
 503             Map<String, ? super Object> params,
 504             AbstractAppImageBuilder appBuilder)
 505             throws IOException , ConfigException {
 506         File image = PREDEFINED_RUNTIME_IMAGE.fetchFrom(params);
 507         if (!image.exists()) {
 508             throw new ConfigException(
 509                     MessageFormat.format(I18N.getString(
 510                     "message.runtime-image-dir-does-not-exist"),
 511                     PREDEFINED_RUNTIME_IMAGE.getID(),
 512                     image.toString()),
 513                     MessageFormat.format(I18N.getString(
 514                     "message.runtime-image-dir-does-not-exist.advice"),
 515                     PREDEFINED_RUNTIME_IMAGE.getID()));
 516         }
 517         // copy whole runtime, need to skip jmods and src.zip
 518         final List<String> excludes = Arrays.asList("jmods", "src.zip");
 519         IOUtils.copyRecursive(image.toPath(), appBuilder.getRoot(), excludes);
 520 
 521         // if module-path given - copy modules to appDir/mods
 522         List<Path> modulePath =
 523                 StandardBundlerParam.MODULE_PATH.fetchFrom(params);
 524         List<Path> defaultModulePath = getDefaultModulePath();
 525         Path dest = appBuilder.getAppModsDir();
 526 
 527         if (dest != null) {
 528             for (Path mp : modulePath) {
 529                 if (!defaultModulePath.contains(mp)) {
 530                     Files.createDirectories(dest);
 531                     IOUtils.copyRecursive(mp, dest);
 532                 }
 533             }
 534         }
 535 
 536         appBuilder.prepareApplicationFiles();
 537     }
 538 
 539     static void extractMainClassInfoFromAppResources(
 540             Map<String, ? super Object> params) {
 541         boolean hasMainClass = params.containsKey(MAIN_CLASS.getID());
 542         boolean hasMainJar = params.containsKey(MAIN_JAR.getID());
 543         boolean hasMainJarClassPath = params.containsKey(CLASSPATH.getID());


< prev index next >