From 1d4a8d4d14df3d498bb0ea68feee8ec6a2370856 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 7 Apr 2016 19:04:38 +0200 Subject: [PATCH] SQSCANNER-15 Update Scanner API to 2.6 --- assembly.xml | 17 +++++------ pom.xml | 29 +++++-------------- .../java/org/sonarsource/scanner/cli/Cli.java | 4 +-- .../org/sonarsource/scanner/cli/Main.java | 10 +++---- ...RunnerFactory.java => ScannerFactory.java} | 12 ++++---- .../org/sonarsource/scanner/cli/MainTest.java | 12 ++++---- ...ctoryTest.java => ScannerFactoryTest.java} | 17 ++++++----- travis.sh | 1 + 8 files changed, 43 insertions(+), 59 deletions(-) rename src/main/java/org/sonarsource/scanner/cli/{RunnerFactory.java => ScannerFactory.java} (83%) rename src/test/java/org/sonarsource/scanner/cli/{RunnerFactoryTest.java => ScannerFactoryTest.java} (83%) diff --git a/assembly.xml b/assembly.xml index d438fdf..e1ba25c 100644 --- a/assembly.xml +++ b/assembly.xml @@ -7,16 +7,6 @@ zip true - - - lib - true - true - - org.sonarsource.sonar-runner:sonar-runner-api - - - src/main/assembly/bin @@ -43,5 +33,12 @@ 0644 dos + + ${project.build.directory} + lib + + ${project.build.finalName}.jar + + diff --git a/pom.xml b/pom.xml index 0bd8cc3..d490039 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.sonarsource.parent parent - 28 + 31 org.sonarsource.scanner.cli @@ -48,9 +48,9 @@ - org.sonarsource.sonar-runner - sonar-runner-api - 2.5.1 + org.sonarsource.scanner.api + sonar-scanner-api + 2.6-SNAPSHOT com.google.code.findbugs @@ -98,13 +98,10 @@ org.apache.maven.plugins maven-jar-plugin - - org/sonar/runner/commonsio/* - false - org.sonar.runner.cli.Main + org.sonarsource.scanner.cli.Main @@ -113,7 +110,6 @@ org.apache.maven.plugins maven-shade-plugin - 2.3 package @@ -123,17 +119,6 @@ true true - - - - org.sonarsource.sonar-runner:sonar-runner-api - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - @@ -173,8 +158,8 @@ - 510000 - 520000 + 490000 + 500000 ${project.build.directory}/sonar-scanner-${project.version}.zip diff --git a/src/main/java/org/sonarsource/scanner/cli/Cli.java b/src/main/java/org/sonarsource/scanner/cli/Cli.java index f8f1fb8..6544cc2 100644 --- a/src/main/java/org/sonarsource/scanner/cli/Cli.java +++ b/src/main/java/org/sonarsource/scanner/cli/Cli.java @@ -20,7 +20,7 @@ package org.sonarsource.scanner.cli; import java.util.Properties; -import org.sonar.runner.api.RunnerProperties; +import org.sonarsource.scanner.api.ScannerProperties; class Cli { @@ -63,7 +63,7 @@ class Cli { for (int i = 0; i < args.length; i++) { String arg = args[i]; if (i == 0 && arg.charAt(0) != '-') { - props.setProperty(RunnerProperties.TASK, arg); + props.setProperty(ScannerProperties.TASK, arg); } else if ("-h".equals(arg) || "--help".equals(arg)) { printUsage(); diff --git a/src/main/java/org/sonarsource/scanner/cli/Main.java b/src/main/java/org/sonarsource/scanner/cli/Main.java index 7ea4f30..0f6c1eb 100644 --- a/src/main/java/org/sonarsource/scanner/cli/Main.java +++ b/src/main/java/org/sonarsource/scanner/cli/Main.java @@ -24,7 +24,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.Properties; -import org.sonar.runner.api.EmbeddedRunner; +import org.sonarsource.scanner.api.EmbeddedScanner; /** * Arguments : @@ -43,12 +43,12 @@ public class Main { private final Shutdown shutdown; private final Cli cli; private final Conf conf; - private EmbeddedRunner runner; + private EmbeddedScanner runner; private BufferedReader inputReader; - private RunnerFactory runnerFactory; + private ScannerFactory runnerFactory; private Logs logger; - Main(Shutdown shutdown, Cli cli, Conf conf, RunnerFactory runnerFactory, Logs logger) { + Main(Shutdown shutdown, Cli cli, Conf conf, ScannerFactory runnerFactory, Logs logger) { this.shutdown = shutdown; this.cli = cli; this.conf = conf; @@ -62,7 +62,7 @@ public class Main { Cli cli = new Cli(exit, logs).parse(args); cli.verify(); Shutdown shutdown = new Shutdown(exit, cli.isInteractive()); - Main main = new Main(shutdown, cli, new Conf(cli, logs), new RunnerFactory(logs), logs); + Main main = new Main(shutdown, cli, new Conf(cli, logs), new ScannerFactory(logs), logs); main.execute(); } diff --git a/src/main/java/org/sonarsource/scanner/cli/RunnerFactory.java b/src/main/java/org/sonarsource/scanner/cli/ScannerFactory.java similarity index 83% rename from src/main/java/org/sonarsource/scanner/cli/RunnerFactory.java rename to src/main/java/org/sonarsource/scanner/cli/ScannerFactory.java index 4bc1dce..c8144d7 100644 --- a/src/main/java/org/sonarsource/scanner/cli/RunnerFactory.java +++ b/src/main/java/org/sonarsource/scanner/cli/ScannerFactory.java @@ -20,19 +20,19 @@ package org.sonarsource.scanner.cli; import java.util.Properties; -import org.sonar.runner.api.EmbeddedRunner; -import org.sonar.runner.api.LogOutput; +import org.sonarsource.scanner.api.EmbeddedScanner; +import org.sonarsource.scanner.api.LogOutput; -class RunnerFactory { +class ScannerFactory { private final Logs logger; - public RunnerFactory(Logs logger) { + public ScannerFactory(Logs logger) { this.logger = logger; } - EmbeddedRunner create(Properties props) { - return EmbeddedRunner.create(new DefaultLogOutput()).addGlobalProperties(props); + EmbeddedScanner create(Properties props) { + return EmbeddedScanner.create(new DefaultLogOutput()).addGlobalProperties(props); } class DefaultLogOutput implements LogOutput { diff --git a/src/test/java/org/sonarsource/scanner/cli/MainTest.java b/src/test/java/org/sonarsource/scanner/cli/MainTest.java index c0fbd65..4e5da4e 100644 --- a/src/test/java/org/sonarsource/scanner/cli/MainTest.java +++ b/src/test/java/org/sonarsource/scanner/cli/MainTest.java @@ -32,7 +32,7 @@ import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.sonar.runner.api.EmbeddedRunner; +import org.sonarsource.scanner.api.EmbeddedScanner; import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Matchers.any; @@ -54,9 +54,9 @@ public class MainTest { @Mock private Properties properties; @Mock - private RunnerFactory runnerFactory; + private ScannerFactory runnerFactory; @Mock - private EmbeddedRunner runner; + private EmbeddedScanner runner; @Mock private Logs logs; @@ -82,7 +82,7 @@ public class MainTest { @Test public void should_stop_on_error() { - EmbeddedRunner runner = mock(EmbeddedRunner.class); + EmbeddedScanner runner = mock(EmbeddedScanner.class); Exception e = new NullPointerException("NPE"); e = new IllegalStateException("Error", e); doThrow(e).when(runner).runAnalysis(any(Properties.class)); @@ -126,7 +126,7 @@ public class MainTest { when(cli.isDebugEnabled()).thenReturn(debugEnabled); when(cli.isDisplayStackTrace()).thenReturn(stackTraceEnabled); - EmbeddedRunner runner = mock(EmbeddedRunner.class); + EmbeddedScanner runner = mock(EmbeddedScanner.class); doThrow(e).when(runner).runAnalysis(any(Properties.class)); when(runnerFactory.create(any(Properties.class))).thenReturn(runner); @@ -140,7 +140,7 @@ public class MainTest { @Test public void should_not_stop_on_error_in_interactive_mode() throws Exception { - EmbeddedRunner runner = mock(EmbeddedRunner.class); + EmbeddedScanner runner = mock(EmbeddedScanner.class); doThrow(new IllegalStateException("Error")).when(runner).runAnalysis(any(Properties.class)); when(runnerFactory.create(any(Properties.class))).thenReturn(runner); when(cli.isInteractive()).thenReturn(true); diff --git a/src/test/java/org/sonarsource/scanner/cli/RunnerFactoryTest.java b/src/test/java/org/sonarsource/scanner/cli/ScannerFactoryTest.java similarity index 83% rename from src/test/java/org/sonarsource/scanner/cli/RunnerFactoryTest.java rename to src/test/java/org/sonarsource/scanner/cli/ScannerFactoryTest.java index 5807952..2e60e81 100644 --- a/src/test/java/org/sonarsource/scanner/cli/RunnerFactoryTest.java +++ b/src/test/java/org/sonarsource/scanner/cli/ScannerFactoryTest.java @@ -19,10 +19,11 @@ */ package org.sonarsource.scanner.cli; -import org.sonar.runner.api.LogOutput.Level; +import org.sonarsource.scanner.api.EmbeddedScanner; +import org.sonarsource.scanner.api.LogOutput; +import org.sonarsource.scanner.api.LogOutput.Level; import org.sonarsource.scanner.cli.Logs; -import org.sonarsource.scanner.cli.RunnerFactory; -import org.sonar.runner.api.LogOutput; +import org.sonarsource.scanner.cli.ScannerFactory; import org.junit.Before; import java.util.Properties; @@ -33,10 +34,10 @@ import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.mock; import org.junit.Test; -import org.sonar.runner.api.EmbeddedRunner; + import static org.fest.assertions.Assertions.assertThat; -public class RunnerFactoryTest { +public class ScannerFactoryTest { Properties props = new Properties(); Logs logs; @@ -49,15 +50,15 @@ public class RunnerFactoryTest { @Test public void should_create_embedded_runner() { props.setProperty("foo", "bar"); - EmbeddedRunner runner = new RunnerFactory(logs).create(props); + EmbeddedScanner runner = new ScannerFactory(logs).create(props); - assertThat(runner).isInstanceOf(EmbeddedRunner.class); + assertThat(runner).isInstanceOf(EmbeddedScanner.class); assertThat(runner.globalProperties().get("foo")).isEqualTo("bar"); } @Test public void should_fwd_logs() { - LogOutput logOutput = new RunnerFactory(logs).new DefaultLogOutput(); + LogOutput logOutput = new ScannerFactory(logs).new DefaultLogOutput(); String msg = "test"; diff --git a/travis.sh b/travis.sh index 5fba286..f9a9784 100755 --- a/travis.sh +++ b/travis.sh @@ -9,6 +9,7 @@ function configureTravis { } configureTravis +build_snapshot SonarSource/sonar-scanner-api case "$TARGET" in -- 2.39.5