]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-22427 Adapt Onboarding tutorials for CFamily Linux ARM64 (#11286)
authorVincenzo Pellegrini <vincenzo.pellegrini@sonarsource.com>
Thu, 20 Jun 2024 12:48:44 +0000 (14:48 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 20 Jun 2024 20:02:37 +0000 (20:02 +0000)
15 files changed:
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/AnalysisCommand.tsx
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-it.tsx.snap
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/commands/CFamily.ts
server/sonar-web/src/main/js/components/tutorials/components/CreateYmlFile.tsx
server/sonar-web/src/main/js/components/tutorials/other/BuildToolForm.tsx
server/sonar-web/src/main/js/components/tutorials/other/ProjectAnalysisStep.tsx
server/sonar-web/src/main/js/components/tutorials/other/__tests__/OtherTutorial-it.tsx
server/sonar-web/src/main/js/components/tutorials/other/__tests__/__snapshots__/OtherTutorial-it.tsx.snap
server/sonar-web/src/main/js/components/tutorials/other/commands/AnalysisCommand.tsx
server/sonar-web/src/main/js/components/tutorials/other/commands/ClangGCCCommand.tsx
server/sonar-web/src/main/js/components/tutorials/other/commands/DownloadScanner.tsx
server/sonar-web/src/main/js/components/tutorials/other/commands/Other.tsx
server/sonar-web/src/main/js/components/tutorials/utils.ts
server/sonar-web/src/main/js/helpers/doc-links.ts
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index fa956930e0bfdab3e1208c3065e23ca13e0cf858..b5f49ab41f029f390567beb644e7cbdef359bd66 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
+import { Link } from '@sonarsource/echoes-react';
 import { Dictionary } from 'lodash';
 import * as React from 'react';
+import { FormattedMessage } from 'react-intl';
 import withAvailableFeatures, {
   WithAvailableFeaturesProps,
 } from '../../../app/components/available-features/withAvailableFeatures';
+import { DocLink } from '../../../helpers/doc-links';
+import { useDocUrl } from '../../../helpers/docs';
+import { translate } from '../../../helpers/l10n';
 import { Feature } from '../../../types/features';
 import { Component } from '../../../types/types';
 import { CompilationInfo } from '../components/CompilationInfo';
 import CreateYmlFile from '../components/CreateYmlFile';
-import { Arch, BuildTools, TutorialConfig } from '../types';
+import { Arch, AutoConfig, BuildTools, TutorialConfig } from '../types';
 import { isCFamily } from '../utils';
 import { PreambuleYaml } from './PreambuleYaml';
 import cFamilyExample from './commands/CFamily';
@@ -60,9 +65,20 @@ const YamlTemplate: Dictionary<BuildToolExampleBuilder> = {
   [BuildTools.Other]: othersExample,
 };
 
+const showJreWarning = (config: TutorialConfig, arch: Arch) => {
+  if (!isCFamily(config.buildTool)) {
+    return false;
+  }
+  if (config.autoConfig === AutoConfig.Automatic) {
+    return false;
+  }
+  return arch === Arch.Arm64;
+};
+
 export function AnalysisCommand(props: Readonly<AnalysisCommandProps>) {
   const { config, arch, mainBranchName, component } = props;
   const branchesEnabled = props.hasFeature(Feature.BranchSupport);
+  const scannerRequirementsUrl = useDocUrl(DocLink.SonarScannerRequirements);
 
   if (!config.buildTool) {
     return null;
@@ -77,10 +93,30 @@ export function AnalysisCommand(props: Readonly<AnalysisCommandProps>) {
     projectName: component.name,
   });
 
+  const warning = showJreWarning(config, arch) && (
+    <p className="sw-mb-2">
+      <FormattedMessage
+        defaultMessage={translate('onboarding.analysis.sq_scanner.jre_required_warning')}
+        id="onboarding.analysis.sq_scanner.jre_required_warning"
+        values={{
+          link: (
+            <Link to={scannerRequirementsUrl}>
+              {translate('onboarding.analysis.sq_scanner.jre_required_warning.link')}
+            </Link>
+          ),
+        }}
+      />
+    </p>
+  );
+
   return (
     <>
       <PreambuleYaml buildTool={config.buildTool} component={component} />
-      <CreateYmlFile yamlFileName="bitbucket-pipelines.yml" yamlTemplate={yamlTemplate} />
+      <CreateYmlFile
+        yamlFileName="bitbucket-pipelines.yml"
+        yamlTemplate={yamlTemplate}
+        warning={warning}
+      />
       {isCFamily(config.buildTool) && <CompilationInfo />}
     </>
   );
index af497235e2fa49b59aa3b460ed431eb5f5acbfca..af14ac13ac1c827c4194f83267afdd237ceb65a5 100644 (file)
@@ -105,9 +105,9 @@ definitions:
           - mkdir $HOME/.sonar
           - curl -sSLo $HOME/.sonar/build-wrapper-linux-aarch64.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-aarch64.zip
           - unzip -o $HOME/.sonar/build-wrapper-linux-aarch64.zip -d $HOME/.sonar/
-          - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux.zip
+          - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}.zip
           - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
-          - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux/bin"
+          - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}/bin"
           - <any step required before running your build, like ./configure>
           - $HOME/.sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command>
           - sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json  
@@ -143,9 +143,9 @@ definitions:
           - mkdir $HOME/.sonar
           - curl -sSLo $HOME/.sonar/build-wrapper-linux-aarch64.zip \${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-aarch64.zip
           - unzip -o $HOME/.sonar/build-wrapper-linux-aarch64.zip -d $HOME/.sonar/
-          - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux.zip
+          - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}.zip
           - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
-          - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux/bin"
+          - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}/bin"
           - <any step required before running your build, like ./configure>
           - $HOME/.sonar/build-wrapper-linux-aarch64/build-wrapper-linux-aarch64 --out-dir bw-output <your clean build command>
           - sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json  
