• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 19681245351

25 Nov 2025 07:13PM UTC coverage: 69.164% (+0.02%) from 69.147%
19681245351

Pull #1569

github

web-flow
Merge e3efba70a into ec798104b
Pull Request #1569: Add support for comma-separated workspace values in repository configuration

3650 of 5789 branches covered (63.05%)

Branch coverage included in aggregate %.

9476 of 13189 relevant lines covered (71.85%)

3.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.33
cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java
1
package com.devonfw.tools.ide.tool.ide;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5
import java.util.Set;
6

7
import com.devonfw.tools.ide.common.Tag;
8
import com.devonfw.tools.ide.context.IdeContext;
9
import com.devonfw.tools.ide.io.FileAccess;
10
import com.devonfw.tools.ide.process.ProcessContext;
11
import com.devonfw.tools.ide.process.ProcessMode;
12
import com.devonfw.tools.ide.process.ProcessResult;
13
import com.devonfw.tools.ide.step.Step;
14
import com.devonfw.tools.ide.tool.ToolCommandlet;
15
import com.devonfw.tools.ide.tool.ToolInstallation;
16
import com.devonfw.tools.ide.tool.eclipse.Eclipse;
17
import com.devonfw.tools.ide.tool.intellij.Intellij;
18
import com.devonfw.tools.ide.tool.plugin.PluginBasedCommandlet;
19
import com.devonfw.tools.ide.tool.vscode.Vscode;
20
import com.devonfw.tools.ide.version.VersionIdentifier;
21

22
/**
23
 * {@link ToolCommandlet} for an IDE (integrated development environment) such as {@link Eclipse}, {@link Vscode}, or {@link Intellij}.
24
 */
25
public abstract class IdeToolCommandlet extends PluginBasedCommandlet {
1✔
26

27
  /**
28
   * The constructor.
29
   *
30
   * @param context the {@link IdeContext}.
31
   * @param tool the {@link #getName() tool name}.
32
   * @param tags the {@link #getTags() tags} classifying the tool. Should be created via {@link Set#of(Object) Set.of} method.
33
   */
34
  public IdeToolCommandlet(IdeContext context, String tool, Set<Tag> tags) {
35

36
    super(context, tool, tags);
5✔
37
    assert (hasIde(tags));
5!
38
  }
1✔
39

40
  private boolean hasIde(Set<Tag> tags) {
41

42
    for (Tag tag : tags) {
10!
43
      if (tag.isAncestorOf(Tag.IDE) || (tag == Tag.IDE)) {
7!
44
        return true;
2✔
45
      }
46
    }
×
47
    throw new IllegalStateException("Tags of IdeTool has to be connected with tag IDE: " + tags);
×
48
  }
49

50
  @Override
51
  public final void run() {
52
    super.run();
2✔
53
  }
1✔
54

55
  @Override
56
  public ProcessResult runTool(String... args) {
57

58
    return runTool(ProcessMode.BACKGROUND, null, args);
6✔
59
  }
60

61
  @Override
62
  public ToolInstallation install(boolean silent, VersionIdentifier version, ProcessContext processContext, Step step) {
63

64
    configureWorkspace();
2✔
65
    return super.install(silent, version, processContext, step);
7✔
66
  }
67

68
  /**
69
   * Configure (initialize or update) the workspace for this IDE using the templates from the settings.
70
   */
71
  protected void configureWorkspace() {
72

73
    FileAccess fileAccess = this.context.getFileAccess();
4✔
74
    Path workspaceFolder = this.context.getWorkspacePath();
4✔
75
    if (!fileAccess.isExpectedFolder(workspaceFolder)) {
4!
76
      this.context.warning("Current workspace does not exist: {}", workspaceFolder);
×
77
      return; // should actually never happen...
×
78
    }
79
    Step step = this.context.newStep("Configuring workspace " + workspaceFolder.getFileName() + " for IDE " + this.tool);
10✔
80
    step.run(() -> doMergeWorkspaceStep(step, workspaceFolder));
12✔
81
  }
1✔
82

83
  private void doMergeWorkspaceStep(Step step, Path workspaceFolder) {
84

85
    int errors = 0;
2✔
86
    errors = mergeWorkspace(this.context.getUserHomeIde(), workspaceFolder, errors);
8✔
87
    errors = mergeWorkspace(this.context.getSettingsPath(), workspaceFolder, errors);
8✔
88
    errors = mergeWorkspace(this.context.getConfPath(), workspaceFolder, errors);
8✔
89
    if (errors == 0) {
2!
90
      step.success();
3✔
91
    } else {
92
      step.error("Your workspace configuration failed with {} error(s) - see log above.\n"
×
93
          + "This is either a configuration error in your settings git repository or a bug in IDEasy.\n"
94
          + "Please analyze the above errors with your team or IDE-admin and try to fix the problem.", errors);
×
95
      this.context.askToContinue(
×
96
          "In order to prevent you from being blocked, you can start your IDE anyhow but some configuration may not be in sync.");
97
    }
98
  }
1✔
99

100
  private int mergeWorkspace(Path configFolder, Path workspaceFolder, int errors) {
101

102
    int result = errors;
2✔
103
    result = mergeWorkspaceSingle(configFolder.resolve(IdeContext.FOLDER_WORKSPACE), workspaceFolder, result);
8✔
104
    result = mergeWorkspaceSingle(configFolder.resolve(this.tool).resolve(IdeContext.FOLDER_WORKSPACE), workspaceFolder, result);
11✔
105
    return result;
2✔
106
  }
107

108
  private int mergeWorkspaceSingle(Path templatesFolder, Path workspaceFolder, int errors) {
109

110
    Path setupFolder = templatesFolder.resolve(IdeContext.FOLDER_SETUP);
4✔
111
    Path updateFolder = templatesFolder.resolve(IdeContext.FOLDER_UPDATE);
4✔
112
    if (!Files.isDirectory(setupFolder) && !Files.isDirectory(updateFolder)) {
10✔
113
      this.context.trace("Skipping empty or non-existing workspace template folder {}.", templatesFolder);
10✔
114
      return errors;
2✔
115
    }
116
    this.context.debug("Merging workspace templates from {}...", templatesFolder);
10✔
117
    return errors + this.context.getWorkspaceMerger().merge(setupFolder, updateFolder, this.context.getVariables(), workspaceFolder);
13✔
118
  }
119

120
  /**
121
   * Imports the repository specified by the given {@link Path} into the IDE managed by this {@link IdeToolCommandlet}.
122
   *
123
   * @param repositoryPath the {@link Path} to the repository directory to import.
124
   */
125
  public void importRepository(Path repositoryPath) {
126

127
    throw new UnsupportedOperationException("Repository import is not yet implemented for IDE " + this.tool);
×
128
  }
129
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc