From 1d4a8d4d14df3d498bb0ea68feee8ec6a2370856 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 7 Apr 2016 19:04:38 +0200 Subject: SQSCANNER-15 Update Scanner API to 2.6 --- src/main/java/org/sonarsource/scanner/cli/Cli.java | 4 +- .../java/org/sonarsource/scanner/cli/Main.java | 10 ++-- .../org/sonarsource/scanner/cli/RunnerFactory.java | 56 ---------------------- .../sonarsource/scanner/cli/ScannerFactory.java | 56 ++++++++++++++++++++++ 4 files changed, 63 insertions(+), 63 deletions(-) delete mode 100644 src/main/java/org/sonarsource/scanner/cli/RunnerFactory.java create mode 100644 src/main/java/org/sonarsource/scanner/cli/ScannerFactory.java (limited to 'src/main') 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/RunnerFactory.java deleted file mode 100644 index 4bc1dce..0000000 --- a/src/main/java/org/sonarsource/scanner/cli/RunnerFactory.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube Scanner - * Copyright (C) 2011-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonarsource.scanner.cli; - -import java.util.Properties; -import org.sonar.runner.api.EmbeddedRunner; -import org.sonar.runner.api.LogOutput; - -class RunnerFactory { - - private final Logs logger; - - public RunnerFactory(Logs logger) { - this.logger = logger; - } - - EmbeddedRunner create(Properties props) { - return EmbeddedRunner.create(new DefaultLogOutput()).addGlobalProperties(props); - } - - class DefaultLogOutput implements LogOutput { - @Override - public void log(String formattedMessage, Level level) { - switch (level) { - case TRACE: - case DEBUG: - logger.debug(formattedMessage); - break; - case ERROR: - logger.error(formattedMessage); - break; - case INFO: - case WARN: - default: - logger.info(formattedMessage); - } - } - } -} diff --git a/src/main/java/org/sonarsource/scanner/cli/ScannerFactory.java b/src/main/java/org/sonarsource/scanner/cli/ScannerFactory.java new file mode 100644 index 0000000..c8144d7 --- /dev/null +++ b/src/main/java/org/sonarsource/scanner/cli/ScannerFactory.java @@ -0,0 +1,56 @@ +/* + * SonarQube Scanner + * Copyright (C) 2011-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarsource.scanner.cli; + +import java.util.Properties; +import org.sonarsource.scanner.api.EmbeddedScanner; +import org.sonarsource.scanner.api.LogOutput; + +class ScannerFactory { + + private final Logs logger; + + public ScannerFactory(Logs logger) { + this.logger = logger; + } + + EmbeddedScanner create(Properties props) { + return EmbeddedScanner.create(new DefaultLogOutput()).addGlobalProperties(props); + } + + class DefaultLogOutput implements LogOutput { + @Override + public void log(String formattedMessage, Level level) { + switch (level) { + case TRACE: + case DEBUG: + logger.debug(formattedMessage); + break; + case ERROR: + logger.error(formattedMessage); + break; + case INFO: + case WARN: + default: + logger.info(formattedMessage); + } + } + } +} -- cgit v1.2.3