26
26
import java .util .Map ;
27
27
import java .util .Set ;
28
28
import java .util .StringJoiner ;
29
- import java .util .stream .Collectors ;
30
29
import java .util .stream .Stream ;
31
30
32
31
import static org .elasticsearch .cli .Terminal .Verbosity .VERBOSE ;
32
+ import static org .elasticsearch .plugins .cli .InstallPluginAction .PLUGINS_CONVERTED_TO_MODULES ;
33
33
34
34
/**
35
35
* An action for the plugin CLI to remove plugins from Elasticsearch.
@@ -116,6 +116,7 @@ private void ensurePluginsNotUsedByOtherPlugins(List<PluginDescriptor> plugins)
116
116
117
117
private void checkCanRemove (PluginDescriptor plugin ) throws UserException {
118
118
String pluginId = plugin .getId ();
119
+
119
120
final Path pluginDir = env .pluginsFile ().resolve (pluginId );
120
121
final Path pluginConfigDir = env .configFile ().resolve (pluginId );
121
122
final Path removing = env .pluginsFile ().resolve (".removing-" + pluginId );
@@ -127,12 +128,19 @@ private void checkCanRemove(PluginDescriptor plugin) throws UserException {
127
128
*/
128
129
if ((Files .exists (pluginDir ) == false && Files .exists (pluginConfigDir ) == false && Files .exists (removing ) == false )
129
130
|| (Files .exists (pluginDir ) == false && Files .exists (pluginConfigDir ) && this .purge == false )) {
130
- final String message = String .format (
131
- Locale .ROOT ,
132
- "plugin [%s] not found; run 'elasticsearch-plugin list' to get list of installed plugins" ,
133
- pluginId
134
- );
135
- throw new UserException (ExitCodes .CONFIG , message );
131
+
132
+ if (PLUGINS_CONVERTED_TO_MODULES .contains (pluginId )) {
133
+ terminal .errorPrintln (
134
+ "plugin [" + pluginId + "] is no longer a plugin but instead a module packaged with this distribution of Elasticsearch"
135
+ );
136
+ } else {
137
+ final String message = String .format (
138
+ Locale .ROOT ,
139
+ "plugin [%s] not found; run 'elasticsearch-plugin list' to get list of installed plugins" ,
140
+ pluginId
141
+ );
142
+ throw new UserException (ExitCodes .CONFIG , message );
143
+ }
136
144
}
137
145
138
146
final Path pluginBinDir = env .binFile ().resolve (pluginId );
@@ -159,15 +167,15 @@ private void removePlugin(PluginDescriptor plugin) throws IOException {
159
167
*/
160
168
if (Files .exists (pluginDir )) {
161
169
try (Stream <Path > paths = Files .list (pluginDir )) {
162
- pluginPaths .addAll (paths .collect ( Collectors . toList () ));
170
+ pluginPaths .addAll (paths .toList ());
163
171
}
164
172
terminal .println (VERBOSE , "removing [" + pluginDir + "]" );
165
173
}
166
174
167
175
final Path pluginBinDir = env .binFile ().resolve (pluginId );
168
176
if (Files .exists (pluginBinDir )) {
169
177
try (Stream <Path > paths = Files .list (pluginBinDir )) {
170
- pluginPaths .addAll (paths .collect ( Collectors . toList () ));
178
+ pluginPaths .addAll (paths .toList ());
171
179
}
172
180
pluginPaths .add (pluginBinDir );
173
181
terminal .println (VERBOSE , "removing [" + pluginBinDir + "]" );
@@ -176,7 +184,7 @@ private void removePlugin(PluginDescriptor plugin) throws IOException {
176
184
if (Files .exists (pluginConfigDir )) {
177
185
if (this .purge ) {
178
186
try (Stream <Path > paths = Files .list (pluginConfigDir )) {
179
- pluginPaths .addAll (paths .collect ( Collectors . toList () ));
187
+ pluginPaths .addAll (paths .toList ());
180
188
}
181
189
pluginPaths .add (pluginConfigDir );
182
190
terminal .println (VERBOSE , "removing [" + pluginConfigDir + "]" );
0 commit comments