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.

build.gradle 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. import java.util.regex.Matcher
  2. import java.util.regex.Pattern
  3. Pattern PLUGIN_NAME_PATTERN = Pattern.compile("(sonar-.*-plugin)(.*)")
  4. /**
  5. * This module is building the zip file containing the static web site
  6. */
  7. sonarqube {
  8. skipProject = true
  9. }
  10. group = 'com.sonarsource.sonarqube'
  11. configurations {
  12. bundledPlugin {
  13. transitive = false
  14. }
  15. }
  16. // loads the bundled_plugins.gradle of each edition
  17. // (they will all add there own bundled plugins to the bundledPlugin dependency configuration)
  18. apply from: new File(rootDir, 'sonar-application/bundled_plugins.gradle')
  19. File closeSourceDir = new File(rootDir, 'private');
  20. if (closeSourceDir.exists()) {
  21. apply from: new File(closeSourceDir, 'edition-developer/bundled_plugins.gradle')
  22. apply from: new File(closeSourceDir, 'edition-enterprise/bundled_plugins.gradle')
  23. apply from: new File(closeSourceDir, 'edition-datacenter/bundled_plugins.gradle')
  24. }
  25. task extractAnalyzerDocFiles {
  26. doLast {
  27. configurations.bundledPlugin.files.each {
  28. File file = it
  29. copy {
  30. from(zipTree(file).matching { include 'static/documentation.md', 'META-INF/MANIFEST.MF' }) {
  31. eachFile { fcd ->
  32. if (fcd.getName().endsWith('.md')) {
  33. fcd.relativePath = new RelativePath(true, 'documentation' + '.md')
  34. } else {
  35. fcd.relativePath = new RelativePath(true, 'MANIFEST' + '.MF')
  36. }
  37. }
  38. includeEmptyDirs = false
  39. }
  40. Matcher m = PLUGIN_NAME_PATTERN.matcher(file.getName())
  41. if (m.find()) {
  42. into "$buildDir/tmp/plugin-documentation/" + m.group(1)
  43. }
  44. }
  45. }
  46. }
  47. }
  48. yarn.configure {
  49. dependsOn tasks.getByPath(':server:sonar-ui-common:yarn_run')
  50. }
  51. yarn_run {
  52. def docsVersion = version.split("[.-]").take(2).join('.')
  53. environment = [ GATSBY_DOCS_VERSION: docsVersion ]
  54. inputs.property('version', docsVersion)
  55. inputs.dir('src').withPathSensitivity(PathSensitivity.RELATIVE)
  56. ['gatsby-config.js', 'gatsby-node.js', 'package.json', 'yarn.lock', 'tsconfig.json'].each {
  57. inputs.file(it).withPathSensitivity(PathSensitivity.RELATIVE)
  58. }
  59. outputs.dir('public')
  60. outputs.cacheIf { true }
  61. args = ['build']
  62. }
  63. // To clean outputs outside of "build" directory:
  64. clean.dependsOn(cleanYarn_run)
  65. "yarn_check-ci" {
  66. // Note that outputs are not relocatable, because contain absolute paths, and that's why inputs are not relativized
  67. ['config', 'src'].each {
  68. inputs.dir(it)
  69. }
  70. ['package.json', 'yarn.lock', 'tsconfig.json'].each {
  71. inputs.file(it)
  72. }
  73. dependsOn(yarn)
  74. }
  75. "yarn_validate-ci" {
  76. // Note that outputs are not relocatable, because contain absolute paths, and that's why inputs are not relativized
  77. ['config', 'src'].each {
  78. inputs.dir(it)
  79. }
  80. ['package.json', 'yarn.lock', 'tsconfig.json', '.eslintrc'].each {
  81. inputs.file(it)
  82. }
  83. outputs.file('eslint-report.json')
  84. outputs.dir('coverage')
  85. outputs.cacheIf { true }
  86. dependsOn(yarn)
  87. }
  88. // Check for known vulnerabilities
  89. yarn_audit {
  90. inputs.file('package.json')
  91. outputs.cacheIf { false }
  92. args = ['--groups', 'dependencies', '--level', 'high']
  93. ignoreExitValue = true
  94. dependsOn(yarn)
  95. }
  96. task zip(type: Zip) {
  97. def archiveDir = "$version"
  98. duplicatesStrategy DuplicatesStrategy.EXCLUDE
  99. baseName "sonar-docs"
  100. into("${archiveDir}") {
  101. from tasks.getByName('yarn_run').outputs
  102. }
  103. }
  104. zip.dependsOn yarn_run
  105. assemble.dependsOn zip, extractAnalyzerDocFiles
  106. publishing {
  107. publications {
  108. docs(MavenPublication) {
  109. artifactId 'sonar-docs'
  110. artifact zip
  111. }
  112. }
  113. }
  114. artifactory {
  115. publish {
  116. repository {
  117. repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO_PRIVATE')
  118. username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME') ?: project.properties.artifactoryUsername
  119. password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD') ?: project.properties.artifactoryPaswword
  120. }
  121. defaults {
  122. properties = [
  123. 'build.name' : 'sonar-enterprise',
  124. 'build.number' : System.getenv('BUILD_NUMBER'),
  125. 'pr.branch.target': System.getenv('GITHUB_BASE_BRANCH'),
  126. 'pr.number' : System.getenv('PULL_REQUEST'),
  127. 'vcs.branch' : System.getenv('GITHUB_BRANCH'),
  128. 'vcs.revision' : System.getenv('GIT_SHA1'),
  129. 'version' : version
  130. ]
  131. publishPom = true
  132. publishIvy = false
  133. }
  134. }
  135. }
  136. artifactoryPublish {
  137. skip = false
  138. publishPom = false
  139. publications(publishing.publications.docs)
  140. }
  141. def sources = fileTree(dir: "src") + fileTree(dir: "config") + fileTree(dir: "plugins") + file("gatsby-config.js") + file("gatsby-node.js")
  142. task licenseCheckWeb(type: com.hierynomus.gradle.license.tasks.LicenseCheck) {
  143. source = sources
  144. }
  145. licenseMain.dependsOn licenseCheckWeb
  146. task licenseFormatWeb(type: com.hierynomus.gradle.license.tasks.LicenseFormat) {
  147. source = sources
  148. }
  149. licenseFormat.dependsOn licenseFormatWeb