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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. task yarn_run(type: Exec) {
  49. def docsVersion = version.split("[.-]").take(2).join('.')
  50. inputs.property('version', docsVersion)
  51. inputs.file(rootProject.file('build.gradle'));
  52. inputs.dir('src').withPathSensitivity(PathSensitivity.RELATIVE)
  53. ['build.gradle', '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. environment += [ GATSBY_DOCS_VERSION: docsVersion ]
  59. commandLine osAdaptiveCommand(['npm', 'run', 'build'])
  60. }
  61. yarn_run.dependsOn(extractAnalyzerDocFiles)
  62. build.dependsOn(yarn_run)
  63. // To clean outputs outside of "build" directory:
  64. clean.dependsOn(cleanYarn_run)
  65. task "yarn_check-ci"(type: Exec) {
  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. commandLine osAdaptiveCommand(['npm', 'run', 'check-ci'])
  74. }
  75. task "yarn_validate-ci"(type: Exec) {
  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.cacheIf { true }
  84. commandLine osAdaptiveCommand(['npm', 'run', 'validate-ci'])
  85. }
  86. // Check for known vulnerabilities
  87. task dependency_audit(type: Exec) {
  88. inputs.file('package.json')
  89. outputs.cacheIf { false }
  90. ignoreExitValue = true
  91. commandLine osAdaptiveCommand(['npm', 'run', 'audit-ci'])
  92. }
  93. task dependencyCheckAggregate_prerequisites(type: Exec) {
  94. // the OWASP tool does not support yarn and its yarn.lock files, so node modules
  95. // should be explicitly installed (yarn install) before running the audit
  96. // See https://github.com/jeremylong/DependencyCheck/issues/2393
  97. commandLine osAdaptiveCommand(['yarn', 'install', '--immutable'])
  98. }
  99. task zip(type: Zip) {
  100. def archiveDir = "$version"
  101. duplicatesStrategy DuplicatesStrategy.EXCLUDE
  102. baseName "sonar-docs"
  103. into("${archiveDir}") {
  104. from tasks.getByName('yarn_run').outputs
  105. }
  106. }
  107. zip.dependsOn yarn_run
  108. assemble.dependsOn zip
  109. publishing {
  110. publications {
  111. docs(MavenPublication) {
  112. artifactId 'sonar-docs'
  113. artifact zip
  114. }
  115. }
  116. }
  117. artifactory {
  118. publish {
  119. repository {
  120. repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO_PRIVATE')
  121. username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME') ?: project.properties.artifactoryUsername
  122. password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD') ?: project.properties.artifactoryPaswword
  123. }
  124. defaults {
  125. properties = [
  126. 'build.name' : 'sonar-enterprise',
  127. 'build.number' : System.getenv('BUILD_NUMBER'),
  128. 'pr.branch.target': System.getenv('GITHUB_BASE_BRANCH'),
  129. 'pr.number' : System.getenv('PULL_REQUEST'),
  130. 'vcs.branch' : System.getenv('GITHUB_BRANCH'),
  131. 'vcs.revision' : System.getenv('GIT_SHA1'),
  132. 'version' : version
  133. ]
  134. publishPom = true
  135. publishIvy = false
  136. }
  137. }
  138. }
  139. artifactoryPublish {
  140. skip = false
  141. publishPom = false
  142. publications(publishing.publications.docs)
  143. }
  144. def sources = fileTree(dir: "src") + fileTree(dir: "config") + fileTree(dir: "plugins") + file("gatsby-config.js") + file("gatsby-node.js")
  145. task licenseCheckWeb(type: com.hierynomus.gradle.license.tasks.LicenseCheck) {
  146. source = sources
  147. }
  148. licenseMain.dependsOn licenseCheckWeb
  149. task licenseFormatWeb(type: com.hierynomus.gradle.license.tasks.LicenseFormat) {
  150. source = sources
  151. }
  152. licenseFormat.dependsOn licenseFormatWeb