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

devonfw / IDEasy / 22264313095

21 Feb 2026 09:03PM UTC coverage: 70.645% (+0.2%) from 70.474%
22264313095

Pull #1710

github

web-flow
Merge eff4c822e into 379acdc9d
Pull Request #1710: #404: allow logging via SLF4J

4121 of 6440 branches covered (63.99%)

Branch coverage included in aggregate %.

10696 of 14534 relevant lines covered (73.59%)

3.13 hits per line

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

10.91
cli/src/main/java/com/devonfw/tools/ide/tool/sonar/Sonar.java
1
package com.devonfw.tools.ide.tool.sonar;
2

3
import java.nio.file.Path;
4
import java.util.List;
5
import java.util.Properties;
6
import java.util.Set;
7

8
import org.slf4j.Logger;
9
import org.slf4j.LoggerFactory;
10

11
import com.devonfw.tools.ide.common.Tag;
12
import com.devonfw.tools.ide.context.IdeContext;
13
import com.devonfw.tools.ide.property.EnumProperty;
14
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
15
import com.devonfw.tools.ide.tool.ToolInstallation;
16
import com.devonfw.tools.ide.tool.java.Java;
17
import com.devonfw.tools.ide.tool.mvn.Mvn;
18

19
/**
20
 * {@link LocalToolCommandlet} for <a href="https://sonarqube.org/">SonarQube</a>.
21
 */
22
public class Sonar extends LocalToolCommandlet {
23

24
  private static final Logger LOG = LoggerFactory.getLogger(Sonar.class);
4✔
25

26
  /** The {@link SonarCommand} to run. */
27
  public final EnumProperty<SonarCommand> command;
28

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

36
    super(context, "sonar", Set.of(Tag.CODE_QA));
6✔
37

38
    this.command = add(new EnumProperty<>("", true, "command", SonarCommand.class));
12✔
39
    add(this.arguments);
5✔
40
  }
1✔
41

42
  @Override
43
  protected void initProperties() {
44

45
    // Empty on purpose
46
  }
1✔
47

48
  @Override
49
  public ToolInstallation install(boolean silent) {
50

51
    getCommandlet(Java.class).install();
×
52
    return super.install(silent);
×
53
  }
54

55
  @Override
56
  protected void doRun() {
57

58
    SonarCommand command = this.command.getValue();
×
59

60
    Path toolPath = getToolPath();
×
61
    if (!toolPath.toFile().exists()) {
×
62
      super.install(true);
×
63
    }
64

65
    switch (command) {
×
66
      case ANALYZE:
67
        getCommandlet(Mvn.class).runTool(List.of("sonar:sonar"));
×
68
        break;
×
69
      case START:
70
        printSonarWebPort();
×
71
        this.arguments.setValueAsString("start", this.context);
×
72
        super.run();
×
73
        break;
×
74
      case STOP:
75
        this.arguments.setValueAsString("stop", this.context);
×
76
        super.run();
×
77
        break;
×
78
      default:
79
    }
80
  }
×
81

82
  @Override
83
  protected String getBinaryName() {
84

85
    if (this.context.getSystemInfo().isWindows()) {
×
86
      SonarCommand command = this.command.getValue();
×
87
      if (command.equals(SonarCommand.START)) {
×
88
        return "windows-x86-64/StartSonar.bat";
×
89
      } else if (command.equals(SonarCommand.STOP)) {
×
90
        return "windows-x86-64/SonarService.bat";
×
91
      }
92
    } else if (this.context.getSystemInfo().isMac()) {
×
93
      return "macosx-universal-64/sonar.sh";
×
94
    }
95
    return "linux-x86-64/sonar.sh";
×
96
  }
97

98
  private void printSonarWebPort() {
99

100
    LOG.info("SonarQube is running at localhost on the following port (default 9000):");
×
101
    Path sonarPropertiesPath = getToolPath().resolve("conf/sonar.properties");
×
102

103
    Properties sonarProperties = this.context.getFileAccess().readProperties(sonarPropertiesPath);
×
104
    String sonarWebPort = sonarProperties.getProperty("sonar.web.port");
×
105
    if (sonarWebPort != null) {
×
106
      LOG.info(sonarWebPort);
×
107
    }
108
  }
×
109
}
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