# HG changeset patch # User sundar # Date 1479306140 -19800 # Node ID dd0623828f16458c0506c9fd8ce0c99e47710e82 # Parent 38bea40bb09ba4c3e17511f1daadf9e254f5a68c 8153038: The set of jlink plugins enabled by default should be the same via CLI or jlink API Reviewed-by: jlaskey diff -r 38bea40bb09b -r dd0623828f16 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java Tue Nov 15 15:52:27 2016 +0300 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Jlink.java Wed Nov 16 19:52:20 2016 +0530 @@ -27,6 +27,7 @@ import java.lang.reflect.Layer; import java.nio.ByteOrder; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -278,6 +279,13 @@ */ public void build(JlinkConfiguration config, PluginsConfiguration pluginsConfig) { Objects.requireNonNull(config); + if (pluginsConfig == null) { + pluginsConfig = new PluginsConfiguration(); + } + + // add all auto-enabled plugins from boot layer + pluginsConfig = addAutoEnabledPlugins(pluginsConfig); + try { JlinkTask.createImage(config, pluginsConfig); } catch (Exception ex) { @@ -285,6 +293,19 @@ } } + private PluginsConfiguration addAutoEnabledPlugins(PluginsConfiguration pluginsConfig) { + List plugins = new ArrayList<>(pluginsConfig.getPlugins()); + List bootPlugins = PluginRepository.getPlugins(Layer.boot()); + for (Plugin bp : bootPlugins) { + if (Utils.isAutoEnabled(bp)) { + bp.configure(Collections.emptyMap()); + plugins.add(bp); + } + } + return new PluginsConfiguration(plugins, pluginsConfig.getImageBuilder(), + pluginsConfig.getLastSorterPluginName()); + } + /** * Post process the image with a plugin configuration. * diff -r 38bea40bb09b -r dd0623828f16 jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java Tue Nov 15 15:52:27 2016 +0300 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java Wed Nov 16 19:52:20 2016 +0530 @@ -118,8 +118,6 @@ null)); } - plugins.add(Jlink.newPlugin("installed-modules", Collections.emptyMap(), null)); - // build the image Jlink.PluginsConfiguration pluginConfig = new Jlink.PluginsConfiguration( plugins, new DefaultImageBuilder(outputDir), null);