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

devonfw / IDEasy / 9808498015

05 Jul 2024 12:43PM UTC coverage: 61.798% (+0.6%) from 61.159%
9808498015

push

github

web-flow
#25: implement tool commandlet for intellij (#447)

1983 of 3531 branches covered (56.16%)

Branch coverage included in aggregate %.

5264 of 8196 relevant lines covered (64.23%)

2.82 hits per line

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

80.0
cli/src/main/java/com/devonfw/tools/ide/tool/intellij/Intellij.java
1
package com.devonfw.tools.ide.tool.intellij;
2

3
import com.devonfw.tools.ide.cli.CliArgument;
4
import com.devonfw.tools.ide.common.Tag;
5
import com.devonfw.tools.ide.context.IdeContext;
6
import com.devonfw.tools.ide.io.FileAccess;
7
import com.devonfw.tools.ide.process.ProcessMode;
8
import com.devonfw.tools.ide.tool.ide.IdeToolCommandlet;
9
import com.devonfw.tools.ide.tool.ide.PluginDescriptor;
10
import com.devonfw.tools.ide.tool.java.Java;
11
import com.devonfw.tools.ide.version.VersionIdentifier;
12

13
import java.io.IOException;
14
import java.nio.file.Files;
15
import java.nio.file.Path;
16
import java.util.Set;
17

18
/**
19
 * {@link IdeToolCommandlet} for <a href="https://www.jetbrains.com/idea/">IntelliJ</a>.
20
 */
21
public class Intellij extends IdeToolCommandlet {
22

23
  private static final String IDEA = "idea";
24

25
  private static final String IDEA64_EXE = IDEA + "64.exe";
26

27
  private static final String IDEA_BASH_SCRIPT = IDEA + ".sh";
28

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

36
    super(context, "intellij", Set.of(Tag.INTELLIJ));
6✔
37
  }
1✔
38

39
  @Override
40
  public void runTool(ProcessMode processMode, VersionIdentifier toolVersion, String... args) {
41

42
    install(true);
4✔
43
    args = CliArgument.prepend(args, this.context.getWorkspacePath().toString());
12✔
44
    super.runTool(processMode, toolVersion, args);
5✔
45
  }
1✔
46

47
  @Override
48
  protected String getBinaryName() {
49

50
    Path toolBinPath = getToolBinPath();
3✔
51
    if (this.context.getSystemInfo().isWindows()) {
5✔
52
      return IDEA64_EXE;
2✔
53
    } else if (this.context.getSystemInfo().isLinux()) {
5✔
54
      return IDEA_BASH_SCRIPT;
2✔
55
    } else {
56
      return IDEA;
2✔
57
    }
58
  }
59

60
  @Override
61
  public boolean install(boolean silent) {
62

63
    getCommandlet(Java.class).install();
6✔
64
    return super.install(silent);
4✔
65
  }
66

67
  @Override
68
  protected void postInstall() {
69

70
    super.postInstall();
2✔
71
    if (this.context.getSystemInfo().isMac()) {
5✔
72
      setMacOsFilePermissions(getToolPath().resolve("IntelliJ IDEA" + generateMacEditionString() + ".app").resolve("Contents").resolve("MacOS").resolve(IDEA));
14✔
73
    }
74
  }
1✔
75

76
  private String generateMacEditionString() {
77

78
    String edition = "";
2✔
79
    if (getEdition().equals("intellij")) {
5!
80
      edition = " CE";
2✔
81
    }
82
    return edition;
2✔
83
  }
84

85
  private void setMacOsFilePermissions(Path binaryFile) {
86

87
    if (Files.exists(binaryFile)) {
5!
88
      FileAccess fileAccess = this.context.getFileAccess();
×
89
      try {
90
        fileAccess.makeExecutable(binaryFile);
×
91
      } catch (IOException e) {
×
92
        throw new RuntimeException(e);
×
93
      }
×
94
    }
95
  }
1✔
96

97
  @Override
98
  public void installPlugin(PluginDescriptor plugin) {
99
    // TODO: needs to be implemented see: https://github.com/devonfw/IDEasy/issues/433
100
  }
×
101
}
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