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

devonfw / IDEasy / 14089575305

26 Mar 2025 05:22PM UTC coverage: 67.602% (-0.1%) from 67.75%
14089575305

push

github

web-flow
#1084: properly detect IDEasy installation dir from native image (#1170)

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

3042 of 4930 branches covered (61.7%)

Branch coverage included in aggregate %.

7844 of 11173 relevant lines covered (70.2%)

3.07 hits per line

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

52.78
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.version.VersionIdentifier;
12

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

20
  /** The tool to install. */
21
  public final ToolProperty tool;
22

23
  /** The optional version to set and install. */
24
  public final VersionProperty version;
25

26
  /**
27
   * The constructor.
28
   *
29
   * @param context the {@link IdeContext}.
30
   */
31
  public InstallCommandlet(IdeContext context) {
32

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

39
  @Override
40
  public String getName() {
41

42
    return "install";
2✔
43
  }
44

45
  @Override
46
  public boolean isIdeRootRequired() {
47

48
    return this.tool.getValueCount() > 0;
6!
49
  }
50

51
  @Override
52
  public void run() {
53

54
    if (this.tool.getValueCount() == 0) {
4!
55
      IdeasyCommandlet ideasy = new IdeasyCommandlet(this.context);
×
56
      GraalVmHelper graalVmHelper = GraalVmHelper.get();
×
57
      if (graalVmHelper.isNativeImage()) {
×
58
        this.context.debug("Detected that IDEasy is running as graalvm native image...");
×
59
      } else {
60
        this.context.debug("Detected that IDEasy is running in JVM...");
×
61
      }
62
      Path cwd = graalVmHelper.getCwd();
×
63
      this.context.info("Installing IDEasy from {}", cwd);
×
64
      if (!this.context.isForceMode()) {
×
65
        this.context.askToContinue("Sub-command install without any further arguments will perform the initial installation of IDEasy.\n"
×
66
            + "Since this is typically not to be called manually, you may have forgotten to specify the tool to install as extra argument.\n"
67
            + "The current command will install IDEasy on your computer. Are you sure?");
68
      }
69
      ideasy.installIdeasy(cwd);
×
70
      return;
×
71
    }
72
    ToolCommandlet commandlet = this.tool.getValue();
5✔
73
    VersionIdentifier versionIdentifier = this.version.getValue();
5✔
74
    if (versionIdentifier != null) {
2✔
75
      commandlet.setVersion(versionIdentifier, false);
4✔
76
    }
77
    commandlet.install(false);
4✔
78
  }
1✔
79

80
  @Override
81
  public ToolCommandlet getToolForCompletion() {
82

83
    return this.tool.getValue();
5✔
84
  }
85
}
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