]> source.dussan.org Git - sonar-scanner-cli.git/commitdiff
Update to the latest scanner-java-library
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 6 May 2024 13:48:11 +0000 (15:48 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Tue, 7 May 2024 11:04:55 +0000 (13:04 +0200)
.cirrus.yml
it/pom.xml
it/src/test/java/com/sonarsource/scanner/it/ScannerTest.java
it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java
pom.xml
src/main/java/org/sonarsource/scanner/cli/Conf.java
src/main/java/org/sonarsource/scanner/cli/ScannerEngineBootstrapperFactory.java
src/main/java/org/sonarsource/scanner/cli/Slf4jLogOutput.java [deleted file]
src/test/java/org/sonarsource/scanner/cli/Slf4jLogOutputTest.java [deleted file]

index fd15fa2ffb29238a940d9e0d89b2ed8728a6b8a8..0405791848a8e0301bf1fc78c3d4773a66884a5f 100644 (file)
@@ -77,6 +77,7 @@ linux_qa_java17_task:
     matrix:
       - SQ_VERSION: LATEST_RELEASE[9.9]
       - SQ_VERSION: LATEST_RELEASE
+      - SQ_VERSION: DEV
   maven_cache:
     folder: ${CIRRUS_WORKING_DIR}/.m2/repository
   qa_script:
@@ -103,6 +104,7 @@ win_qa_java17_task:
     matrix:
       - SQ_VERSION: LATEST_RELEASE[9.9]
       - SQ_VERSION: LATEST_RELEASE
+      - SQ_VERSION: DEV
   maven_cache:
     folder: ${CIRRUS_WORKING_DIR}/.m2/repository
   qa_script:
index 2ad29b742746c25b8a7199bda7abd230f18123d9..cfb928285f68cfa9a44aead5d94ad55de912c169 100644 (file)
   </dependencies>
 
   <build>
-    <pluginManagement>
-      <plugins>
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-surefire-plugin</artifactId>
-          <configuration>
-            <systemProperties>
-              <scanner.version>${env.PROJECT_VERSION}</scanner.version>
-            </systemProperties>
-            <includes>
-              <include>**/SonarScannerTestSuite.java</include>
-            </includes>
-          </configuration>
-        </plugin>
-      </plugins>
-    </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <!-- Some tests are asserting on localized messages or dates -->
+          <systemPropertyVariables>
+            <user.language>en</user.language>
+            <user.country>US</user.country>
+          </systemPropertyVariables>
+          <environmentVariables>
+            <LANGUAGE>en_US</LANGUAGE>
+          </environmentVariables>
+          <systemProperties>
+            <scanner.version>${env.PROJECT_VERSION}</scanner.version>
+          </systemProperties>
+          <includes>
+            <include>**/SonarScannerTestSuite.java</include>
+          </includes>
+        </configuration>
+      </plugin>
+    </plugins>
   </build>
 
   <profiles>
index 8055d8206d007f284b60a1713467b106fd751b11..d6b9bf7740fc7d23aeb57bca33eba424e916a0d4 100644 (file)
@@ -164,17 +164,14 @@ public class ScannerTest extends ScannerTestCase {
   @Test
   public void should_use_environment_prop() {
     SonarScanner build = newScanner(new File("projects/simple-sample"))
-      .setEnvironmentVariable("SONAR_HOST_URL", "http://from-env.org");
+      .setEnvironmentVariable("SONAR_HOST_URL", "http://www.google.com/404");
 
     BuildRunner runner = new BuildRunner(orchestrator.getConfiguration());
     BuildResult buildResult = runner.runQuietly(null, build);
 
     assertThat(buildResult.isSuccess()).isFalse();
     assertThat(buildResult.getLogs())
-      .containsAnyOf(
-        "No such host is known (from-env.org)", // Windows
-        "from-env.org: Name or service not known" // Linux
-      );
+      .contains("Error status returned by url [http://www.google.com/404/api/v2/analysis/version]: 404");
   }
 
   @Test
@@ -192,18 +189,15 @@ public class ScannerTest extends ScannerTestCase {
   public void should_fail_if_unable_to_connect() {
     SonarScanner build = newScanner(new File("projects/simple-sample"))
       //env property should be overridden
-      .setEnvironmentVariable("SONAR_HOST_URL", "http://from-env.org")
-      .setProperty("sonar.host.url", "http://foo");
+      .setEnvironmentVariable("SONAR_HOST_URL", "http://www.google.com")
+      .setProperty("sonar.host.url", "http://www.google.com/404");
 
     BuildResult result = orchestrator.executeBuildQuietly(build);
     // expect build failure
     assertThat(result.isSuccess()).isFalse();
     // with the following message
     assertThat(result.getLogs())
-      .containsAnyOf(
-        "No such host is known (foo)", // Windows
-        "foo: No address associated with hostname" // Linux
-      );
+      .contains("Error status returned by url [http://www.google.com/404/api/v2/analysis/version]: 404");
   }
 
   // SONARPLUGINS-3574
index e3222a52fc4273f0f7b0a8471ccec4dc81ffcbf9..8d4df8850f23197253d3b9bf7327acbc0bda83ef 100644 (file)
@@ -38,7 +38,7 @@ public class SonarScannerTestSuite {
 
   private static OrchestratorRule createOrchestrator() {
     String sonarVersion = System
-      .getProperty("sonar.runtimeVersion", "LATEST_RELEASE[9.9]");
+      .getProperty("sonar.runtimeVersion", "DEV");
     return OrchestratorRule.builderEnv()
       .useDefaultAdminCredentialsForBuilds(true)
       .setSonarVersion(sonarVersion)
diff --git a/pom.xml b/pom.xml
index dbe822e44242f2559adec7c7f64db67d14748fcf..226c5110780b09c7cbebcc2f6325e542a3058116 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -66,7 +66,7 @@
     <dependency>
       <groupId>org.sonarsource.scanner.lib</groupId>
       <artifactId>sonar-scanner-java-library</artifactId>
-      <version>3.0.0.114</version>
+      <version>3.0.0.141</version>
     </dependency>
     <dependency>
       <groupId>ch.qos.logback</groupId>
             <configuration>
               <rules>
                 <requireFilesSize>
-                  <minsize>4100000</minsize>
-                  <maxsize>4200000</maxsize>
+                  <minsize>4300000</minsize>
+                  <maxsize>4400000</maxsize>
                   <files>
                     <file>${project.build.directory}/sonar-scanner-${project.version}.zip</file>
                   </files>
index b1cbe620fd152f81dfb2782cce45eb33b33f2759..47f431f6119395e5f74f44d1e1ccba1d53fb0fd4 100644 (file)
@@ -81,8 +81,8 @@ class Conf {
     return resolver.resolve();
   }
 
-  private Map<String, String> loadEnvironmentProperties() {
-    return EnvironmentConfig.load(new Slf4jLogOutput());
+  private static Map<String, String> loadEnvironmentProperties() {
+    return EnvironmentConfig.load();
   }
 
   private Properties loadGlobalProperties() {
index 63ee9d0df05245dd75383a5acdca0e3e3c63d52c..a0983d95b61e79e0f0222989d91534ee02389947 100644 (file)
@@ -38,7 +38,7 @@ class ScannerEngineBootstrapperFactory {
   }
 
   ScannerEngineBootstrapper newScannerEngineBootstrapper(String appName, String appVersion) {
-    return ScannerEngineBootstrapper.create(appName, appVersion, new Slf4jLogOutput());
+    return ScannerEngineBootstrapper.create(appName, appVersion);
   }
 
 
diff --git a/src/main/java/org/sonarsource/scanner/cli/Slf4jLogOutput.java b/src/main/java/org/sonarsource/scanner/cli/Slf4jLogOutput.java
deleted file mode 100644 (file)
index 2ce5cba..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * SonarScanner CLI
- * Copyright (C) 2011-2024 SonarSource SA
- * mailto:info 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 org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonarsource.scanner.lib.LogOutput;
-
-public class Slf4jLogOutput implements LogOutput {
-
-  private static final Logger LOG = LoggerFactory.getLogger(Slf4jLogOutput.class);
-
-  @Override
-  public void log(String s, Level level) {
-    switch (level) {
-      case TRACE:
-        LOG.trace(s);
-        break;
-      case DEBUG:
-        LOG.debug(s);
-        break;
-      case INFO:
-        LOG.info(s);
-        break;
-      case WARN:
-        LOG.warn(s);
-        break;
-      case ERROR:
-        LOG.error(s);
-        break;
-    }
-  }
-}
diff --git a/src/test/java/org/sonarsource/scanner/cli/Slf4jLogOutputTest.java b/src/test/java/org/sonarsource/scanner/cli/Slf4jLogOutputTest.java
deleted file mode 100644 (file)
index adf29f4..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * SonarScanner CLI
- * Copyright (C) 2011-2024 SonarSource SA
- * mailto:info 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 org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.slf4j.event.Level;
-import org.sonarsource.scanner.lib.LogOutput;
-import testutils.LogTester;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-class Slf4jLogOutputTest {
-
-  @RegisterExtension
-  LogTester logTester = new LogTester().setLevel(Level.TRACE);
-
-  @Test
-  void make_coverage_happy() {
-    var underTest = new Slf4jLogOutput();
-    underTest.log("trace", LogOutput.Level.TRACE);
-    underTest.log("debug", LogOutput.Level.DEBUG);
-    underTest.log("info", LogOutput.Level.INFO);
-    underTest.log("warn", LogOutput.Level.WARN);
-    underTest.log("error", LogOutput.Level.ERROR);
-
-    assertThat(logTester.logs(Level.TRACE)).containsOnly("trace");
-    assertThat(logTester.logs(Level.DEBUG)).containsOnly("debug");
-    assertThat(logTester.logs(Level.INFO)).containsOnly("info");
-    assertThat(logTester.logs(Level.WARN)).containsOnly("warn");
-    assertThat(logTester.logs(Level.ERROR)).containsOnly("error");
-  }
-
-}