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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 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
  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