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

devonfw / IDEasy / 13063267543

30 Jan 2025 11:34PM UTC coverage: 68.379% (-0.2%) from 68.557%
13063267543

push

github

web-flow
#954: improve repository support (#990)

Co-authored-by: jan-vcapgemini <59438728+jan-vcapgemini@users.noreply.github.com>
Co-authored-by: jan-vcapgemini <jan-vincent.hoelzle@capgemini.com>

2857 of 4597 branches covered (62.15%)

Branch coverage included in aggregate %.

7391 of 10390 relevant lines covered (71.14%)

3.1 hits per line

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

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

96
  /**
97
   * Imports the repository specified by the given {@link Path} into the IDE managed by this {@link IdeToolCommandlet}.
98
   *
99
   * @param repositoryPath the {@link Path} to the repository directory to import.
100
   */
101
  public void importRepository(Path repositoryPath) {
102

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