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

devonfw / IDEasy / 15558256102

10 Jun 2025 11:28AM UTC coverage: 67.761% (+0.02%) from 67.746%
15558256102

Pull #1328

github

web-flow
Merge cf2a3bd1c into 7be183ce9
Pull Request #1328: #1292: logs potential welcome file to info level

3163 of 5074 branches covered (62.34%)

Branch coverage included in aggregate %.

8122 of 11580 relevant lines covered (70.14%)

3.07 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.ProcessMode;
11
import com.devonfw.tools.ide.step.Step;
12
import com.devonfw.tools.ide.tool.ToolCommandlet;
13
import com.devonfw.tools.ide.tool.eclipse.Eclipse;
14
import com.devonfw.tools.ide.tool.intellij.Intellij;
15
import com.devonfw.tools.ide.tool.plugin.PluginBasedCommandlet;
16
import com.devonfw.tools.ide.tool.vscode.Vscode;
17

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

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

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

36
  private boolean hasIde(Set<Tag> tags) {
37

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

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

52
  @Override
53
  public void runTool(String... args) {
54

55
    runTool(ProcessMode.BACKGROUND, null, args);
5✔
56
  }
1✔
57

58
  /**
59
   * Configure the workspace for this IDE using the templates from the settings.
60
   */
61
  protected void configureWorkspace() {
62

63
    FileAccess fileAccess = this.context.getFileAccess();
4✔
64
    Path workspaceFolder = this.context.getWorkspacePath();
4✔
65
    if (!fileAccess.isExpectedFolder(workspaceFolder)) {
4!
66
      this.context.warning("Current workspace does not exist: {}", workspaceFolder);
×
67
      return; // should actually never happen...
×
68
    }
69
    Step step = this.context.newStep("Configuring workspace " + workspaceFolder.getFileName() + " for IDE " + this.tool);
10✔
70
    step.run(() -> doMergeWorkspaceStep(step, workspaceFolder));
12✔
71
  }
1✔
72

73
  private void doMergeWorkspaceStep(Step step, Path workspaceFolder) {
74

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

90
  private int mergeWorkspace(Path configFolder, Path workspaceFolder, int errors) {
91

92
    int result = errors;
2✔
93
    result = mergeWorkspaceSingle(configFolder.resolve(IdeContext.FOLDER_WORKSPACE), workspaceFolder, result);
8✔
94
    result = mergeWorkspaceSingle(configFolder.resolve(this.tool).resolve(IdeContext.FOLDER_WORKSPACE), workspaceFolder, result);
11✔
95
    return result;
2✔
96
  }
97

98
  private int mergeWorkspaceSingle(Path templatesFolder, Path workspaceFolder, int errors) {
99

100
    Path setupFolder = templatesFolder.resolve(IdeContext.FOLDER_SETUP);
4✔
101
    Path updateFolder = templatesFolder.resolve(IdeContext.FOLDER_UPDATE);
4✔
102
    if (!Files.isDirectory(setupFolder) && !Files.isDirectory(updateFolder)) {
10✔
103
      this.context.trace("Skipping empty or non-existing workspace template folder {}.", templatesFolder);
10✔
104
      return errors;
2✔
105
    }
106
    this.context.debug("Merging workspace templates from {}...", templatesFolder);
10✔
107
    return errors + this.context.getWorkspaceMerger().merge(setupFolder, updateFolder, this.context.getVariables(), workspaceFolder);
13✔
108
  }
109

110
  /**
111
   * Imports the repository specified by the given {@link Path} into the IDE managed by this {@link IdeToolCommandlet}.
112
   *
113
   * @param repositoryPath the {@link Path} to the repository directory to import.
114
   */
115
  public void importRepository(Path repositoryPath) {
116

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