From 4a8d1e3fda2a772671383ac6f6201a6b97605ac1 Mon Sep 17 00:00:00 2001 From: Mark Rekveld Date: Thu, 24 Sep 2020 08:29:18 +0200 Subject: [PATCH] SQSCANNER-78 - backtick syntax (#83) --- it/pom.xml | 2 +- .../scanner/it/SonarScannerTestSuite.java | 26 +++++++++++++++---- misc/symlink-tester.sh | 14 +++++----- src/main/assembly/bin/sonar-scanner | 20 +++++++------- src/main/assembly/bin/sonar-scanner-debug | 4 +-- 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/it/pom.xml b/it/pom.xml index 633f93c..430a58b 100644 --- a/it/pom.xml +++ b/it/pom.xml @@ -36,7 +36,7 @@ org.sonarsource.orchestrator sonar-orchestrator - 3.29.0.2543 + 3.30.0.2630 junit diff --git a/it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java b/it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java index 5d76042..bc795b2 100644 --- a/it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java +++ b/it/src/test/java/com/sonarsource/scanner/it/SonarScannerTestSuite.java @@ -20,6 +20,7 @@ package com.sonarsource.scanner.it; import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.OrchestratorBuilder; import com.sonar.orchestrator.locator.MavenLocation; import org.junit.ClassRule; import org.junit.runner.RunWith; @@ -27,17 +28,32 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses({ScannerTest.class, MultimoduleTest.class, DistributionTest.class}) +@SuiteClasses({ScannerTest.class, MultimoduleTest.class, + DistributionTest.class}) public class SonarScannerTestSuite { @ClassRule - public static final Orchestrator ORCHESTRATOR = Orchestrator.builderEnv() - .setSonarVersion(System.getProperty("sonar.runtimeVersion", "LATEST_RELEASE[6.7]")) + public static final Orchestrator ORCHESTRATOR = createOrchestrator(); + + private static Orchestrator createOrchestrator() { + String sonarVersion = System + .getProperty("sonar.runtimeVersion", "LATEST_RELEASE[6.7]"); + OrchestratorBuilder builder = Orchestrator.builderEnv() + .setSonarVersion( + sonarVersion); // The scanner cli should still be compatible with previous LTS 6.7, and not the 7.9 // at the time of writing, so the installed plugins should be compatible with // both 6.7 and 8.x. The latest releases of analysers drop the compatibility with // 6.7, that's why versions are hardcoded here. - .addPlugin(MavenLocation.of("org.sonarsource.javascript", "sonar-javascript-plugin", "5.2.1.7778")) - .build(); + MavenLocation javascriptPlugin = MavenLocation + .of("org.sonarsource.javascript", "sonar-javascript-plugin", + "5.2.1.7778"); + if (sonarVersion.startsWith("DEV")) { + builder.addBundledPlugin(javascriptPlugin); + } else { + builder.addPlugin(javascriptPlugin); + } + return builder.build(); + } } diff --git a/misc/symlink-tester.sh b/misc/symlink-tester.sh index bab955e..8ef5791 100755 --- a/misc/symlink-tester.sh +++ b/misc/symlink-tester.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh usage() { echo usage: $0 path/to/sonar-scanner @@ -10,10 +10,10 @@ test -f "$1" && test -x "$1" || usage scanner=$1 if type mktemp &>/dev/null; then - tempdir=$(mktemp -d) - tempdir=$(cd "$tempdir"; pwd -P) + tempdir=`mktemp -d` + tempdir=`cd "$tempdir"; pwd -P` else - tempdir=/tmp/"$(basename "$0")-$$" + tempdir=/tmp/"`basename "$0"`-$$" mkdir -p "$tempdir" fi @@ -25,7 +25,7 @@ trap 'cleanup; exit 1' 1 2 3 15 trap 'cleanup; exit 0' 0 abspath() { - (cd "$(dirname "$1")"; echo $PWD/"$(basename "$1")") + (cd "`dirname "$1"`"; echo $PWD/"`basename "$1"`") } verify() { @@ -46,10 +46,10 @@ relpath_to_root() { ) } -ln -s "$(abspath "$scanner")" "$tempdir"/scanner +ln -s "`abspath "$scanner"`" "$tempdir"/scanner verify 'launch from abs symlink to abs path' "$tempdir"/scanner -h -ln -s "$(relpath_to_root "$tempdir")$(abspath "$scanner")" "$tempdir"/scanner-rel +ln -s "`relpath_to_root "$tempdir"``abspath "$scanner"`" "$tempdir"/scanner-rel verify 'symlink to rel path is valid' test -e "$tempdir"/scanner-rel verify 'launch from abs symlink to rel path' "$tempdir"/scanner-rel -h diff --git a/src/main/assembly/bin/sonar-scanner b/src/main/assembly/bin/sonar-scanner index e0e4c9d..56f0ce5 100755 --- a/src/main/assembly/bin/sonar-scanner +++ b/src/main/assembly/bin/sonar-scanner @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # # SonarScanner Startup Script for Unix # @@ -12,21 +12,21 @@ real_path () { ( while true; do - cd "$(dirname "$target")" - target=$(basename "$target") + cd "`dirname "$target"`" + target=`basename "$target"` test -L "$target" || break - target=$(readlink "$target") + target=`readlink "$target"` done - echo "$(pwd -P)/$target" + echo "`pwd -P`/$target" ) } -script_path=$(real_path "$0") -sonar_scanner_home=$(dirname "$script_path")/.. +script_path=`real_path "$0"` +sonar_scanner_home=`dirname "$script_path"`/.. # make it fully qualified -sonar_scanner_home=$(cd "$sonar_scanner_home" && pwd -P) +sonar_scanner_home=`cd "$sonar_scanner_home" && pwd -P` jar_file=$sonar_scanner_home/lib/sonar-scanner-cli-${project.version}.jar @@ -46,7 +46,7 @@ if [ -n "$JAVA_HOME" ] then java_cmd="$JAVA_HOME/bin/java" else - java_cmd="$(which java)" + java_cmd="`which java`" fi if [ -z "$java_cmd" -o ! -x "$java_cmd" ] ; then @@ -54,7 +54,7 @@ if [ -z "$java_cmd" -o ! -x "$java_cmd" ] ; then exit 1 fi -project_home=$(pwd) +project_home=`pwd` #echo "Info: Using sonar-scanner at $sonar_scanner_home" #echo "Info: Using java at $java_cmd" diff --git a/src/main/assembly/bin/sonar-scanner-debug b/src/main/assembly/bin/sonar-scanner-debug index 823a1ab..750f813 100755 --- a/src/main/assembly/bin/sonar-scanner-debug +++ b/src/main/assembly/bin/sonar-scanner-debug @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env sh # # SonarScanner Startup Script for Unix # @@ -11,4 +11,4 @@ SONAR_SCANNER_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend echo "Executing SonarScanner in Debug Mode" echo "SONAR_SCANNER_DEBUG_OPTS=\"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000\"" -env SONAR_SCANNER_OPTS="$SONAR_SCANNER_OPTS" SONAR_SCANNER_DEBUG_OPTS="$SONAR_SCANNER_DEBUG_OPTS" "$(dirname "$0")"/sonar-scanner "$@" +env SONAR_SCANNER_OPTS="$SONAR_SCANNER_OPTS" SONAR_SCANNER_DEBUG_OPTS="$SONAR_SCANNER_DEBUG_OPTS" "`dirname "$0"`"/sonar-scanner "$@" -- 2.39.5