-
Notifications
You must be signed in to change notification settings - Fork 84
#2180: Add *_PLUGINS_EXTRA variable to install extra IDE plugins per user #2237
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
Open
Paras14
wants to merge
1
commit into
devonfw:main
Choose a base branch
from
Paras14:2180-plugins-extra-variable-to-install-per-user
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+174
−7
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,8 @@ | |
| import com.devonfw.tools.ide.cli.CliException; | ||
| import com.devonfw.tools.ide.common.Tag; | ||
| import com.devonfw.tools.ide.context.IdeContext; | ||
| import com.devonfw.tools.ide.environment.EnvironmentVariables; | ||
| import com.devonfw.tools.ide.environment.VariableLine; | ||
| import com.devonfw.tools.ide.io.FileAccess; | ||
| import com.devonfw.tools.ide.process.ProcessContext; | ||
| import com.devonfw.tools.ide.process.ProcessErrorHandling; | ||
|
|
@@ -28,6 +30,9 @@ public abstract class PluginBasedCommandlet extends LocalToolCommandlet { | |
|
|
||
| private static final Logger LOG = LoggerFactory.getLogger(PluginBasedCommandlet.class); | ||
|
|
||
| /** Suffix of the tool-specific variable listing additional plugins to activate (e.g. {@code VSCODE_PLUGINS_EXTRA}). */ | ||
| public static final String VARIABLE_SUFFIX_PLUGINS_EXTRA = "_PLUGINS_EXTRA"; | ||
|
|
||
| private ToolPlugins plugins; | ||
|
|
||
| /** {@link FlagProperty} to force the reset and reinstallation of plugins as configured in the project settings. */ | ||
|
|
@@ -68,6 +73,8 @@ public ToolPlugins getPlugins() { | |
| Path userPluginsPath = getUserHomePluginsConfigPath(); | ||
| loadPluginsFromDirectory(toolPlugins, userPluginsPath); | ||
|
|
||
| activateExtraPlugins(toolPlugins); | ||
|
|
||
| this.plugins = toolPlugins; | ||
| } | ||
|
|
||
|
|
@@ -316,4 +323,33 @@ protected void handleInstallForInactivePlugin(ToolPluginDescriptor plugin) { | |
|
|
||
| LOG.debug("Omitting installation of inactive plugin {} ({}).", plugin.name(), plugin.id()); | ||
| } | ||
|
|
||
| /** | ||
| * Activates the plugins configured in the tool-specific {@code «TOOL»}{@value #VARIABLE_SUFFIX_PLUGINS_EXTRA} variable (e.g. | ||
| * {@code VSCODE_PLUGINS_EXTRA=copilot,docker}). This allows a user to permanently opt-in to plugins that are not {@link ToolPluginDescriptor#active() active} | ||
| * in the project settings, without modifying the shared settings and without losing them when plugins are purged and reinstalled on IDE upgrade. Values refer | ||
| * to the {@link ToolPluginDescriptor#name() name} of the plugin (the filename of its {@code .properties} file) and not to the | ||
| * {@link ToolPluginDescriptor#id() id}. Names that do not resolve to a configured plugin are logged as a warning and skipped so that a single stale entry | ||
| * cannot break the entire installation. | ||
| * | ||
| * @param toolPlugins the {@link ToolPlugins} to modify. | ||
| */ | ||
| private void activateExtraPlugins(ToolPlugins toolPlugins) { | ||
|
|
||
| String variable = EnvironmentVariables.getToolVariablePrefix(this.tool) + VARIABLE_SUFFIX_PLUGINS_EXTRA; | ||
| String value = this.context.getVariables().get(variable); | ||
| if ((value == null) || value.isBlank()) { | ||
| return; | ||
| } | ||
| for (String entry : VariableLine.parseArray(value)) { | ||
| String name = entry; | ||
|
Comment on lines
+344
to
+345
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. entry is only read once before getting copied into name. you could just loop over name directly: |
||
| if (name.endsWith(IdeContext.EXT_PROPERTIES)) { | ||
| name = name.substring(0, name.length() - IdeContext.EXT_PROPERTIES.length()); | ||
| } | ||
| if (toolPlugins.activate(name) == null) { | ||
| LOG.warn("Undefined plugin '{}' configured in variable {} - no file {}{} found in {} or {}.", name, variable, name, IdeContext.EXT_PROPERTIES, | ||
| getPluginsConfigPath(), getUserHomePluginsConfigPath()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
cli/src/test/resources/ide-projects/plugin-extra/project/conf/ide.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ECLIPSE_PLUGINS_EXTRA=anyedit |
3 changes: 3 additions & 0 deletions
3
...t/resources/ide-projects/plugin-extra/project/settings/eclipse/plugins/anyedit.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| url=https://raw.githubusercontent.com/iloveeclipse/plugins/latest/ | ||
| id=AnyEditTools.feature.group | ||
| active=false |
3 changes: 3 additions & 0 deletions
3
...esources/ide-projects/plugin-extra/project/settings/eclipse/plugins/checkstyle.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| url=https://checkstyle.org/eclipse-cs-update-site/ | ||
| id=net.sf.eclipsecs.feature.group | ||
| active=false |
3 changes: 3 additions & 0 deletions
3
.../resources/ide-projects/plugin-extra/project/settings/eclipse/plugins/spotbugs.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| url=https://spotbugs.github.io/eclipse/ | ||
| id=com.github.spotbugs.plugin.eclipse.feature.group | ||
| active=true |
1 change: 1 addition & 0 deletions
1
cli/src/test/resources/ide-projects/plugin-extra/project/settings/ide.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ECLIPSE_VERSION=2023-03 |
1 change: 1 addition & 0 deletions
1
cli/src/test/resources/ide-projects/plugin-extra/project/workspaces/main/readme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| this is the main workspace of plugin-extra |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have getToolVersionVariable(tool) and getToolEditionVariable(tool) in EnvironmentVariables for building these tool-prefixed variable names, each with its own test in EnvironmentVariablesTest. Might be worth adding a getToolPluginsExtraVariable(tool) there too instead of building the string inline here