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

devonfw / IDEasy / 19751480105

28 Nov 2025 01:26AM UTC coverage: 69.441% (+0.3%) from 69.136%
19751480105

push

github

web-flow
#1613: fixed duplicated CVE check and refactored installation routine (#1614)

3696 of 5851 branches covered (63.17%)

Branch coverage included in aggregate %.

9620 of 13325 relevant lines covered (72.2%)

3.14 hits per line

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

62.75
cli/src/main/java/com/devonfw/tools/ide/commandlet/InstallCommandlet.java
1
package com.devonfw.tools.ide.commandlet;
2

3
import java.nio.file.Path;
4

5
import com.devonfw.tools.ide.cli.GraalVmHelper;
6
import com.devonfw.tools.ide.context.IdeContext;
7
import com.devonfw.tools.ide.property.ToolProperty;
8
import com.devonfw.tools.ide.property.VersionProperty;
9
import com.devonfw.tools.ide.tool.IdeasyCommandlet;
10
import com.devonfw.tools.ide.tool.ToolCommandlet;
11
import com.devonfw.tools.ide.tool.ToolEditionAndVersion;
12
import com.devonfw.tools.ide.tool.ToolInstallRequest;
13
import com.devonfw.tools.ide.tool.ToolInstallation;
14
import com.devonfw.tools.ide.version.VersionIdentifier;
15

16
/**
17
 * {@link Commandlet} to install a tool.
18
 *
19
 * @see ToolCommandlet#install()
20
 */
21
public class InstallCommandlet extends Commandlet {
22

23
  /** The tool to install. */
24
  public final ToolProperty tool;
25

26
  /** The optional version to set and install. */
27
  public final VersionProperty version;
28

29
  /**
30
   * The constructor.
31
   *
32
   * @param context the {@link IdeContext}.
33
   */
34
  public InstallCommandlet(IdeContext context) {
35

36
    super(context);
3✔
37
    addKeyword(getName());
4✔
38
    this.tool = add(new ToolProperty("", false, "tool"));
11✔
39
    this.version = add(new VersionProperty("", false, "version"));
11✔
40
  }
1✔
41

42
  @Override
43
  public String getName() {
44

45
    return "install";
2✔
46
  }
47

48
  @Override
49
  public boolean isIdeRootRequired() {
50

51
    return this.tool.getValueCount() > 0;
6!
52
  }
53

54
  @Override
55
  public void run() {
56

57
    if (this.tool.getValueCount() == 0) {
4!
58
      IdeasyCommandlet ideasy = new IdeasyCommandlet(this.context);
×
59
      GraalVmHelper graalVmHelper = GraalVmHelper.get();
×
60
      if (graalVmHelper.isNativeImage()) {
×
61
        this.context.debug("Detected that IDEasy is running as graalvm native image...");
×
62
      } else {
63
        this.context.debug("Detected that IDEasy is running in JVM...");
×
64
      }
65
      Path cwd = graalVmHelper.getCwd();
×
66
      this.context.info("Installing IDEasy from {}", cwd);
×
67
      if (!this.context.isForceMode()) {
×
68
        this.context.askToContinue("Sub-command install without any further arguments will perform the initial installation of IDEasy.\n"
×
69
            + "Since this is typically not to be called manually, you may have forgotten to specify the tool to install as extra argument.\n"
70
            + "The current command will install IDEasy on your computer. Are you sure?");
71
      }
72
      ideasy.installIdeasy(cwd);
×
73
      ideasy.setupWindowsTerminal();
×
74
      return;
×
75
    }
76
    ToolCommandlet commandlet = this.tool.getValue();
5✔
77
    VersionIdentifier versionIdentifier = this.version.getValue();
5✔
78
    VersionIdentifier version = versionIdentifier;
2✔
79
    if (version == null) {
2✔
80
      version = commandlet.getConfiguredVersion();
3✔
81
    }
82
    ToolInstallRequest request = ToolInstallRequest.ofDirect();
2✔
83
    request.setRequested(new ToolEditionAndVersion(version));
6✔
84
    ToolInstallation installation = commandlet.install(request);
4✔
85
    if (versionIdentifier != null) {
2✔
86
      VersionIdentifier installedVersion = installation.resolvedVersion();
3✔
87
      if (!versionIdentifier.isPattern() || !versionIdentifier.matches(installedVersion)) {
7!
88
        versionIdentifier = installedVersion;
2✔
89
      }
90
      commandlet.setVersion(versionIdentifier, false);
4✔
91
    }
92
  }
1✔
93

94
  @Override
95
  public ToolCommandlet getToolForCompletion() {
96

97
    return this.tool.getValue();
5✔
98
  }
99
}
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