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

devonfw / IDEasy / 22345446363

24 Feb 2026 09:49AM UTC coverage: 70.247% (-0.2%) from 70.474%
22345446363

Pull #1714

github

web-flow
Merge 5655b6589 into 379acdc9d
Pull Request #1714: #404: #1713: advanced logging

4065 of 6384 branches covered (63.67%)

Branch coverage included in aggregate %.

10597 of 14488 relevant lines covered (73.14%)

3.08 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.List;
6
import java.util.Set;
7

8
import org.slf4j.Logger;
9
import org.slf4j.LoggerFactory;
10

11
import com.devonfw.tools.ide.common.Tag;
12
import com.devonfw.tools.ide.context.IdeContext;
13
import com.devonfw.tools.ide.io.FileAccess;
14
import com.devonfw.tools.ide.process.ProcessMode;
15
import com.devonfw.tools.ide.process.ProcessResult;
16
import com.devonfw.tools.ide.step.Step;
17
import com.devonfw.tools.ide.tool.ToolCommandlet;
18
import com.devonfw.tools.ide.tool.ToolInstallRequest;
19
import com.devonfw.tools.ide.tool.ToolInstallation;
20
import com.devonfw.tools.ide.tool.eclipse.Eclipse;
21
import com.devonfw.tools.ide.tool.intellij.Intellij;
22
import com.devonfw.tools.ide.tool.plugin.PluginBasedCommandlet;
23
import com.devonfw.tools.ide.tool.vscode.Vscode;
24

25
/**
26
 * {@link ToolCommandlet} for an IDE (integrated development environment) such as {@link Eclipse}, {@link Vscode}, or {@link Intellij}.
27
 */
28
public abstract class IdeToolCommandlet extends PluginBasedCommandlet {
29

30
  private static final Logger LOG = LoggerFactory.getLogger(IdeToolCommandlet.class);
4✔
31

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

41
    super(context, tool, tags);
5✔
42
    assert (hasIde(tags));
5!
43
  }
1✔
44

45
  private boolean hasIde(Set<Tag> tags) {
46

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

55
  @Override
56
  protected final void doRun() {
57
    super.doRun();
2✔
58
  }
1✔
59

60
  @Override
61
  public ProcessResult runTool(List<String> args) {
62

63
    return runTool(ProcessMode.BACKGROUND, null, args);
6✔
64
  }
65

66
  @Override
67
  public ToolInstallation install(ToolInstallRequest request) {
68

69
    configureWorkspace();
2✔
70
    return super.install(request);
4✔
71
  }
72

73
  /**
74
   * Configure (initialize or update) the workspace for this IDE using the templates from the settings.
75
   */
76
  protected void configureWorkspace() {
77

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

88
  private void doMergeWorkspaceStep(Step step, Path workspaceFolder) {
89

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

105
  private int mergeWorkspace(Path configFolder, Path workspaceFolder, int errors) {
106

107
    int result = errors;
2✔
108
    result = mergeWorkspaceSingle(configFolder.resolve(IdeContext.FOLDER_WORKSPACE), workspaceFolder, result);
8✔
109
    result = mergeWorkspaceSingle(configFolder.resolve(this.tool).resolve(IdeContext.FOLDER_WORKSPACE), workspaceFolder, result);
11✔
110
    return result;
2✔
111
  }
112

113
  private int mergeWorkspaceSingle(Path templatesFolder, Path workspaceFolder, int errors) {
114

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

125
  /**
126
   * Imports the repository specified by the given {@link Path} into the IDE managed by this {@link IdeToolCommandlet}.
127
   *
128
   * @param repositoryPath the {@link Path} to the repository directory to import.
129
   */
130
  public void importRepository(Path repositoryPath) {
131

132
    throw new UnsupportedOperationException("Repository import is not yet implemented for IDE " + this.tool);
×
133
  }
134
}
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

© 2026 Coveralls, Inc