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

devonfw / IDEasy / 12795814462

15 Jan 2025 07:42PM UTC coverage: 67.842% (+0.02%) from 67.826%
12795814462

Pull #909

github

web-flow
Merge 558a2ba77 into 6f167c101
Pull Request #909: #790: Fix intellij plugin installation

2697 of 4345 branches covered (62.07%)

Branch coverage included in aggregate %.

6978 of 9916 relevant lines covered (70.37%)

3.09 hits per line

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

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

3
import java.nio.file.Files;
4
import java.util.ArrayList;
5
import java.util.List;
6
import java.util.Set;
7

8
import com.devonfw.tools.ide.common.Tag;
9
import com.devonfw.tools.ide.context.IdeContext;
10
import com.devonfw.tools.ide.log.IdeLogLevel;
11
import com.devonfw.tools.ide.process.EnvironmentContext;
12
import com.devonfw.tools.ide.process.ProcessErrorHandling;
13
import com.devonfw.tools.ide.process.ProcessMode;
14
import com.devonfw.tools.ide.process.ProcessResult;
15
import com.devonfw.tools.ide.step.Step;
16
import com.devonfw.tools.ide.tool.ToolInstallation;
17
import com.devonfw.tools.ide.tool.ide.IdeToolCommandlet;
18
import com.devonfw.tools.ide.tool.ide.IdeaBasedIdeToolCommandlet;
19
import com.devonfw.tools.ide.tool.java.Java;
20
import com.devonfw.tools.ide.tool.plugin.ToolPluginDescriptor;
21

22
/**
23
 * {@link IdeToolCommandlet} for <a href="https://www.jetbrains.com/idea/">IntelliJ</a>.
24
 */
25
public class Intellij extends IdeaBasedIdeToolCommandlet {
26

27
  private static final String IDEA = "idea";
28

29
  private static final String IDEA64_EXE = IDEA + "64.exe";
30

31
  private static final String IDEA_BASH_SCRIPT = IDEA + ".sh";
32

33
  /**
34
   * The constructor.
35
   *
36
   * @param context the {@link IdeContext}.
37
   */
38
  public Intellij(IdeContext context) {
39

40
    super(context, "intellij", Set.of(Tag.INTELLIJ));
6✔
41
  }
1✔
42

43
  @Override
44
  protected String getBinaryName() {
45

46
    if (this.context.getSystemInfo().isWindows()) {
5✔
47
      return IDEA64_EXE;
2✔
48
    } else {
49
      if (Files.exists(this.getToolBinPath().resolve(IDEA))) {
8✔
50
        return IDEA;
2✔
51
      } else if (Files.exists(this.getToolBinPath().resolve(IDEA_BASH_SCRIPT))) {
8✔
52
        return IDEA_BASH_SCRIPT;
2✔
53
      } else {
54
        return IDEA;
2✔
55
      }
56
    }
57
  }
58

59
  @Override
60
  protected void setEnvironment(EnvironmentContext environmentContext, ToolInstallation toolInstallation, boolean extraInstallation) {
61

62
    super.setEnvironment(environmentContext, toolInstallation, extraInstallation);
5✔
63
    environmentContext.withEnvVar("IDEA_PROPERTIES", this.context.getWorkspacePath().resolve("idea.properties").toString());
10✔
64
  }
1✔
65

66
  @Override
67
  protected void installDependencies() {
68

69
    // TODO create intellij/intellij/dependencies.json file in ide-urls and delete this method
70
    // TODO create intellij/ultimate/dependencies.json file in ide-urls and delete this method
71
    getCommandlet(Java.class).install();
6✔
72
  }
1✔
73

74
  @Override
75
  public void installPlugin(ToolPluginDescriptor plugin, Step step) {
76

77
    // In case of plugins with a custom repo url
78
    boolean customRepo = plugin.url() != null;
5!
79
    List<String> args = new ArrayList<>();
4✔
80
    args.add("installPlugins");
4✔
81
    args.add(plugin.id());
5✔
82
    if (customRepo) {
2!
83
      args.add(plugin.url());
×
84
    }
85
    ProcessResult result = runTool(ProcessMode.DEFAULT_CAPTURE, null, ProcessErrorHandling.LOG_WARNING, args.toArray(new String[0]));
11✔
86
    if (result.isSuccessful()) {
3!
87
      for (String line : result.getOut()) {
11!
88
        if (line.contains("installed plugin: PluginNode{id=" + plugin.id())) {
6✔
89
          step.success();
2✔
90
          return;
1✔
91
        }
92
      }
1✔
93
    }
94
    result.log(IdeLogLevel.DEBUG, context, IdeLogLevel.ERROR);
×
95
    step.error("Failed to install plugin {} ({}): exit code was {}", plugin.name(), plugin.id(), result.getExitCode());
×
96
  }
×
97

98
}
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