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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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_run {
  49. def docsVersion = version.split("[.-]").take(2).join('.')
  50. environment = [ GATSBY_DOCS_VERSION: docsVersion ]
  51. inputs.property('version', docsVersion)
  52. inputs.dir('src').withPathSensitivity(PathSensitivity.RELATIVE)
  53. ['gatsby-config.js', 'gatsby-node.js', 'package.json', 'yarn.lock', 'tsconfig.json'].each {
  54. inputs.file(it).withPathSensitivity(PathSensitivity.RELATIVE)
  55. }
  56. outputs.dir('public')
  57. outputs.cacheIf { true }
  58. args = ['build']
  59. }
  60. // To clean outputs outside of "build" directory:
  61. clean.dependsOn(cleanYarn_run)
  62. "yarn_check-ci" {
  63. // Note that outputs are not relocatable, because contain absolute paths, and that's why inputs are not relativized
  64. ['config', 'src'].each {
  65. inputs.dir(it)
  66. }
  67. ['package.json', 'yarn.lock', 'tsconfig.json'].each {
  68. inputs.file(it)
  69. }
  70. dependsOn(yarn)
  71. }
  72. "yarn_validate-ci" {
  73. // Note that outputs are not relocatable, because contain absolute paths, and that's why inputs are not relativized
  74. ['config', 'src'].each {
  75. inputs.dir(it)
  76. }
  77. ['package.json', 'yarn.lock', 'tsconfig.json', '.eslintrc'].each {
  78. inputs.file(it)
  79. }
  80. outputs.file('eslint-report.json')
  81. outputs.dir('coverage')
  82. outputs.cacheIf { true }
  83. dependsOn(yarn)
  84. }
  85. // Check for known vulnerabilities
  86. yarn_audit {
  87. inputs.file('package.json')
  88. outputs.cacheIf { false }
  89. args = ['--groups', 'dependencies', '--level', 'high']
  90. ignoreExitValue = true
  91. dependsOn(yarn)
  92. }
  93. task zip(type: Zip) {
  94. def archiveDir = "$version"
  95. duplicatesStrategy DuplicatesStrategy.EXCLUDE
  96. baseName "sonar-docs"
  97. into("${archiveDir}") {
  98. from tasks.getByName('yarn_run').outputs
  99. }
  100. }
  101. zip.dependsOn yarn_run
  102. assemble.dependsOn zip, extractAnalyzerDocFiles
  103. publishing {
  104. publications {
  105. docs(MavenPublication) {
  106. artifactId 'sonar-docs'
  107. artifact zip
  108. }
  109. }
  110. }
  111. artifactory {
  112. publish {
  113. repository {
  114. repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO_PRIVATE')
  115. username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME') ?: project.properties.artifactoryUsername
  116. password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD') ?: project.properties.artifactoryPaswword
  117. }
  118. defaults {
  119. properties = [
  120. 'build.name' : 'sonar-enterprise',
  121. 'build.number' : System.getenv('BUILD_NUMBER'),
  122. 'pr.branch.target': System.getenv('GITHUB_BASE_BRANCH'),
  123. 'pr.number' : System.getenv('PULL_REQUEST'),
  124. 'vcs.branch' : System.getenv('GITHUB_BRANCH'),
  125. 'vcs.revision' : System.getenv('GIT_SHA1'),
  126. 'version' : version
  127. ]
  128. publishPom = true
  129. publishIvy = false
  130. }
  131. }
  132. }
  133. artifactoryPublish {
  134. skip = false
  135. publishPom = false
  136. publications(publishing.publications.docs)
  137. }
  138. def sources = fileTree(dir: "src") + fileTree(dir: "config") + fileTree(dir: "plugins") + file("gatsby-config.js") + file("gatsby-node.js")
  139. task licenseCheckWeb(type: com.hierynomus.gradle.license.tasks.LicenseCheck) {
  140. source = sources
  141. }
  142. licenseMain.dependsOn licenseCheckWeb
  143. task licenseFormatWeb(type: com.hierynomus.gradle.license.tasks.LicenseFormat) {
  144. source = sources
  145. }
  146. licenseFormat.dependsOn licenseFormatWeb