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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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:transport'
  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 extensions/plugins
  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.bat'
  66. exclude 'elasticsearch/bin/elasticsearch-env.bat'
  67. exclude 'elasticsearch/bin/elasticsearch-service.bat'
  68. exclude 'elasticsearch/bin/elasticsearch-service-*.exe'
  69. exclude 'elasticsearch/bin/elasticsearch-certgen*'
  70. exclude 'elasticsearch/bin/elasticsearch-certutil*'
  71. exclude 'elasticsearch/bin/elasticsearch-cli*'
  72. exclude 'elasticsearch/bin/elasticsearch-croneval*'
  73. exclude 'elasticsearch/bin/elasticsearch-keystore*'
  74. exclude 'elasticsearch/bin/elasticsearch-migrate*'
  75. exclude 'elasticsearch/bin/elasticsearch-plugin*'
  76. exclude 'elasticsearch/bin/elasticsearch-saml-metadata*'
  77. exclude 'elasticsearch/bin/elasticsearch-setup-passwords*'
  78. exclude 'elasticsearch/bin/elasticsearch-shard*'
  79. exclude 'elasticsearch/bin/elasticsearch-sql-cli*'
  80. exclude 'elasticsearch/bin/elasticsearch-syskeygen*'
  81. exclude 'elasticsearch/bin/elasticsearch-translog*'
  82. exclude 'elasticsearch/bin/elasticsearch-users*'
  83. exclude 'elasticsearch/bin/x-pack/**'
  84. exclude 'elasticsearch/bin/x-pack*'
  85. exclude 'elasticsearch/lib/tools/**'
  86. exclude 'elasticsearch/modules/aggs-matrix-stats/**'
  87. exclude 'elasticsearch/modules/ingest-common/**'
  88. exclude 'elasticsearch/modules/ingest-geoip/**'
  89. exclude 'elasticsearch/modules/ingest-user-agent/**'
  90. exclude 'elasticsearch/modules/lang-expression/**'
  91. exclude 'elasticsearch/modules/lang-groovy/**'
  92. exclude 'elasticsearch/modules/lang-mustache/**'
  93. exclude 'elasticsearch/modules/rank-eval/**'
  94. exclude 'elasticsearch/modules/tribe/**'
  95. exclude 'elasticsearch/modules/x-pack-*/**'
  96. }
  97. into("${archiveDir}/conf/") {
  98. from file('src/main/assembly/conf/sonar.properties')
  99. filter(ReplaceTokens, tokens: [
  100. 'searchDefaultHeapSize': '512MB',
  101. 'searchJavaOpts' : '-Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError',
  102. 'ceDefaultHeapSize' : '512MB',
  103. 'ceJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError',
  104. 'webDefaultHeapSize' : '512MB',
  105. 'webJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError'
  106. ])
  107. }
  108. into("${archiveDir}/elasticsearch/") {
  109. from file('src/main/assembly/elasticsearch-patch')
  110. include 'bin/elasticsearch'
  111. }
  112. // Create the empty dir (plugins) required by elasticsearch
  113. into("${archiveDir}/elasticsearch/") {
  114. from "$buildDir/elasticsearch"
  115. }
  116. into("${archiveDir}/lib/") {
  117. from jar
  118. }
  119. into("${archiveDir}/extensions/plugins/") {
  120. from configurations.bundledPlugin
  121. }
  122. into("${archiveDir}/lib/jsw/") {
  123. from configurations.jsw
  124. }
  125. into("${archiveDir}/lib/scanner/") {
  126. from configurations.scanner
  127. }
  128. into("${archiveDir}/lib/common/") {
  129. from configurations.compile
  130. }
  131. into("${archiveDir}/web/") {
  132. duplicatesStrategy DuplicatesStrategy.FAIL
  133. // FIXME use configurations.web with correct artifacts
  134. from(tasks.getByPath(':server:sonar-web:yarn_run').outputs) { a ->
  135. if (official) {
  136. project(':private:branding').fileTree('src').visit { b ->
  137. if (!b.isDirectory()) {
  138. a.exclude b.relativePath.toString()
  139. }
  140. }
  141. }
  142. }
  143. if (official) {
  144. from project(':private:branding').file('src')
  145. }
  146. }
  147. into("${archiveDir}/lib/jdbc/mssql/") {
  148. from configurations.jdbc_mssql
  149. }
  150. into("${archiveDir}/lib/jdbc/postgresql/") {
  151. from configurations.jdbc_postgresql
  152. }
  153. into("${archiveDir}/lib/jdbc/h2/") {
  154. from configurations.jdbc_h2
  155. }
  156. into("${archiveDir}/lib/") {
  157. from configurations.shutdowner
  158. }
  159. }
  160. // Create the empty dir required by elasticsearch
  161. zip.doFirst {
  162. new File(buildDir, 'elasticsearch/plugins').mkdirs()
  163. }
  164. // Check the size of the archive
  165. zip.doLast {
  166. def minLength = 220000000
  167. def maxLength = 230000000
  168. def length = archiveFile.get().asFile.length()
  169. if (length < minLength)
  170. throw new GradleException("$archiveName size ($length) too small. Min is $minLength")
  171. if (length > maxLength)
  172. throw new GradleException("$distsDir/$archiveName size ($length) too large. Max is $maxLength")
  173. }
  174. assemble.dependsOn zip
  175. // the script start.sh unpacks OSS distribution into $buildDir/distributions/sonarqube-oss.
  176. // This directory should be deleted when the zip is changed.
  177. task cleanLocalUnzippedDir(dependsOn: zip) {
  178. def unzippedDir = file("$buildDir/distributions/sonarqube-$version")
  179. inputs.files(file("$buildDir/distributions/sonar-application-${version}.zip"))
  180. outputs.upToDateWhen { true }
  181. doLast {
  182. println("delete directory ${unzippedDir}")
  183. project.delete(unzippedDir)
  184. }
  185. }
  186. assemble.dependsOn cleanLocalUnzippedDir
  187. artifacts { zip zip }
  188. artifactoryPublish.skip = false
  189. publishing {
  190. publications {
  191. mavenJava(MavenPublication) {
  192. artifact zip
  193. }
  194. }
  195. }