< prev index next >

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java

Print this page




 240         Objects.requireNonNull(config);
 241         Objects.requireNonNull(config.getOutput());
 242         plugins = plugins == null ? new PluginsConfiguration() : plugins;
 243 
 244         if (config.getModulepaths().isEmpty()) {
 245             throw new Exception("Empty module paths");
 246         }
 247 
 248         ModuleFinder finder
 249                 = newModuleFinder(config.getModulepaths(), config.getLimitmods(), config.getModules());
 250 
 251         // First create the image provider
 252         ImageProvider imageProvider
 253                 = createImageProvider(finder,
 254                                       checkAddMods(config.getModules()),
 255                                       config.getLimitmods(),
 256                                       config.getByteOrder(),
 257                                       null);
 258 
 259         // Then create the Plugin Stack
 260         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(plugins);
 261 
 262         //Ask the stack to proceed;
 263         stack.operate(imageProvider);
 264     }
 265 
 266     /*
 267      * Jlink API entry point.
 268      */
 269     public static void postProcessImage(ExecutableImage image, List<Plugin> postProcessorPlugins)
 270             throws Exception {
 271         Objects.requireNonNull(image);
 272         Objects.requireNonNull(postProcessorPlugins);
 273         PluginsConfiguration config = new PluginsConfiguration(postProcessorPlugins);
 274         ImagePluginStack stack = ImagePluginConfiguration.
 275                 parseConfiguration(config);
 276 
 277         stack.operate((ImagePluginStack stack1) -> image);
 278     }
 279 
 280     private void postProcessOnly(Path existingImage) throws Exception {


 291             throw taskHelper.newBadArgs("err.output.must.be.specified").showUsage(true);
 292         }
 293         ModuleFinder finder
 294                 = newModuleFinder(options.modulePath, options.limitMods, options.addMods);
 295         try {
 296             options.addMods = checkAddMods(options.addMods);
 297         } catch (IllegalArgumentException ex) {
 298             throw taskHelper.newBadArgs("err.mods.must.be.specified", "--add-modules")
 299                     .showUsage(true);
 300         }
 301         // First create the image provider
 302         ImageProvider imageProvider
 303                 = createImageProvider(finder,
 304                         options.addMods,
 305                         options.limitMods,
 306                         options.endian,
 307                         options.packagedModulesPath);
 308 
 309         // Then create the Plugin Stack
 310         ImagePluginStack stack = ImagePluginConfiguration.
 311                 parseConfiguration(taskHelper.getPluginsConfig(options.output));
 312 
 313         //Ask the stack to proceed
 314         stack.operate(imageProvider);
 315     }
 316 
 317     private static Set<String> checkAddMods(Set<String> addMods) {
 318         if (addMods.isEmpty()) {
 319             throw new IllegalArgumentException("no modules to add");
 320         }
 321         return addMods;
 322     }
 323 
 324     public static ModuleFinder newModuleFinder(List<Path> paths,
 325                                                Set<String> limitMods,
 326                                                Set<String> addMods)
 327     {
 328         ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[0]));
 329 
 330         // jmods are located at link-time
 331         if (finder instanceof ConfigurableModuleFinder) {




 240         Objects.requireNonNull(config);
 241         Objects.requireNonNull(config.getOutput());
 242         plugins = plugins == null ? new PluginsConfiguration() : plugins;
 243 
 244         if (config.getModulepaths().isEmpty()) {
 245             throw new Exception("Empty module paths");
 246         }
 247 
 248         ModuleFinder finder
 249                 = newModuleFinder(config.getModulepaths(), config.getLimitmods(), config.getModules());
 250 
 251         // First create the image provider
 252         ImageProvider imageProvider
 253                 = createImageProvider(finder,
 254                                       checkAddMods(config.getModules()),
 255                                       config.getLimitmods(),
 256                                       config.getByteOrder(),
 257                                       null);
 258 
 259         // Then create the Plugin Stack
 260         ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(plugins, config.getModules());
 261 
 262         //Ask the stack to proceed;
 263         stack.operate(imageProvider);
 264     }
 265 
 266     /*
 267      * Jlink API entry point.
 268      */
 269     public static void postProcessImage(ExecutableImage image, List<Plugin> postProcessorPlugins)
 270             throws Exception {
 271         Objects.requireNonNull(image);
 272         Objects.requireNonNull(postProcessorPlugins);
 273         PluginsConfiguration config = new PluginsConfiguration(postProcessorPlugins);
 274         ImagePluginStack stack = ImagePluginConfiguration.
 275                 parseConfiguration(config);
 276 
 277         stack.operate((ImagePluginStack stack1) -> image);
 278     }
 279 
 280     private void postProcessOnly(Path existingImage) throws Exception {


 291             throw taskHelper.newBadArgs("err.output.must.be.specified").showUsage(true);
 292         }
 293         ModuleFinder finder
 294                 = newModuleFinder(options.modulePath, options.limitMods, options.addMods);
 295         try {
 296             options.addMods = checkAddMods(options.addMods);
 297         } catch (IllegalArgumentException ex) {
 298             throw taskHelper.newBadArgs("err.mods.must.be.specified", "--add-modules")
 299                     .showUsage(true);
 300         }
 301         // First create the image provider
 302         ImageProvider imageProvider
 303                 = createImageProvider(finder,
 304                         options.addMods,
 305                         options.limitMods,
 306                         options.endian,
 307                         options.packagedModulesPath);
 308 
 309         // Then create the Plugin Stack
 310         ImagePluginStack stack = ImagePluginConfiguration.
 311                 parseConfiguration(taskHelper.getPluginsConfig(options.output), options.addMods);
 312 
 313         //Ask the stack to proceed
 314         stack.operate(imageProvider);
 315     }
 316 
 317     private static Set<String> checkAddMods(Set<String> addMods) {
 318         if (addMods.isEmpty()) {
 319             throw new IllegalArgumentException("no modules to add");
 320         }
 321         return addMods;
 322     }
 323 
 324     public static ModuleFinder newModuleFinder(List<Path> paths,
 325                                                Set<String> limitMods,
 326                                                Set<String> addMods)
 327     {
 328         ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[0]));
 329 
 330         // jmods are located at link-time
 331         if (finder instanceof ConfigurableModuleFinder) {


< prev index next >