3 * Copyright (C) 2009-2023 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 * as React from 'react';
21 import { FormattedMessage } from 'react-intl';
22 import { ClipboardIconButton } from '../../../../components/controls/clipboard';
23 import { translate } from '../../../../helpers/l10n';
24 import CodeSnippet from '../../../common/CodeSnippet';
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.build-wrapper-output=bw-output';
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 <ul className="list-styled list-alpha spacer-top">
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'
71 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare.run_analysis.section'
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']}
98 id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence"
99 defaultMessage={translate(
100 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence'
106 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence.project_key'
110 key: <code className="rule">{projectKey}</code>,
111 button: <ClipboardIconButton copyValue={projectKey} />,
115 {buildTool === BuildTools.CFamily && (
118 id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp"
119 defaultMessage={translate(
120 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp'
126 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp.advanced'
133 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.prepare_additional.ccpp.additional'
137 property: <code className="rule">{ADDITIONAL_PROPERTY}</code>,
138 button: <ClipboardIconButton copyValue={ADDITIONAL_PROPERTY} />,
146 {kind === PrepareType.JavaMavenGradle && (
148 <SentenceWithHighlights
149 translationKey="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.advanced_properties"
150 highlightKeys={['section', 'properties']}
153 <CodeSnippet snippet={MAVEN_GRADLE_PROPS_SNIPPET} />
156 {kind === PrepareType.MSBuild && (
159 id="onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence"
160 defaultMessage={translate(
161 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence'
167 'onboarding.tutorial.with.azure_pipelines.BranchAnalysis.run.key.sentence.project_key'
171 key: <code className="rule">{projectKey}</code>,
172 button: <ClipboardIconButton copyValue={projectKey} />,