You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Gradle.tsx 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  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.
  10. *
  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.
  15. *
  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.
  19. */
  20. import * as React from 'react';
  21. import { Component } from '../../../../types/types';
  22. import CreateYmlFile from '../../components/CreateYmlFile';
  23. import GradleBuild from '../../components/GradleBuild';
  24. import { GITHUB_ACTIONS_RUNS_ON_LINUX } from '../constants';
  25. import { generateGitHubActionsYaml } from '../utils';
  26. import MonorepoDocLinkFallback from './MonorepoDocLinkFallback';
  27. export interface GradleProps {
  28. branchesEnabled?: boolean;
  29. mainBranchName: string;
  30. monorepo?: boolean;
  31. component: Component;
  32. }
  33. const GRADLE_YAML_STEPS = `
  34. - name: Set up JDK 17
  35. uses: actions/setup-java@v1
  36. with:
  37. java-version: 17
  38. - name: Cache SonarQube packages
  39. uses: actions/cache@v1
  40. with:
  41. path: ~/.sonar/cache
  42. key: \${{ runner.os }}-sonar
  43. restore-keys: \${{ runner.os }}-sonar
  44. - name: Cache Gradle packages
  45. uses: actions/cache@v1
  46. with:
  47. path: ~/.gradle/caches
  48. key: \${{ runner.os }}-gradle-\${{ hashFiles('**/*.gradle') }}
  49. restore-keys: \${{ runner.os }}-gradle
  50. - name: Build and analyze
  51. env:
  52. SONAR_TOKEN: \${{ secrets.SONAR_TOKEN }}
  53. SONAR_HOST_URL: \${{ secrets.SONAR_HOST_URL }}
  54. run: ./gradlew build sonar --info`;
  55. export default function Gradle(props: GradleProps) {
  56. const { component, branchesEnabled, mainBranchName, monorepo } = props;
  57. return (
  58. <>
  59. <GradleBuild component={component} />
  60. {monorepo ? (
  61. <MonorepoDocLinkFallback />
  62. ) : (
  63. <CreateYmlFile
  64. yamlFileName=".github/workflows/build.yml"
  65. yamlTemplate={generateGitHubActionsYaml(
  66. mainBranchName,
  67. !!branchesEnabled,
  68. GITHUB_ACTIONS_RUNS_ON_LINUX,
  69. GRADLE_YAML_STEPS,
  70. )}
  71. />
  72. )}
  73. </>
  74. );
  75. }