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

devonfw / IDEasy / 11560364436

28 Oct 2024 06:31PM UTC coverage: 66.705% (-0.04%) from 66.746%
11560364436

push

github

web-flow
#710: make workspace configuration robust (#719)

2406 of 3950 branches covered (60.91%)

Branch coverage included in aggregate %.

6275 of 9064 relevant lines covered (69.23%)

3.05 hits per line

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

42.0
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.Path;
4
import java.util.Set;
5

6
import com.devonfw.tools.ide.common.Tag;
7
import com.devonfw.tools.ide.context.IdeContext;
8
import com.devonfw.tools.ide.io.FileAccess;
9
import com.devonfw.tools.ide.process.ProcessMode;
10
import com.devonfw.tools.ide.step.Step;
11
import com.devonfw.tools.ide.tool.ToolCommandlet;
12
import com.devonfw.tools.ide.tool.eclipse.Eclipse;
13
import com.devonfw.tools.ide.tool.intellij.Intellij;
14
import com.devonfw.tools.ide.tool.plugin.PluginBasedCommandlet;
15
import com.devonfw.tools.ide.tool.vscode.Vscode;
16

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

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

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

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

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

45
  @Override
46
  public final void run() {
47

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
    Path settingsWorkspaceFolder = this.context.getSettingsPath().resolve(this.tool)
7✔
64
        .resolve(IdeContext.FOLDER_WORKSPACE);
2✔
65
    FileAccess fileAccess = this.context.getFileAccess();
4✔
66
    if (!fileAccess.isExpectedFolder(settingsWorkspaceFolder)) {
4!
67
      return;
1✔
68
    }
69
    Path setupFolder = settingsWorkspaceFolder.resolve(IdeContext.FOLDER_SETUP);
×
70
    Path updateFolder = settingsWorkspaceFolder.resolve(IdeContext.FOLDER_UPDATE);
×
71
    if (!fileAccess.isExpectedFolder(setupFolder) && !fileAccess.isExpectedFolder(updateFolder)) {
×
72
      return;
×
73
    }
74
    Path ideWorkspacePath = this.context.getWorkspacePath();
×
75
    if (!fileAccess.isExpectedFolder(ideWorkspacePath)) {
×
76
      return; // should actually never happen...
×
77
    }
78
    try (Step step = this.context.newStep("Configuring workspace " + ideWorkspacePath.getFileName() + " for IDE " + this.tool)) {
×
79
      int errors = this.context.getWorkspaceMerger().merge(setupFolder, updateFolder, this.context.getVariables(), ideWorkspacePath);
×
80
      if (errors == 0) {
×
81
        step.success();
×
82
      } else {
83
        step.error("Your workspace configuration failed with {} error(s) - see log above.\n"
×
84
            + "This is either a configuration error in your settings git repository or a bug in IDEasy.\n"
85
            + "Please analyze the above errors with your team or IDE-admin and try to fix the problem.", errors);
×
86
        this.context.askToContinue(
×
87
            "In order to prevent you from being blocked, you can start your IDE anyhow but some configuration may not be in sync.");
88
      }
89
    }
90
  }
×
91
}
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