3 * Copyright (C) 2009-2024 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 import { ClipboardIconButton, CodeSnippet, ListItem, UnorderedList } from 'design-system';
21 import * as React from 'react';
22 import { FormattedMessage } from 'react-intl';
23 import { translate } from '../../../../helpers/l10n';
24 import { InlineSnippet } from '../../components/InlineSnippet';
25 import SentenceWithHighlights from '../../components/SentenceWithHighlights';
26 import { BuildTools } from '../../types';
28 export enum PrepareType {
34 export interface PrepareAnalysisCommandProps {
35 buildTool: BuildTools;
41 export default function PrepareAnalysisCommand(props: PrepareAnalysisCommandProps) {
42 const { buildTool, kind, projectKey, projectName } = props;
44 const ADDITIONAL_PROPERTY = 'sonar.cfamily.compile-commands=bw-output/compile_commands.json';
46 const MAVEN_GRADLE_PROPS_SNIPPET = `# Additional properties that will be passed to the scanner,
47 # Put one key=value per line, example:
48 # sonar.exclusions=**/*.bin
49 sonar.projectKey=${projectKey}
50 sonar.projectName=${projectName}
54 <UnorderedList ticks className="sw-ml-12 sw-my-2">
56 <SentenceWithHighlights
57 translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.endpoint"
58 highlightKeys={['endpoint']}
63 id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis"
64 defaultMessage={translate(
65 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis',
69 <b className="sw-font-semibold">
71 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis.section',
76 <b className="sw-font-semibold">
78 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis.values',
87 {kind === PrepareType.StandAlone && (
90 <SentenceWithHighlights
91 translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.manual"
92 highlightKeys={['mode']}
97 <span className="sw-flex sw-items-center">
99 id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence"
100 defaultMessage={translate(
101 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence',
105 <b className="sw-font-semibold sw-mx-1">
107 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence.project_key',
112 <span className="sw-ml-1">
113 <InlineSnippet snippet={projectKey} />
116 button: <ClipboardIconButton className="sw-ml-2" copyValue={projectKey} />,
121 {buildTool === BuildTools.CFamily && (
123 <span className="sw-flex sw-items-center sw-flex-wrap">
125 id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp"
126 defaultMessage={translate(
127 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp',
131 <b className="sw-font-semibold sw-mx-1">
133 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp.advanced',
138 <b className="sw-font-semibold sw-mx-1">
140 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp.additional',
145 <span className="sw-ml-1">
146 <InlineSnippet snippet={ADDITIONAL_PROPERTY} />
150 <ClipboardIconButton className="sw-ml-2" copyValue={ADDITIONAL_PROPERTY} />
160 {kind === PrepareType.JavaMavenGradle && (
162 <SentenceWithHighlights
163 translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.advanced_properties"
164 highlightKeys={['section', 'properties']}
169 language="properties"
170 snippet={MAVEN_GRADLE_PROPS_SNIPPET}
174 {kind === PrepareType.MSBuild && (
176 <span className="sw-flex sw-items-center">
178 id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence"
179 defaultMessage={translate(
180 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence',
184 <b className="sw-font-semibold sw-mx-1">
186 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence.project_key',
191 <span className="sw-ml-1">
192 <InlineSnippet snippet={projectKey} />
195 button: <ClipboardIconButton className="sw-ml-2" copyValue={projectKey} />,