Skip to content

Commit

Permalink
SCANCLI-168 Update Scanner Java Library dependency to 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
henryju committed Jan 15, 2025
1 parent 0657dfa commit 14f6764
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<dependency>
<groupId>org.sonarsource.scanner.lib</groupId>
<artifactId>sonar-scanner-java-library</artifactId>
<version>3.1.1.261</version>
<version>3.2.0.370</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/org/sonarsource/scanner/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,20 @@ void analyze() {
checkSkip(p);
configureLogging(p);
init(p);
try (var engine = scannerEngineBootstrapper.bootstrap()) {
var success = engine.analyze((Map) p);
if (success) {
displayExecutionResult(stats, "SUCCESS");
status = Exit.SUCCESS;
try (var result = scannerEngineBootstrapper.bootstrap()) {
if (result.isSuccessful()) {
var engine = result.getEngineFacade();
var success = engine.analyze((Map) p);
if (success) {
displayExecutionResult(stats, "SUCCESS");
status = Exit.SUCCESS;
} else {
displayExecutionResult(stats, "FAILURE");
status = Exit.SCANNER_ENGINE_ERROR;
}
} else {
displayExecutionResult(stats, "FAILURE");
status = Exit.SCANNER_ENGINE_ERROR;
status = Exit.INTERNAL_ERROR;
}
}
} catch (Throwable e) {
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/org/sonarsource/scanner/cli/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;
import org.sonar.api.utils.MessageException;
import org.sonarsource.scanner.lib.ScannerEngineBootstrapResult;
import org.sonarsource.scanner.lib.ScannerEngineBootstrapper;
import org.sonarsource.scanner.lib.ScannerEngineFacade;
import org.sonarsource.scanner.lib.ScannerProperties;
Expand Down Expand Up @@ -60,7 +61,10 @@ class MainTest {
@BeforeEach
void setUp() {
when(scannerEngineBootstrapperFactory.create(any(Properties.class), any(String.class))).thenReturn(bootstrapper);
when(bootstrapper.bootstrap()).thenReturn(engine);
var result = mock(ScannerEngineBootstrapResult.class);
when(result.isSuccessful()).thenReturn(true);
when(result.getEngineFacade()).thenReturn(engine);
when(bootstrapper.bootstrap()).thenReturn(result);
when(engine.analyze(any())).thenReturn(true);
when(conf.properties()).thenReturn(properties);
}
Expand Down

0 comments on commit 14f6764

Please sign in to comment.