index 70df56f6ce96b00d1372415e3969fb23e962ceb0..cf77fbf478ae36d22a16d3b60a3a6c9b13f4bdc2 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { AutoConfig, BuildTools } from '../../types';
-import { getBuildWrapperExecutableLinux, getBuildWrapperFolderLinux } from '../../utils';
+import { AutoConfig, BuildTools, OSs } from '../../types';
+import {
+  getBuildWrapperExecutableLinux,
+  getBuildWrapperFolderLinux,
+  getScannerUrlSuffix,
+} from '../../utils';
 import { BuildToolExampleBuilder } from '../AnalysisCommand';
 import othersExample from './Others';
 
@@ -33,6 +37,7 @@ const cFamilyExample: BuildToolExampleBuilder = ({
   }
   const buildWrapperExecutable = getBuildWrapperExecutableLinux(arch);
   const buildWrapperFolder = getBuildWrapperFolderLinux(arch);
+  const scannerSuffix = getScannerUrlSuffix(OSs.Linux, arch);
   return `image: <image ready for your build toolchain>
 
 definitions:
@@ -44,9 +49,9 @@ definitions:
           - mkdir $HOME/.sonar
           - curl -sSLo $HOME/.sonar/${buildWrapperFolder}.zip \${SONAR_HOST_URL}/static/cpp/${buildWrapperFolder}.zip
           - unzip -o $HOME/.sonar/${buildWrapperFolder}.zip -d $HOME/.sonar/
-          - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}-linux.zip
+          - curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-\${SONAR_SCANNER_VERSION}${scannerSuffix}.zip
           - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
-          - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}-linux/bin"
+          - export PATH="$PATH:$HOME/.sonar/sonar-scanner-\${SONAR_SCANNER_VERSION}${scannerSuffix}/bin"
           - <any step required before running your build, like ./configure>
           - $HOME/.sonar/${buildWrapperFolder}/${buildWrapperExecutable} --out-dir bw-output <your clean build command>
           - sonar-scanner -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json  
index a2658bb5b8079fde2e742ef68be0573b9d724bdf..8be1e9d92e27eaaeaa01149a8f8ece8a873d1963 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import { ClipboardIconButton, CodeSnippet, NumberedListItem } from 'design-system';
+import { ClipboardIconButton, CodeSnippet, FlagMessage, NumberedListItem } from 'design-system';
 import * as React from 'react';
 import { FormattedMessage } from 'react-intl';
 import { translate } from '../../../helpers/l10n';
 import { InlineSnippet } from './InlineSnippet';
 
 export interface CreateYmlFileProps {
+  warning?: React.ReactNode;
   yamlFileName: string;
   yamlTemplate: string;
 }
 
-export default function CreateYmlFile(props: CreateYmlFileProps) {
-  const { yamlTemplate, yamlFileName } = props;
+export default function CreateYmlFile(props: Readonly<CreateYmlFileProps>) {
+  const { yamlTemplate, yamlFileName, warning } = props;
   return (
     <NumberedListItem>
       <FormattedMessage
@@ -44,6 +45,13 @@ export default function CreateYmlFile(props: CreateYmlFileProps) {
           ),
         }}
       />
+      {warning && (
+        <div>
+          <FlagMessage className="sw-mt-2 sw-w-abs-600" variant="warning">
+            {warning}
+          </FlagMessage>
+        </div>
+      )}
       <CodeSnippet className="sw-p-6 sw-overflow-auto" snippet={yamlTemplate} language="yml" />
     </NumberedListItem>
   );
index e5a51052430f33d52dc41d1d0435dbb68440029d..78d5bbf5531c2035670e117b494bdc108d2eac72 100644 (file)
@@ -30,6 +30,7 @@ interface Props {
   arch?: Arch;
   config: TutorialConfig;
   hasCLanguageFeature: boolean;
+  isLocal: boolean;
   os?: OSs;
   setArch: (arch: Arch) => void;
   setConfig: (config: TutorialConfig) => void;
@@ -37,7 +38,7 @@ interface Props {
 }
 
 export function BuildToolForm(props: Readonly<Props>) {
-  const { config, setConfig, os, setOs, arch, setArch, hasCLanguageFeature } = props;
+  const { config, setConfig, os, setOs, arch, setArch, isLocal, hasCLanguageFeature } = props;
 
   function handleConfigChange(newConfig: TutorialConfig) {
     const selectOsByDefault = (newConfig.buildTool === BuildTools.Cpp ||
@@ -75,7 +76,7 @@ export function BuildToolForm(props: Readonly<Props>) {
           titleLabelKey="onboarding.build.other.os"
         />
       )}
-      {shouldShowArchSelector(os, config) && (
+      {shouldShowArchSelector(os, config, !isLocal) && (
         <RenderOptions
           label={translate('onboarding.build.other.architecture')}
           checked={arch}
index e40181969a7a5a42106d690ca743d0d78a99c92a..ed8fb265cd196cfb537dbf7a20f941a53b9a0d7d 100644 (file)
@@ -47,6 +47,7 @@ export default function ProjectAnalysisStep(props: Readonly<Props>) {
       <div className="sw-pb-4">
         <BuildToolForm
           config={config}
+          isLocal={isLocal}
           setConfig={setConfig}
           os={os}
           setOs={setOs}
index 00616b9b63dc26cb4e6fd02e21a6978a59139a73..dbc445d6326ec05c7027fd98bd346c4a1d9b9a6e 100644 (file)
@@ -124,9 +124,19 @@ it('can choose build tools and copy provided settings', async () => {
   // C++ - Automatic
   await user.click(ui.cppBuildButton.get());
   await user.click(ui.linuxButton.get());
+  expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot(
+    'c++ (automatic) and other linux: download scanner',
+  );
   expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot(
     'c++ (automatic) and other linux: execute scanner',
   );
+  await user.click(ui.arm64Button.get());
+  expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot(
+    'c++ (automatic) and other linux arm64: download scanner',
+  );
+  expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot(
+    'c++ (automatic) and other linux arm64: execute scanner',
+  );
   await user.click(ui.windowsButton.get());
   expect(getCopyToClipboardValue(1, 'Copy')).toMatchSnapshot(
     'c++ (automatic) and other windows: execute scanner',
@@ -139,6 +149,7 @@ it('can choose build tools and copy provided settings', async () => {
   // C++ - Linux (x86_64)
   await user.click(ui.autoConfigManual.get());
   await user.click(ui.linuxButton.get());
+  await user.click(ui.x86_64Button.get());
   expect(getCopyToClipboardValue(0, 'Copy')).toMatchSnapshot(
     'c++ (manual) linux: download build wrapper',
   );
index b38254c0548bbb56b643d4b9d92107a7f0385583..9bbba92c69505d240ea7c4a6dff5fc39d49c625f 100644 (file)
@@ -1,5 +1,32 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
+exports[`can choose build tools and copy provided settings: c++ (automatic) and other linux arm64: download scanner 1`] = `
+"export SONAR_SCANNER_VERSION=5.0.1.3006
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION.zip
+unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
+export PATH=$SONAR_SCANNER_HOME/bin:$PATH
+export SONAR_SCANNER_OPTS="-server"
+"
+`;
+
+exports[`can choose build tools and copy provided settings: c++ (automatic) and other linux arm64: execute scanner 1`] = `
+"sonar-scanner \\
+  -Dsonar.projectKey=my-project \\
+  -Dsonar.sources=. \\
+  -Dsonar.host.url=http://localhost:9000"
+`;
+
+exports[`can choose build tools and copy provided settings: c++ (automatic) and other linux: download scanner 1`] = `
+"export SONAR_SCANNER_VERSION=5.0.1.3006
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
+unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
+export PATH=$SONAR_SCANNER_HOME/bin:$PATH
+export SONAR_SCANNER_OPTS="-server"
+"
+`;
+
 exports[`can choose build tools and copy provided settings: c++ (automatic) and other linux: execute scanner 1`] = `
 "sonar-scanner \\
   -Dsonar.projectKey=my-project \\
@@ -60,8 +87,8 @@ export PATH=$HOME/.sonar/build-wrapper-linux-aarch64:$PATH
 
 exports[`can choose build tools and copy provided settings: c++ (manual) linux arm64: download scanner 1`] = `
 "export SONAR_SCANNER_VERSION=5.0.1.3006
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION.zip
 unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
 export PATH=$SONAR_SCANNER_HOME/bin:$PATH
 export SONAR_SCANNER_OPTS="-server"
@@ -207,8 +234,8 @@ export PATH=$HOME/.sonar/build-wrapper-linux-aarch64:$PATH
 
 exports[`can choose build tools and copy provided settings: objective-c linux arm64: download scanner 1`] = `
 "export SONAR_SCANNER_VERSION=5.0.1.3006
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION.zip
 unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
 export PATH=$SONAR_SCANNER_HOME/bin:$PATH
 export SONAR_SCANNER_OPTS="-server"
index 7105aeafa15be89c35db110805ad861e0272dc3f..846fdb0f14cb8dfbd6eac19d28224f9738c86064 100644 (file)
@@ -55,14 +55,28 @@ export default function AnalysisCommand(props: Readonly<AnalysisCommandProps>) {
 
     case BuildTools.Other:
       return (
-        <Other baseUrl={baseUrl} os={os} component={component} isLocal={isLocal} token={token} />
+        <Other
+          arch={Arch.X86_64}
+          baseUrl={baseUrl}
+          os={os}
+          component={component}
+          isLocal={isLocal}
+          token={token}
+        />
       );
 
     case BuildTools.Cpp:
     case BuildTools.ObjectiveC:
       if (config.buildTool === BuildTools.Cpp && config.autoConfig === AutoConfig.Automatic) {
         return (
-          <Other os={os} baseUrl={baseUrl} component={component} isLocal={isLocal} token={token} />
+          <Other
+            arch={arch}
+            os={os}
+            baseUrl={baseUrl}
+            component={component}
+            isLocal={isLocal}
+            token={token}
+          />
         );
       }
       return (
index 90dfda610b382f811cb5e34e819ff2bf3173f38e..0498b2c2c46fdb7fe5abe647dc0bedd556e67f2c 100644 (file)
@@ -35,13 +35,13 @@ export interface ClangGCCCustomProps {
   token: string;
 }
 
-export default function ClangGCCCustom(props: ClangGCCCustomProps) {
+export default function ClangGCCCustom(props: Readonly<ClangGCCCustomProps>) {
   const { os, arch, baseUrl, component, isLocal, token } = props;
 
   return (
     <div>
       <DownloadBuildWrapper isLocal={isLocal} baseUrl={baseUrl} os={os} arch={arch} />
-      <DownloadScanner isLocal={isLocal} os={os} token={token} />
+      <DownloadScanner arch={arch} isLocal={isLocal} os={os} token={token} />
       <ExecBuildWrapper os={os} arch={arch} />
       <CompilationInfo />
       <ExecScanner
index b914eaa49600d180f389588280029952f6dbd5b0..872f355e2061011ccafbf810c59b50edb0ff6c59 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
+import { Link } from '@sonarsource/echoes-react';
 import {
   ClipboardIconButton,
   CodeSnippet,
-  Link,
+  FlagMessage,
   NumberedList,
   NumberedListItem,
   SubHeading,
@@ -32,18 +33,21 @@ import { DocLink } from '../../../../helpers/doc-links';
 import { useDocUrl } from '../../../../helpers/docs';
 import { translate } from '../../../../helpers/l10n';
 import { InlineSnippet } from '../../components/InlineSnippet';
-import { OSs } from '../../types';
+import { Arch, OSs } from '../../types';
+import { getScannerUrlSuffix } from '../../utils';
 
 export interface DownloadScannerProps {
+  arch: Arch;
   isLocal: boolean;
   os: OSs;
   token: string;
 }
 
-export default function DownloadScanner(props: DownloadScannerProps) {
-  const { os, isLocal, token } = props;
+export default function DownloadScanner(props: Readonly<DownloadScannerProps>) {
+  const { arch, os, isLocal, token } = props;
 
   const docUrl = useDocUrl(DocLink.SonarScanner);
+  const scannerRequirementsUrl = useDocUrl(DocLink.SonarScannerRequirements);
 
   return (
     <div className="sw-mb-4">
@@ -66,12 +70,29 @@ export default function DownloadScanner(props: DownloadScannerProps) {
         </p>
       ) : (
         <>
+          {os === OSs.Linux && arch === Arch.Arm64 && (
+            <FlagMessage className="sw-mt-2 sw-w-abs-600" variant="warning">
+              <p className="sw-mb-2">
+                <FormattedMessage
+                  defaultMessage={translate('onboarding.analysis.sq_scanner.jre_required_warning')}
+                  id="onboarding.analysis.sq_scanner.jre_required_warning"
+                  values={{
+                    link: (
+                      <Link to={scannerRequirementsUrl}>
+                        {translate('onboarding.analysis.sq_scanner.jre_required_warning.link')}
+                      </Link>
+                    ),
+                  }}
+                />
+              </p>
+            </FlagMessage>
+          )}
           <CodeSnippet
             className="sw-p-4"
             wrap
             language={os === OSs.Windows ? 'powershell' : 'bash'}
-            snippet={getRemoteDownloadSnippet(os)}
-            render={`<code>${getRemoteDownloadSnippet(os)}</code>`}
+            snippet={getRemoteDownloadSnippet(os, arch)}
+            render={`<code>${getRemoteDownloadSnippet(os, arch)}</code>`}
           />
           <SubHeading className="sw-mb-2 sw-mt-4">
             {translate('onboarding.analysis.sq_scanner.sonar_token_env.header')}
@@ -98,7 +119,7 @@ export default function DownloadScanner(props: DownloadScannerProps) {
   );
 }
 
-function getRemoteDownloadSnippet(os: OSs) {
+function getRemoteDownloadSnippet(os: OSs, arch: Arch) {
   if (os === OSs.Windows) {
     return `$env:SONAR_SCANNER_VERSION = "5.0.1.3006"
 $env:SONAR_DIRECTORY = [System.IO.Path]::Combine($(get-location).Path,".sonar")
@@ -113,10 +134,10 @@ $env:Path += ";$env:SONAR_SCANNER_HOME/bin"
 $env:SONAR_SCANNER_OPTS="-server"
 `;
   }
-  const suffix = os === OSs.MacOS ? 'macosx' : 'linux';
+  const suffix = getScannerUrlSuffix(os, arch);
   return `export SONAR_SCANNER_VERSION=5.0.1.3006
-export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-${suffix}
-curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-${suffix}.zip
+export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION${suffix}
+curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION${suffix}.zip
 unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
 export PATH=$SONAR_SCANNER_HOME/bin:$PATH
 export SONAR_SCANNER_OPTS="-server"
index 81b72ded5e9bd381abc817bc82cd43c4b9632650..82500b1e060e6fbf1fed52b0702953d7494893cc 100644 (file)
  */
 import * as React from 'react';
 import { Component } from '../../../../types/types';
-import { OSs } from '../../types';
+import { Arch, OSs } from '../../types';
 import DownloadScanner from './DownloadScanner';
 import ExecScanner from './ExecScanner';
 
 export interface OtherProps {
+  arch: Arch;
   baseUrl: string;
   component: Component;
   isLocal: boolean;
@@ -31,12 +32,12 @@ export interface OtherProps {
   token: string;
 }
 
-export default function Other(props: OtherProps) {
-  const { baseUrl, os, component, isLocal, token } = props;
+export default function Other(props: Readonly<OtherProps>) {
+  const { arch, baseUrl, os, component, isLocal, token } = props;
 
   return (
     <div>
-      <DownloadScanner isLocal={isLocal} os={os} token={token} />
+      <DownloadScanner arch={arch} isLocal={isLocal} os={os} token={token} />
       <ExecScanner
         baseUrl={baseUrl}
         isLocal={isLocal}
index f5b1aa95345f9ad40a6d5308f76fd0c7d4ac802b..fc1a041aaae4698218a355b85c32aeb0cb7ac720 100644 (file)
@@ -120,13 +120,20 @@ export function shouldShowGithubCFamilyExampleRepositories(config: TutorialConfi
   return false;
 }
 
-export function shouldShowArchSelector(os: OSs | undefined, config: TutorialConfig) {
+export function shouldShowArchSelector(
+  os: OSs | undefined,
+  config: TutorialConfig,
+  scannerDownloadExplicit = false,
+) {
   if (os !== OSs.Linux) {
     return false;
   }
   if (!isCFamily(config.buildTool)) {
     return false;
   }
+  if (scannerDownloadExplicit) {
+    return true;
+  }
   if (config.buildTool === BuildTools.Cpp && config.autoConfig === AutoConfig.Automatic) {
     return false;
   }
@@ -159,6 +166,22 @@ export function getBuildWrapperExecutable(os: OSs, arch?: Arch) {
   throw new Error(`Unsupported OS: ${os}`);
 }
 
-export const getBuildWrapperFolderLinux = (arch?: Arch) => getBuildWrapperFolder(OSs.Linux, arch);
-export const getBuildWrapperExecutableLinux = (arch?: Arch) =>
-  getBuildWrapperExecutable(OSs.Linux, arch);
+export function getBuildWrapperFolderLinux(arch?: Arch) {
+  return getBuildWrapperFolder(OSs.Linux, arch);
+}
+export function getBuildWrapperExecutableLinux(arch?: Arch) {
+  return getBuildWrapperExecutable(OSs.Linux, arch);
+}
+
+export function getScannerUrlSuffix(os: OSs, arch?: Arch) {
+  if (os === OSs.Windows) {
+    return '-windows';
+  }
+  if (os === OSs.MacOS) {
+    return '-macosx';
+  }
+  if (os === OSs.Linux && arch === Arch.X86_64) {
+    return '-linux';
+  }
+  return '';
+}
index 148dc4b77023bd3eee935c846ed999d3f4b2809e..219e701fdcfde7ef0abec2b862664b2ce7a1f313 100644 (file)
@@ -77,6 +77,7 @@ export enum DocLink {
   ServerUpgradeRoadmap = '/setup-and-upgrade/upgrade-the-server/roadmap/',
   SonarLintConnectedMode = '/user-guide/sonarlint-connected-mode/',
   SonarScanner = '/analyzing-source-code/scanners/sonarscanner/',
+  SonarScannerRequirements = '/analyzing-source-code/scanners/general-requirements/',
   SonarScannerDotNet = '/analyzing-source-code/scanners/sonarscanner-for-dotnet/',
   SonarScannerGradle = '/analyzing-source-code/scanners/sonarscanner-for-gradle/',
   SonarScannerMaven = '/analyzing-source-code/scanners/sonarscanner-for-maven/',
index 61513daa6ddb3845bd21a20ad0188c1dfe8cf6f3..80dc1c28a1e13c54e275a6060159ab609edade8b 100644 (file)
@@ -4637,6 +4637,8 @@ onboarding.analysis.sq_scanner.docs_link=official documentation of the Scanner
 onboarding.analysis.sq_scanner.sonar_token_env.header=Configure a SONAR_TOKEN environment variable in your CI settings
 onboarding.analysis.sq_scanner.sonar_token_env.var_name=Add an environment variable called
 onboarding.analysis.sq_scanner.sonar_token_env.var_value=Give it the following value
+onboarding.analysis.sq_scanner.jre_required_warning=A compatible Java Runtime Environment is required to run the Scanner on this platform, please refer to {link} for more details.
+onboarding.analysis.sq_scanner.jre_required_warning.link=the documentation
 onboarding.analysis.sqscanner.docs.gradle.title=official documentation of the Scanner for Gradle
 onboarding.analysis.sqscanner.docs.gradle.example_project.title=live Gradle-based example project