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

devonfw / IDEasy / 29727615224

20 Jul 2026 08:21AM UTC coverage: 72.474% (+0.04%) from 72.436%
29727615224

Pull #2144

github

web-flow
Merge f5492ab08 into 1389cc21a
Pull Request #2144: #1976: extend tool commandlet installation logic

4937 of 7524 branches covered (65.62%)

Branch coverage included in aggregate %.

12698 of 16809 relevant lines covered (75.54%)

3.2 hits per line

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

69.23
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 org.slf4j.Logger;
6
import org.slf4j.LoggerFactory;
7

8
import com.devonfw.tools.ide.cli.GraalVmHelper;
9
import com.devonfw.tools.ide.context.IdeContext;
10
import com.devonfw.tools.ide.property.FlagProperty;
11
import com.devonfw.tools.ide.property.ToolProperty;
12
import com.devonfw.tools.ide.property.VersionProperty;
13
import com.devonfw.tools.ide.tool.IdeasyCommandlet;
14
import com.devonfw.tools.ide.tool.ToolCommandlet;
15
import com.devonfw.tools.ide.tool.ToolEditionAndVersion;
16
import com.devonfw.tools.ide.tool.ToolInstallRequest;
17
import com.devonfw.tools.ide.tool.ToolInstallation;
18
import com.devonfw.tools.ide.version.VersionIdentifier;
19

20
/**
21
 * {@link Commandlet} to install a tool.
22
 *
23
 * @see ToolCommandlet#install()
24
 */
25
public class InstallCommandlet extends Commandlet {
26

27
  private static final Logger LOG = LoggerFactory.getLogger(InstallCommandlet.class);
4✔
28

29
  /** The tool to install. */
30
  public final ToolProperty tool;
31

32
  /** The optional version to set and install. */
33
  public final VersionProperty version;
34

35
  /** Ignore the current project during installation. */
36
  public final FlagProperty ignoreProject;
37

38
  /**
39
   * The constructor.
40
   *
41
   * @param context the {@link IdeContext}.
42
   */
43
  public InstallCommandlet(IdeContext context) {
44

45
    super(context);
3✔
46
    addKeyword(getName());
4✔
47
    this.tool = add(new ToolProperty("", false, "tool"));
11✔
48
    this.version = add(new VersionProperty("", false, "version"));
11✔
49
    this.ignoreProject = add(new FlagProperty("--ignore-project"));
9✔
50
  }
1✔
51

52
  @Override
53
  public String getName() {
54

55
    return "install";
2✔
56
  }
57

58
  @Override
59
  public boolean isIdeRootRequired() {
60

61
    return this.tool.getValueCount() > 0;
7!
62
  }
63

64
  @Override
65
  public boolean isIdeHomeRequired() {
66

67
    return (this.tool.getValueCount() > 0)
8✔
68
        && !Boolean.TRUE.equals(this.ignoreProject.getValue());
4!
69
  }
70

71
  @Override
72
  protected void doRun() {
73

74
    if (this.tool.getValueCount() == 0) {
4!
75
      IdeasyCommandlet ideasy = new IdeasyCommandlet(this.context);
×
76
      GraalVmHelper graalVmHelper = GraalVmHelper.get();
×
77
      if (graalVmHelper.isNativeImage()) {
×
78
        LOG.debug("Detected that IDEasy is running as graalvm native image...");
×
79
      } else {
80
        LOG.debug("Detected that IDEasy is running in JVM...");
×
81
      }
82
      Path cwd = graalVmHelper.getCwd();
×
83
      LOG.info("Installing IDEasy from {}", cwd);
×
84
      if (!this.context.isForceMode()) {
×
85
        this.context.askToContinue("Sub-command install without any further arguments will perform the initial installation of IDEasy.\n"
×
86
            + "Since this is typically not to be called manually, you may have forgotten to specify the tool to install as extra argument.\n"
87
            + "The current command will install IDEasy on your computer. Are you sure?");
88
      }
89
      ideasy.installIdeasy(cwd);
×
90
      ideasy.setupWindowsTerminal();
×
91
      return;
×
92
    }
93
    ToolCommandlet commandlet = this.tool.getValue();
5✔
94
    VersionIdentifier versionIdentifier = this.version.getValue();
5✔
95
    VersionIdentifier version = versionIdentifier;
2✔
96
    boolean ignoreProject = Boolean.TRUE.equals(this.ignoreProject.getValue());
6✔
97
    if ((version == null) && !ignoreProject) {
4✔
98
      version = commandlet.getConfiguredVersion();
3✔
99
    }
100
    ToolInstallRequest request = ToolInstallRequest.ofDirect();
2✔
101
    request.setRequested(new ToolEditionAndVersion(version));
6✔
102
    request.setIgnoreProject(ignoreProject);
3✔
103
    ToolInstallation installation = commandlet.install(request);
4✔
104
    if ((versionIdentifier != null) && !ignoreProject) {
4✔
105
      VersionIdentifier installedVersion = installation.resolvedVersion();
3✔
106
      if (!versionIdentifier.isPattern() || !versionIdentifier.matches(installedVersion)) {
7!
107
        versionIdentifier = installedVersion;
2✔
108
      }
109
      commandlet.setVersion(versionIdentifier, false);
4✔
110
    }
111
  }
1✔
112

113
  @Override
114
  public ToolCommandlet getToolForCompletion() {
115

116
    return this.tool.getValue();
5✔
117
  }
118
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc