Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1309: Improve plugin managment #229

Merged
merged 31 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c7ee250
no duplicates in pluginsMap, if plugin id already exists then overwri…
diiinesh Feb 26, 2024
290fc0d
Merge branch 'main' into Enhancement/improve_plugin_management
diiinesh Feb 26, 2024
49f0878
Merge branch 'main' into Enhancement/improve_plugin_management
diiinesh Mar 1, 2024
cb6efc7
changed asserts to assertThat
diiinesh Mar 4, 2024
cd0f477
removes paths import
diiinesh Mar 11, 2024
7c65c65
Merge branch 'main' into Enhancement/improve_plugin_management
diiinesh Mar 11, 2024
016e237
modified ide test context such that copy mutation is false
diiinesh Mar 11, 2024
e92269e
Merge remote-tracking branch 'origin/Enhancement/improve_plugin_manag…
diiinesh Mar 11, 2024
5f4e9b2
changed testcontext declaration
diiinesh Mar 15, 2024
f4282c2
changed graalvm version to 21.0.2
diiinesh Mar 15, 2024
a16eb07
Merge branch 'main' into Enhancement/improve_plugin_management
diiinesh Mar 22, 2024
5d64d82
pulled latest changes from main
diiinesh Mar 22, 2024
dae2c77
Merge branch 'main' into Enhancement/improve_plugin_management
diiinesh Mar 22, 2024
c131c28
Merge remote-tracking branch 'origin/Enhancement/improve_plugin_manag…
diiinesh Apr 18, 2024
13c59b8
modified getPluginsMap, getPlugin, doInstall
diiinesh Apr 19, 2024
14db733
Merge branch 'main' into Enhancement/improve_plugin_management
diiinesh Apr 19, 2024
6029fe6
Merge branch 'main' into Enhancement/improve_plugin_management
diiinesh Apr 22, 2024
264c118
Update cli/src/main/java/com/devonfw/tools/ide/tool/PluginMaps.java
diiinesh Apr 30, 2024
48dfda3
Update cli/src/main/java/com/devonfw/tools/ide/tool/PluginBasedComman…
diiinesh Apr 30, 2024
eba359b
Update cli/src/main/java/com/devonfw/tools/ide/tool/PluginBasedComman…
diiinesh Apr 30, 2024
ba9662d
Merge branch 'refs/heads/main' into Enhancement/improve_plugin_manage…
diiinesh May 14, 2024
939533d
Merge remote-tracking branch 'origin/Enhancement/improve_plugin_manag…
diiinesh May 14, 2024
5fb2f3a
Merge branch 'main' into Enhancement/improve_plugin_management
diiinesh May 14, 2024
2d479cf
Merge remote-tracking branch 'origin/Enhancement/improve_plugin_manag…
diiinesh May 14, 2024
8712120
added some imports and made some adjustments on recent changes
diiinesh May 14, 2024
d16b836
included usage of PluginMaps.java
diiinesh May 17, 2024
713a3c6
Merge branch 'main' into Enhancement/improve_plugin_management
hohwille May 17, 2024
481c08d
initialized pluginMaps to avoid nullpointererror
diiinesh May 21, 2024
96dc18e
Merge branch 'main' into Enhancement/improve_plugin_management
diiinesh May 21, 2024
1c0a600
Merge branch 'main' into Enhancement/improve_plugin_management
diiinesh May 24, 2024
29004f5
Merge branch 'main' into Enhancement/improve_plugin_management
hohwille May 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
diiinesh marked this conversation as resolved.
Show resolved Hide resolved
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -68,8 +69,20 @@ private void loadPluginsFromDirectory(Map<String, PluginDescriptor> map, Path pl
if (filename.endsWith(IdeContext.EXT_PROPERTIES) && Files.exists(child)) {
PluginDescriptor descriptor = PluginDescriptorImpl.of(child, this.context, isPluginUrlNeeded());

// Priority to user-specific plugins
map.put(descriptor.getName(), descriptor);
// Check if plugin with same id exists
boolean pluginExists = map.values().stream()
.anyMatch(existingDescriptor -> existingDescriptor.getId().equals(descriptor.getId()));

if (pluginExists) {
// Plugin with same id already exists, overwrite it
map.entrySet().stream()
.filter(entry -> entry.getValue().getId().equals(descriptor.getId()))
.findFirst()
.ifPresent(entry -> entry.setValue(descriptor));
} else {
// Plugin does not exist, add it normally to the map
map.put(descriptor.getName(), descriptor);
}
}
}
} catch (IOException e) {
Expand Down Expand Up @@ -146,7 +159,7 @@ public void uninstallPlugin(PluginDescriptor plugin) {

/**
* @param key the filename of the properties file configuring the requested plugin (typically excluding the
* ".properties" extension).
* ".properties" extension).
* @return the {@link PluginDescriptor} for the given {@code key}.
*/
public PluginDescriptor getPlugin(String key) {
Expand Down Expand Up @@ -191,7 +204,7 @@ protected boolean doInstall(boolean silent) {

/**
* @param plugin the in{@link PluginDescriptor#isActive() active} {@link PluginDescriptor} that is skipped for regular
* plugin installation.
* plugin installation.
*/
protected void handleInstall4InactivePlugin(PluginDescriptor plugin) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
package com.devonfw.tools.ide.tool;

import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.util.Map;
import java.util.Set;

import org.junit.jupiter.api.Test;

import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.AbstractIdeContextTest;
import com.devonfw.tools.ide.context.IdeTestContext;
import com.devonfw.tools.ide.tool.ide.PluginDescriptor;
import org.junit.jupiter.api.Test;

import java.util.Map;

import static org.junit.jupiter.api.Assertions.*;
diiinesh marked this conversation as resolved.
Show resolved Hide resolved

/**
* Test of {@link PluginBasedCommandlet}.
*/
public class PluginBasedCommandletTest extends AbstractIdeContextTest {

@Test
void testGetPluginsMap() {

IdeTestContext context = newContext(PROJECT_BASIC, "", true);
String tool = "eclipse";
Set<Tag> tags = null;
ExamplePluginBasedCommandlet pluginBasedCommandlet = new ExamplePluginBasedCommandlet(context, tool, tags);
public IdeTestContext context = newContext(PROJECT_BASIC, "", true);
public ExamplePluginBasedCommandlet pluginBasedCommandlet = new ExamplePluginBasedCommandlet(context, "eclipse", null);

@Test
void testGetPluginsMap() {
Map<String, PluginDescriptor> pluginsMap = pluginBasedCommandlet.getPluginsMap();
assertThat(pluginsMap).isNotNull();

Expand All @@ -40,6 +34,12 @@ void testGetPluginsMap() {
assertThat(plugin2.getName()).isEqualTo("anyedit");

// Check if anyedit plugin has value "false" --> value from user directory
assertThat(plugin2.isActive()).isFalse();
assertFalse(plugin2.isActive());
diiinesh marked this conversation as resolved.
Show resolved Hide resolved

assertFalse(pluginsMap.containsKey("anyedit2"));

assertEquals(2, pluginsMap.size());
}


}
Loading