8153038: The set of jlink plugins enabled by default should be the same via CLI or jlink API
Reviewed-by: jlaskey
--- 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<Plugin> plugins = new ArrayList<>(pluginsConfig.getPlugins());
+ List<Plugin> 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.
*
--- 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);