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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import org.apache.tools.ant.filters.ReplaceTokens
  2. sonarqube {
  3. properties {
  4. property 'sonar.projectName', "${projectTitle} :: Application"
  5. }
  6. }
  7. configurations {
  8. zip
  9. jsw
  10. scanner
  11. web
  12. shutdowner
  13. jdbc_mssql {
  14. transitive = false
  15. }
  16. jdbc_postgresql {
  17. transitive = false
  18. }
  19. jdbc_h2 {
  20. transitive = false
  21. }
  22. bundledPlugin {
  23. transitive = false
  24. }
  25. }
  26. dependencies {
  27. // please keep list ordered
  28. compile 'org.slf4j:slf4j-api'
  29. compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client'
  30. compile project(':server:sonar-ce')
  31. compile project(':server:sonar-main')
  32. compile project(':server:sonar-process')
  33. compile project(':server:sonar-webserver')
  34. compile project(':sonar-core')
  35. compile project(path: ':sonar-plugin-api', configuration: 'shadow')
  36. compile project(':sonar-plugin-api-impl')
  37. compileOnly 'com.google.code.findbugs:jsr305'
  38. jsw 'tanukisoft:wrapper:3.2.3'
  39. scanner project(path: ':sonar-scanner-engine-shaded', configuration: 'shadow')
  40. web project(':server:sonar-web')
  41. shutdowner project(':sonar-shutdowner')
  42. jdbc_h2 'com.h2database:h2'
  43. jdbc_mssql 'com.microsoft.sqlserver:mssql-jdbc'
  44. jdbc_postgresql 'org.postgresql:postgresql'
  45. }
  46. // declare dependencies in configuration bundledPlugin to be packaged in lib/extensions
  47. apply from: 'bundled_plugins.gradle'
  48. jar {
  49. manifest {
  50. attributes(
  51. 'Class-Path': configurations.compile.resolvedConfiguration.files.collect { "common/${it.getName()}" }.join(' '),
  52. 'Main-Class': 'org.sonar.application.App'
  53. )
  54. }
  55. }
  56. task zip(type: Zip, dependsOn: [configurations.compile]) {
  57. duplicatesStrategy DuplicatesStrategy.EXCLUDE
  58. def archiveDir = "sonarqube-$version"
  59. into("${archiveDir}/") {
  60. from file('src/main/assembly')
  61. exclude 'conf/sonar.properties'
  62. exclude 'elasticsearch-patch'
  63. // elasticsearch script will be replaced by patched version below
  64. exclude 'elasticsearch/bin/elasticsearch'
  65. exclude 'elasticsearch/bin/elasticsearch-cli'
  66. exclude 'elasticsearch/bin/elasticsearch-keystore'
  67. exclude 'elasticsearch/bin/elasticsearch-node'
  68. exclude 'elasticsearch/bin/elasticsearch-shard'
  69. exclude 'elasticsearch/lib/tools/**'
  70. exclude 'elasticsearch/modules/aggs-matrix-stats/**'
  71. exclude 'elasticsearch/modules/geo/**'
  72. exclude 'elasticsearch/modules/ingest-common/**'
  73. exclude 'elasticsearch/modules/ingest-geoip/**'
  74. exclude 'elasticsearch/modules/ingest-user-agent/**'
  75. exclude 'elasticsearch/modules/kibana/**'
  76. exclude 'elasticsearch/modules/lang-expression/**'
  77. exclude 'elasticsearch/modules/lang-mustache/**'
  78. exclude 'elasticsearch/modules/mapper-extras/**'
  79. exclude 'elasticsearch/modules/rank-eval/**'
  80. exclude 'elasticsearch/modules/reindex/**'
  81. exclude 'elasticsearch/modules/repository-url/**'
  82. exclude 'elasticsearch/modules/tasks/**'
  83. }
  84. into("${archiveDir}/conf/") {
  85. from file('src/main/assembly/conf/sonar.properties')
  86. filter(ReplaceTokens, tokens: [
  87. 'searchDefaultHeapSize': '512MB',
  88. 'searchJavaOpts' : '-Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError',
  89. 'ceDefaultHeapSize' : '512MB',
  90. 'ceJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError',
  91. 'webDefaultHeapSize' : '512MB',
  92. 'webJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError'
  93. ])
  94. }
  95. into("${archiveDir}/elasticsearch/") {
  96. from file('src/main/assembly/elasticsearch-patch')
  97. include 'bin/elasticsearch'
  98. }
  99. // Create the empty dir (plugins) required by elasticsearch
  100. into("${archiveDir}/elasticsearch/") {
  101. from "$buildDir/elasticsearch"
  102. }
  103. into("${archiveDir}/lib/") {
  104. from jar
  105. }
  106. into("${archiveDir}/lib/extensions/") {
  107. from configurations.bundledPlugin
  108. }
  109. into("${archiveDir}/lib/jsw/") {
  110. from configurations.jsw
  111. }
  112. into("${archiveDir}/lib/scanner/") {
  113. from configurations.scanner
  114. }
  115. into("${archiveDir}/lib/common/") {
  116. from configurations.compile
  117. }
  118. into("${archiveDir}/web/") {
  119. duplicatesStrategy DuplicatesStrategy.FAIL
  120. // FIXME use configurations.web with correct artifacts
  121. from(tasks.getByPath(':server:sonar-web:yarn_run').outputs) { a ->
  122. if (official) {
  123. project(':private:branding').fileTree('src').visit { b ->
  124. if (!b.isDirectory()) {
  125. a.exclude b.relativePath.toString()
  126. }
  127. }
  128. }
  129. }
  130. if (official) {
  131. from project(':private:branding').file('src')
  132. }
  133. }
  134. into("${archiveDir}/lib/jdbc/mssql/") {
  135. from configurations.jdbc_mssql
  136. }
  137. into("${archiveDir}/lib/jdbc/postgresql/") {
  138. from configurations.jdbc_postgresql
  139. }
  140. into("${archiveDir}/lib/jdbc/h2/") {
  141. from configurations.jdbc_h2
  142. }
  143. into("${archiveDir}/lib/") {
  144. from configurations.shutdowner
  145. }
  146. }
  147. // Create the empty dir required by elasticsearch
  148. zip.doFirst {
  149. new File(buildDir, 'elasticsearch/plugins').mkdirs()
  150. }
  151. // Check the size of the archive
  152. zip.doLast {
  153. def minLength = 238000000
  154. def maxLength = 258000000
  155. def length = archiveFile.get().asFile.length()
  156. if (length < minLength)
  157. throw new GradleException("$archiveName size ($length) too small. Min is $minLength")
  158. if (length > maxLength)
  159. throw new GradleException("$distsDir/$archiveName size ($length) too large. Max is $maxLength")
  160. }
  161. assemble.dependsOn zip
  162. // the script start.sh unpacks OSS distribution into $buildDir/distributions/sonarqube-oss.
  163. // This directory should be deleted when the zip is changed.
  164. task cleanLocalUnzippedDir(dependsOn: zip) {
  165. def unzippedDir = file("$buildDir/distributions/sonarqube-$version")
  166. inputs.files(file("$buildDir/distributions/sonar-application-${version}.zip"))
  167. outputs.upToDateWhen { true }
  168. doLast {
  169. println("delete directory ${unzippedDir}")
  170. project.delete(unzippedDir)
  171. }
  172. }
  173. assemble.dependsOn cleanLocalUnzippedDir
  174. artifacts { zip zip }
  175. artifactoryPublish.skip = false
  176. publishing {
  177. publications {
  178. mavenJava(MavenPublication) {
  179. artifact zip
  180. }
  181. }
  182. }