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

devonfw / IDEasy / 18680241255

21 Oct 2025 10:03AM UTC coverage: 68.407% (-0.1%) from 68.522%
18680241255

Pull #1529

github

web-flow
Merge 6c92cf30d into 03c8a307b
Pull Request #1529: #1521: Use wiremock for npm repository.

3457 of 5541 branches covered (62.39%)

Branch coverage included in aggregate %.

9045 of 12735 relevant lines covered (71.02%)

3.12 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.eclipse.Eclipse;
16
import com.devonfw.tools.ide.tool.intellij.Intellij;
17
import com.devonfw.tools.ide.tool.plugin.PluginBasedCommandlet;
18
import com.devonfw.tools.ide.tool.vscode.Vscode;
19

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

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

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

38
  private boolean hasIde(Set<Tag> tags) {
39

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

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

53
  @Override
54
  public ProcessResult runTool(String... args) {
55

56
    return runTool(ProcessMode.BACKGROUND, null, args);
6✔
57
  }
58

59
  @Override
60
  public boolean install(boolean silent, ProcessContext processContext, Step step) {
61

62
    configureWorkspace();
2✔
63
    return super.install(silent, processContext, step);
6✔
64
  }
65

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

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

81
  private void doMergeWorkspaceStep(Step step, Path workspaceFolder) {
82

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

98
  private int mergeWorkspace(Path configFolder, Path workspaceFolder, int errors) {
99

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

106
  private int mergeWorkspaceSingle(Path templatesFolder, Path workspaceFolder, int errors) {
107

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

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

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