* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
-import { FormattedMessage } from 'react-intl';
-import { ClipboardIconButton } from '../../../components/controls/clipboard';
-import { translate } from '../../../helpers/l10n';
import { Component } from '../../../types/types';
-import CodeSnippet from '../../common/CodeSnippet';
import DefaultProjectKey from '../components/DefaultProjectKey';
+import GradleBuild from '../components/GradleBuild';
import { BuildTools } from '../types';
-import { buildGradleSnippet } from '../utils';
export interface PreambuleYamlProps {
buildTool: BuildTools;
const { buildTool, component } = props;
switch (buildTool) {
case BuildTools.Gradle:
- return (
- <li className="abs-width-600">
- <FormattedMessage
- defaultMessage={translate('onboarding.tutorial.with.yaml.gradle')}
- id="onboarding.tutorial.with.yaml.gradle"
- values={{
- gradle: (
- <>
- <code className="rule">build.gradle</code>
- <ClipboardIconButton copyValue="build.gradle" />
- </>
- ),
- sq: <code className="rule">org.sonarqube</code>,
- }}
- />
- <CodeSnippet snippet={buildGradleSnippet(component.key, component.name)} />
- </li>
- );
+ return <GradleBuild component={component} />;
case BuildTools.CFamily:
case BuildTools.Other:
return <DefaultProjectKey component={component} />;
getTutorialActionButtons,
getTutorialBuildButtons,
} from '../../test-utils';
-import { TutorialModes } from '../../types';
+import { GradleBuildDSL, TutorialModes } from '../../types';
import BitbucketPipelinesTutorial, {
BitbucketPipelinesTutorialProps,
} from '../BitbucketPipelinesTutorial';
// Gradle
await user.click(ui.gradleBuildButton.get());
- expect(getCopyToClipboardValue(1)).toMatchSnapshot('Gradle: build.gradle');
- expect(getCopyToClipboardValue(3)).toMatchSnapshot('Gradle: bitbucket-pipelines.yml');
+ expect(getCopyToClipboardValue(2)).toMatchSnapshot('Groovy: build.gradle');
+ await user.click(ui.gradleDSLButton(GradleBuildDSL.Kotlin).get());
+ expect(getCopyToClipboardValue(2)).toMatchSnapshot('Kotlin: build.gradle.kts');
+ expect(getCopyToClipboardValue(4)).toMatchSnapshot('Gradle: bitbucket-pipelines.yml');
// .NET
await user.click(ui.dotnetBuildButton.get());
- step: *build-step"
`;
-exports[`should follow and complete all steps: Gradle: build.gradle 1`] = `
+exports[`should follow and complete all steps: Groovy: build.gradle 1`] = `
"plugins {
id "org.sonarqube" version "4.0.0.2929"
}
}"
`;
+exports[`should follow and complete all steps: Kotlin: build.gradle.kts 1`] = `
+"plugins {
+ id("org.sonarqube") version "4.0.0.2929"
+}
+
+sonar {
+ properties {
+ property("sonar.projectKey", "my-project")
+ property("sonar.projectName", "MyProject")
+ }
+}"
+`;
+
exports[`should follow and complete all steps: Maven: bitbucket-pipelines.yml 1`] = `
"image: maven:3-openjdk-11
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.
+ */
+import React from 'react';
+import { FormattedMessage } from 'react-intl';
+import { translate } from '../../../helpers/l10n';
+import { Component } from '../../../types/types';
+import CodeSnippet from '../../common/CodeSnippet';
+import { ClipboardIconButton } from '../../controls/clipboard';
+import { GradleBuildDSL } from '../types';
+import { buildGradleSnippet } from '../utils';
+import GradleBuildSelection from './GradleBuildSelection';
+
+interface Props {
+ component: Component;
+}
+
+export default function GradleBuild({ component }: Props) {
+ return (
+ <li className="abs-width-600">
+ <FormattedMessage
+ defaultMessage={translate('onboarding.tutorial.with.yaml.gradle')}
+ id="onboarding.tutorial.with.yaml.gradle"
+ values={{
+ groovy: (
+ <>
+ <code className="rule">{GradleBuildDSL.Groovy}</code>
+ <ClipboardIconButton copyValue={GradleBuildDSL.Groovy} />
+ </>
+ ),
+ kotlin: (
+ <>
+ <code className="rule">{GradleBuildDSL.Kotlin}</code>
+ <ClipboardIconButton copyValue={GradleBuildDSL.Kotlin} />
+ </>
+ ),
+ sq: <code className="rule">org.sonarqube</code>,
+ }}
+ />
+ <GradleBuildSelection className="big-spacer-top big-spacer-bottom">
+ {(build) => (
+ <CodeSnippet snippet={buildGradleSnippet(component.key, component.name, build)} />
+ )}
+ </GradleBuildSelection>
+ </li>
+ );
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 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.
+ */
+import React from 'react';
+import ButtonToggle from '../../controls/ButtonToggle';
+import { GradleBuildDSL } from '../types';
+
+interface Props {
+ className?: string;
+ children: (build: GradleBuildDSL) => React.ReactNode;
+}
+
+export default function GradleBuildSelection({ children, className }: Props) {
+ const [build, setBuild] = React.useState<GradleBuildDSL>(GradleBuildDSL.Groovy);
+
+ const buildOptions = Object.values(GradleBuildDSL).map((v: GradleBuildDSL) => ({
+ label: v,
+ value: v,
+ }));
+
+ return (
+ <>
+ <div className={className}>
+ <ButtonToggle
+ options={buildOptions}
+ value={build}
+ onCheck={(value: GradleBuildDSL) => setBuild(value)}
+ />
+ </div>
+ {children(build)}
+ </>
+ );
+}
getTutorialActionButtons,
getTutorialBuildButtons,
} from '../../test-utils';
-import { TutorialModes } from '../../types';
+import { GradleBuildDSL, TutorialModes } from '../../types';
import GitHubActionTutorial, { GitHubActionTutorialProps } from '../GitHubActionTutorial';
jest.mock('../../../../api/user-tokens');
// Gradle
await user.click(ui.gradleBuildButton.get());
- expect(getCopyToClipboardValue(1)).toMatchSnapshot('Gradle: build.gradle');
- expect(getCopyToClipboardValue(3)).toMatchSnapshot('Gradle: .github/workflows/build.yml');
+ expect(getCopyToClipboardValue(2)).toMatchSnapshot('Groovy: build.gradle');
+ await user.click(ui.gradleDSLButton(GradleBuildDSL.Kotlin).get());
+ expect(getCopyToClipboardValue(2)).toMatchSnapshot('Kotlin: build.gradle.kts');
+ expect(getCopyToClipboardValue(4)).toMatchSnapshot('Gradle: .github/workflows/build.yml');
// .NET
await user.click(ui.dotnetBuildButton.get());
run: ./gradlew build sonar --info"
`;
-exports[`should follow and complete all steps: Gradle: build.gradle 1`] = `
+exports[`should follow and complete all steps: Groovy: build.gradle 1`] = `
"plugins {
id "org.sonarqube" version "4.0.0.2929"
}
}"
`;
+exports[`should follow and complete all steps: Kotlin: build.gradle.kts 1`] = `
+"plugins {
+ id("org.sonarqube") version "4.0.0.2929"
+}
+
+sonar {
+ properties {
+ property("sonar.projectKey", "my-project")
+ property("sonar.projectName", "MyProject")
+ }
+}"
+`;
+
exports[`should follow and complete all steps: Maven: .github/workflows/build.yml 1`] = `
"name: Build
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
-import { FormattedMessage } from 'react-intl';
-import { ClipboardIconButton } from '../../../../components/controls/clipboard';
-import { translate } from '../../../../helpers/l10n';
import { Component } from '../../../../types/types';
-import CodeSnippet from '../../../common/CodeSnippet';
import CreateYmlFile from '../../components/CreateYmlFile';
import FinishButton from '../../components/FinishButton';
-import { buildGradleSnippet } from '../../utils';
+import GradleBuild from '../../components/GradleBuild';
import { GITHUB_ACTIONS_RUNS_ON_LINUX } from '../constants';
import { generateGitHubActionsYaml } from '../utils';
return (
<>
- <li className="abs-width-600">
- <FormattedMessage
- defaultMessage={translate('onboarding.tutorial.with.yaml.gradle')}
- id="onboarding.tutorial.with.yaml.gradle"
- values={{
- gradle: (
- <>
- <code className="rule">build.gradle</code>
- <ClipboardIconButton copyValue="build.gradle" />
- </>
- ),
- sq: <code className="rule">org.sonarqube</code>,
- }}
- />
- <CodeSnippet snippet={buildGradleSnippet(component.key, component.name)} />
- </li>
+ <GradleBuild component={component} />
<CreateYmlFile
yamlFileName=".github/workflows/build.yml"
yamlTemplate={generateGitHubActionsYaml(
import { withCLanguageFeature } from '../../hoc/withCLanguageFeature';
import FinishButton from '../components/FinishButton';
import GithubCFamilyExampleRepositories from '../components/GithubCFamilyExampleRepositories';
+import GradleBuildSelection from '../components/GradleBuildSelection';
import RenderOptions from '../components/RenderOptions';
import Step from '../components/Step';
-import { BuildTools, TutorialModes } from '../types';
+import { BuildTools, GradleBuildDSL, TutorialModes } from '../types';
import PipeCommand from './commands/PipeCommand';
export interface YmlFileStepProps extends WithAvailableFeaturesProps {
<sonar.qualitygate.wait>true</sonar.qualitygate.wait>
</properties>`;
-const gradleSnippet = (key: string, name: string) => `plugins {
+const gradleSnippet = (key: string, name: string, build: GradleBuildDSL) => {
+ const map = {
+ [GradleBuildDSL.Groovy]: `plugins {
id "org.sonarqube" version "${GRADLE_SCANNER_VERSION}"
}
property "sonar.projectName", "${name}"
property "sonar.qualitygate.wait", true
}
-}`;
+}`,
+ [GradleBuildDSL.Kotlin]: `plugins {
+ id ("org.sonarqube") version "${GRADLE_SCANNER_VERSION}"
+}
+
+sonar {
+ properties {
+ property("sonar.projectKey", "${key}")
+ property("sonar.projectName", "${name}")
+ property("sonar.qualitygate.wait", true)
+ }
+}`,
+ };
+ return map[build];
+};
const otherSnippet = (key: string) => `sonar.projectKey=${key}
sonar.qualitygate.wait=true
const filenameForBuildTool = {
[BuildTools.Maven]: 'pom.xml',
- [BuildTools.Gradle]: 'build.gradle',
+ [BuildTools.Gradle]: GradleBuildDSL.Groovy,
[BuildTools.CFamily]: 'sonar-project.properties',
[BuildTools.Other]: 'sonar-project.properties',
};
`onboarding.tutorial.with.gitlab_ci.project_key.${buildTool}.step2`
)}
id={`onboarding.tutorial.with.gitlab_ci.project_key.${buildTool}.step2`}
- values={{
- file: (
- <>
- <code className="rule">{filenameForBuildTool[buildTool]}</code>
- <ClipboardIconButton
- className="little-spacer-left"
- copyValue={filenameForBuildTool[buildTool]}
- />
- </>
- ),
- }}
+ values={Object.assign(
+ {
+ file: (
+ <>
+ <code className="rule">{filenameForBuildTool[buildTool]}</code>
+ <ClipboardIconButton
+ className="little-spacer-left"
+ copyValue={filenameForBuildTool[buildTool]}
+ />
+ </>
+ ),
+ },
+ buildTool === BuildTools.Gradle
+ ? {
+ file2: (
+ <>
+ <code className="rule">{GradleBuildDSL.Kotlin}</code>
+ <ClipboardIconButton
+ className="little-spacer-left"
+ copyValue={GradleBuildDSL.Kotlin}
+ />
+ </>
+ ),
+ }
+ : {}
+ )}
/>
- <CodeSnippet snippet={snippetForBuildTool[buildTool](component.key, component.name)} />
+ {buildTool === BuildTools.Gradle ? (
+ <GradleBuildSelection className="spacer-top big-spacer-bottom">
+ {(build) => (
+ <CodeSnippet
+ snippet={snippetForBuildTool[buildTool](component.key, component.name, build)}
+ />
+ )}
+ </GradleBuildSelection>
+ ) : (
+ <CodeSnippet snippet={snippetForBuildTool[buildTool](component.key)} />
+ )}
</li>
)}
{buildTool && (
getTutorialActionButtons,
getTutorialBuildButtons,
} from '../../test-utils';
-import { TutorialModes } from '../../types';
+import { GradleBuildDSL, TutorialModes } from '../../types';
import GitLabCITutorial, { GitLabCITutorialProps } from '../GitLabCITutorial';
jest.mock('../../../../api/user-tokens');
// Gradle
await user.click(ui.gradleBuildButton.get());
- expect(getCopyToClipboardValue(1)).toMatchSnapshot('Gradle: build.gradle');
- expect(getCopyToClipboardValue(3)).toMatchSnapshot('Gradle: gitlab-ci.yml');
+ expect(getCopyToClipboardValue(2)).toMatchSnapshot('Groovy: build.gradle');
+ await user.click(ui.gradleDSLButton(GradleBuildDSL.Kotlin).get());
+ expect(getCopyToClipboardValue(2)).toMatchSnapshot('Kotlin: build.gradle.kts');
+ expect(getCopyToClipboardValue(4)).toMatchSnapshot('Gradle: gitlab-ci.yml');
// .NET
await user.click(ui.dotnetBuildButton.get());
"
`;
-exports[`should follow and complete all steps: Gradle: build.gradle 1`] = `
-"plugins {
- id "org.sonarqube" version "4.0.0.2929"
-}
-
-sonar {
- properties {
- property "sonar.projectKey", "my-project"
- property "sonar.projectName", "MyProject"
- property "sonar.qualitygate.wait", true
- }
-}"
-`;
-
exports[`should follow and complete all steps: Gradle: gitlab-ci.yml 1`] = `
"sonarqube-check:
image: gradle:jre11-slim
"
`;
+exports[`should follow and complete all steps: Groovy: build.gradle 1`] = `
+"plugins {
+ id "org.sonarqube" version "4.0.0.2929"
+}
+
+sonar {
+ properties {
+ property "sonar.projectKey", "my-project"
+ property "sonar.projectName", "MyProject"
+ property "sonar.qualitygate.wait", true
+ }
+}"
+`;
+
+exports[`should follow and complete all steps: Kotlin: build.gradle.kts 1`] = `
+"plugins {
+ id ("org.sonarqube") version "4.0.0.2929"
+}
+
+sonar {
+ properties {
+ property("sonar.projectKey", "my-project")
+ property("sonar.projectName", "MyProject")
+ property("sonar.qualitygate.wait", true)
+ }
+}"
+`;
+
exports[`should follow and complete all steps: Maven: gitlab-ci.yml 1`] = `
"sonarqube-check:
image: maven:3.6.3-jdk-11
getTutorialActionButtons,
getTutorialBuildButtons,
} from '../../test-utils';
+import { GradleBuildDSL } from '../../types';
import JenkinsTutorial, { JenkinsTutorialProps } from '../JenkinsTutorial';
jest.mock('../../../../api/user-tokens');
await user.click(ui.mavenBuildButton.get());
expect(getCopyToClipboardValue()).toMatchSnapshot(`maven jenkinsfile`);
- // Gradle
+ // Gradle (Groovy)
await user.click(ui.gradleBuildButton.get());
- expect(getCopyToClipboardValue()).toMatchSnapshot(`build.gradle file`);
+ expect(getCopyToClipboardValue()).toMatchSnapshot(`Groovy: build.gradle file`);
+ // Gradle(Kotlin)
+ await user.click(ui.gradleDSLButton(GradleBuildDSL.Kotlin).get());
+ expect(getCopyToClipboardValue()).toMatchSnapshot(`Kotlin: build.gradle.kts file`);
expect(getCopyToClipboardValue(1)).toMatchSnapshot(`gradle jenkinsfile`);
// .NET
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: build.gradle file 1`] = `
+exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: Groovy: build.gradle file 1`] = `
"plugins {
id "org.sonarqube" version "4.0.0.2929"
}
}"
`;
+exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: Kotlin: build.gradle.kts file 1`] = `
+"plugins {
+ id("org.sonarqube") version "4.0.0.2929"
+}
+
+sonar {
+ properties {
+ property("sonar.projectKey", "my-project")
+ property("sonar.projectName", "MyProject")
+ }
+}"
+`;
+
exports[`bitbucket: can select devops platform and complete all the steps with copying code snippets: cfamily linux jenkinsfile 1`] = `
"node {
stage('SCM') {
"
`;
-exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: build.gradle file 1`] = `
+exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: Groovy: build.gradle file 1`] = `
"plugins {
id "org.sonarqube" version "4.0.0.2929"
}
}"
`;
+exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: Kotlin: build.gradle.kts file 1`] = `
+"plugins {
+ id("org.sonarqube") version "4.0.0.2929"
+}
+
+sonar {
+ properties {
+ property("sonar.projectKey", "my-project")
+ property("sonar.projectName", "MyProject")
+ }
+}"
+`;
+
exports[`bitbucketcloud: can select devops platform and complete all the steps with copying code snippets: cfamily linux jenkinsfile 1`] = `
"node {
stage('SCM') {
"
`;
-exports[`github: can select devops platform and complete all the steps with copying code snippets: build.gradle file 1`] = `
+exports[`github: can select devops platform and complete all the steps with copying code snippets: Groovy: build.gradle file 1`] = `
"plugins {
id "org.sonarqube" version "4.0.0.2929"
}
}"
`;
+exports[`github: can select devops platform and complete all the steps with copying code snippets: Kotlin: build.gradle.kts file 1`] = `
+"plugins {
+ id("org.sonarqube") version "4.0.0.2929"
+}
+
+sonar {
+ properties {
+ property("sonar.projectKey", "my-project")
+ property("sonar.projectName", "MyProject")
+ }
+}"
+`;
+
exports[`github: can select devops platform and complete all the steps with copying code snippets: cfamily linux jenkinsfile 1`] = `
"node {
stage('SCM') {
"
`;
-exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: build.gradle file 1`] = `
+exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: Groovy: build.gradle file 1`] = `
"plugins {
id "org.sonarqube" version "4.0.0.2929"
}
}"
`;
+exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: Kotlin: build.gradle.kts file 1`] = `
+"plugins {
+ id("org.sonarqube") version "4.0.0.2929"
+}
+
+sonar {
+ properties {
+ property("sonar.projectKey", "my-project")
+ property("sonar.projectName", "MyProject")
+ }
+}"
+`;
+
exports[`gitlab: can select devops platform and complete all the steps with copying code snippets: cfamily linux jenkinsfile 1`] = `
"node {
stage('SCM') {
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { FormattedMessage } from 'react-intl';
+import { translate } from '../../../../helpers/l10n';
import CodeSnippet from '../../../common/CodeSnippet';
import FinishButton from '../../components/FinishButton';
-import SentenceWithFilename from '../../components/SentenceWithFilename';
+import GradleBuildSelection from '../../components/GradleBuildSelection';
+import { GradleBuildDSL } from '../../types';
import { buildGradleSnippet } from '../../utils';
import { LanguageProps } from '../JenkinsfileStep';
import CreateJenkinsfileBulletPoint from './CreateJenkinsfileBulletPoint';
export default function Gradle(props: LanguageProps) {
const { component } = props;
+
return (
<>
<li className="abs-width-600">
- <SentenceWithFilename
- filename="build.gradle"
- translationKey="onboarding.tutorial.with.jenkins.jenkinsfile.gradle.step2"
- />
- <CodeSnippet snippet={buildGradleSnippet(component.key, component.name)} />
+ <span className="markdown">
+ <FormattedMessage
+ defaultMessage={translate(
+ 'onboarding.tutorial.with.jenkins.jenkinsfile.gradle.step2',
+ 'sentence'
+ )}
+ id="onboarding.tutorial.with.jenkins.jenkinsfile.gradle.step2.sentence"
+ values={{
+ groovy: <code>{GradleBuildDSL.Groovy}</code>,
+ kotlin: <code>{GradleBuildDSL.Kotlin}</code>,
+ }}
+ />
+ </span>
+ <GradleBuildSelection className="big-spacer-top big-spacer-bottom">
+ {(build) => (
+ <CodeSnippet snippet={buildGradleSnippet(component.key, component.name, build)} />
+ )}
+ </GradleBuildSelection>
</li>
<CreateJenkinsfileBulletPoint snippet={JENKINSFILE_SNIPPET} />
<FinishButton onClick={props.onDone} />
import CodeSnippet from '../../../common/CodeSnippet';
import DocLink from '../../../common/DocLink';
import InstanceMessage from '../../../common/InstanceMessage';
+import GradleBuildSelection from '../../components/GradleBuildSelection';
+import { GradleBuildDSL } from '../../types';
import DoneNextSteps from '../DoneNextSteps';
export interface JavaGradleProps {
token: string;
}
+const config = {
+ [GradleBuildDSL.Groovy]: `plugins {
+ id "org.sonarqube" version "${GRADLE_SCANNER_VERSION}"
+}`,
+ [GradleBuildDSL.Kotlin]: `plugins {
+ id("org.sonarqube") version "${GRADLE_SCANNER_VERSION}"
+}`,
+};
+
export default function JavaGradle(props: JavaGradleProps) {
const { baseUrl, component, token } = props;
- const config = `plugins {
- id "org.sonarqube" version "${GRADLE_SCANNER_VERSION}"
-}`;
const command = [
'./gradlew sonar',
id="onboarding.analysis.java.gradle.text.1"
values={{
plugin_code: <code>org.sonarqube</code>,
- filename: <code>build.gradle</code>,
+ groovy: <code>{GradleBuildDSL.Groovy}</code>,
+ kotlin: <code>{GradleBuildDSL.Kotlin}</code>,
}}
/>
</p>
)}
</InstanceMessage>
- <CodeSnippet snippet={config} />
+ <GradleBuildSelection className="big-spacer-top big-spacer-bottom">
+ {(build) => <CodeSnippet snippet={config[build]} />}
+ </GradleBuildSelection>
<p className="big-spacer-bottom markdown">
<em className="small text-muted">
<FormattedMessage
*/
import { screen } from '@testing-library/react';
import { byRole, byText } from 'testing-library-selector';
-import { BuildTools, OSs, TutorialModes } from './types';
+import { BuildTools, GradleBuildDSL, OSs, TutorialModes } from './types';
const CI_TRANSLATE_MAP: Partial<Record<TutorialModes, string>> = {
[TutorialModes.BitbucketPipelines]: 'bitbucket_pipelines',
describeBuildTitle: byRole('heading', { name: 'onboarding.build' }),
mavenBuildButton: byRole('button', { name: `onboarding.build.${BuildTools.Maven}` }),
gradleBuildButton: byRole('button', { name: `onboarding.build.${BuildTools.Gradle}` }),
+ gradleDSLButton: (name: GradleBuildDSL) => byRole('button', { name }),
dotnetBuildButton: byRole('button', { name: `onboarding.build.${BuildTools.DotNet}` }),
cFamilyBuildButton: byRole('button', { name: `onboarding.build.${BuildTools.CFamily}` }),
otherBuildButton: byRole('button', { name: `onboarding.build.${BuildTools.Other}` }),
Other = 'other',
}
+export enum GradleBuildDSL {
+ Groovy = 'build.gradle',
+ Kotlin = 'build.gradle.kts',
+}
+
export enum OSs {
Linux = 'linux',
Windows = 'win',
import { convertGithubApiUrlToLink, stripTrailingSlash } from '../../helpers/urls';
import { AlmSettingsInstance, ProjectAlmBindingResponse } from '../../types/alm-settings';
import { UserToken } from '../../types/token';
+import { GradleBuildDSL } from './types';
export function quote(os: string): (s: string) => string {
return os === 'win' ? (s: string) => `"${s}"` : (s: string) => s;
}
-export function buildGradleSnippet(key: string, name: string) {
- return `plugins {
+export function buildGradleSnippet(key: string, name: string, build: GradleBuildDSL) {
+ const map = {
+ [GradleBuildDSL.Groovy]: `plugins {
id "org.sonarqube" version "${GRADLE_SCANNER_VERSION}"
}
property "sonar.projectKey", "${key}"
property "sonar.projectName", "${name}"
}
-}`;
+}`,
+ [GradleBuildDSL.Kotlin]: `plugins {
+ id("org.sonarqube") version "${GRADLE_SCANNER_VERSION}"
+}
+
+sonar {
+ properties {
+ property("sonar.projectKey", "${key}")
+ property("sonar.projectName", "${name}")
+ }
+}`,
+ };
+ return map[build];
}
export function getUniqueTokenName(tokens: UserToken[], initialTokenName: string) {
onboarding.analysis.java.maven.text.custom=Run the following command in your project's folder.
onboarding.analysis.java.gradle.header=Execute the Scanner for Gradle
-onboarding.analysis.java.gradle.text.1=Running an analysis with Gradle is straighforward. You just need to declare the {plugin_code} plugin in your {filename} file:
+onboarding.analysis.java.gradle.text.1=Running an analysis with Gradle is straighforward. You just need to declare the {plugin_code} plugin in your {groovy} or {kotlin} file:
onboarding.analysis.java.gradle.text.2=and run the following command:
onboarding.analysis.java.gradle.latest_version=You can find the latest version of the Gradle plugin {link}.
onboarding.analysis.java.gradle.docs_link=official documentation of the Scanner for Gradle
onboarding.tutorial.choose_method.bitbucket-pipelines=With Bitbucket Pipelines
-onboarding.tutorial.with.yaml.gradle=Update your {gradle} file with the {sq} plugin and it's configuration:
+onboarding.tutorial.with.yaml.gradle=Update your {groovy} or {kotlin} file with the {sq} plugin and its configuration:
onboarding.tutorial.with.gitlab_ci.title=Analyze your project with GitLab CI
onboarding.tutorial.with.gitlab_ci.project_key.title=Set your project key
onboarding.tutorial.with.gitlab_ci.project_key.maven.step2=Add the following to your {file} file:
-onboarding.tutorial.with.gitlab_ci.project_key.gradle.step2=Add the following to your {file} file:
+onboarding.tutorial.with.gitlab_ci.project_key.gradle.step2=Add the following to your {file} or {file2} file:
onboarding.tutorial.with.gitlab_ci.project_key.other.step2=Create a {file} file in your repository and paste the following code:
onboarding.tutorial.with.gitlab_ci.project_key.dotnet.step2=Create a {file} file in your repository and paste the following code:
onboarding.tutorial.with.gitlab_ci.project_key.cfamily.step2=Create a {file} file in your repository and paste the following code:
onboarding.tutorial.with.jenkins.jenkinsfile.maven.step3.help2.sentence=The name is located under the {path} section, in the {name} field.
onboarding.tutorial.with.jenkins.jenkinsfile.maven.step3.help2.sentence.path=Maven > Maven installations
onboarding.tutorial.with.jenkins.jenkinsfile.maven.step3.help2.sentence.name=Name
-onboarding.tutorial.with.jenkins.jenkinsfile.gradle.step2.sentence=Add the following to your {file} file:
+onboarding.tutorial.with.jenkins.jenkinsfile.gradle.step2.sentence=Add the following to your {groovy} or {kotlin} file:
onboarding.tutorial.with.jenkins.jenkinsfile.dotnet.build_agent=Choose your build agent.
onboarding.tutorial.with.jenkins.dotnet.msbuild.prereqs.title.sentence=Prerequisite: Add a {default_msbuild} tool.