8153038: The set of jlink plugins enabled by default should be the same via CLI or jlink API

Reviewed-by: jlaskey
This commit is contained in:
Athijegannathan Sundararajan 2016-11-16 19:52:20 +05:30
parent 94dc401425
commit 5efdbcb1fb
2 changed files with 21 additions and 2 deletions

View File

@ -27,6 +27,7 @@ package jdk.tools.jlink.internal;
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 final class Jlink {
*/
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 @@ public final class Jlink {
}
}
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.
*

View File

@ -118,8 +118,6 @@ public final class AppRuntimeImageBuilder {
null));
}
plugins.add(Jlink.newPlugin("installed-modules", Collections.emptyMap(), null));
// build the image
Jlink.PluginsConfiguration pluginConfig = new Jlink.PluginsConfiguration(
plugins, new DefaultImageBuilder(outputDir), null);