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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. exclude 'elasticsearch/modules/constant-keyword/**'
  84. exclude 'elasticsearch/modules/flattened/**'
  85. exclude 'elasticsearch/modules/frozen-indices/**'
  86. exclude 'elasticsearch/modules/mapper-version/**'
  87. exclude 'elasticsearch/modules/repositories-metering-api/**'
  88. exclude 'elasticsearch/modules/search-business-rules/**'
  89. exclude 'elasticsearch/modules/searchable-snapshots/**'
  90. exclude 'elasticsearch/modules/spatial/**'
  91. exclude 'elasticsearch/modules/transform/**'
  92. exclude 'elasticsearch/modules/unsigned-long/**'
  93. exclude 'elasticsearch/modules/vectors/**'
  94. exclude 'elasticsearch/modules/wildcard/**'
  95. exclude 'elasticsearch/modules/x-pack-*/**'
  96. exclude 'elasticsearch/modules/x-pack-analytics/**'
  97. exclude 'elasticsearch/modules/x-pack-async/**'
  98. exclude 'elasticsearch/modules/x-pack-async-search/**'
  99. exclude 'elasticsearch/modules/x-pack-autoscaling/**'
  100. exclude 'elasticsearch/modules/x-pack-ccr/**'
  101. exclude 'elasticsearch/modules/x-pack-core/**'
  102. exclude 'elasticsearch/modules/x-pack-data-streams/**'
  103. exclude 'elasticsearch/modules/x-pack-deprecation/**'
  104. exclude 'elasticsearch/modules/x-pack-enrich/**'
  105. exclude 'elasticsearch/modules/x-pack-eql/**'
  106. exclude 'elasticsearch/modules/x-pack-fleet/**'
  107. exclude 'elasticsearch/modules/x-pack-graph/**'
  108. exclude 'elasticsearch/modules/x-pack-identity-provider/**'
  109. exclude 'elasticsearch/modules/x-pack-ilm/**'
  110. exclude 'elasticsearch/modules/x-pack-ingest/**'
  111. exclude 'elasticsearch/modules/x-pack-logstash/**'
  112. exclude 'elasticsearch/modules/x-pack-ml/**'
  113. exclude 'elasticsearch/modules/x-pack-monitoring/**'
  114. exclude 'elasticsearch/modules/x-pack-ql/**'
  115. exclude 'elasticsearch/modules/x-pack-rollup/**'
  116. exclude 'elasticsearch/modules/x-pack-runtime-fields/**'
  117. exclude 'elasticsearch/modules/x-pack-security/**'
  118. exclude 'elasticsearch/modules/x-pack-sql/**'
  119. exclude 'elasticsearch/modules/x-pack-stack/**'
  120. exclude 'elasticsearch/modules/x-pack-voting-only-node/**'
  121. exclude 'elasticsearch/modules/x-pack-watcher/**'
  122. }
  123. into("${archiveDir}/conf/") {
  124. from file('src/main/assembly/conf/sonar.properties')
  125. filter(ReplaceTokens, tokens: [
  126. 'searchDefaultHeapSize': '512MB',
  127. 'searchJavaOpts' : '-Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError',
  128. 'ceDefaultHeapSize' : '512MB',
  129. 'ceJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError',
  130. 'webDefaultHeapSize' : '512MB',
  131. 'webJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError'
  132. ])
  133. }
  134. into("${archiveDir}/elasticsearch/") {
  135. from file('src/main/assembly/elasticsearch-patch')
  136. include 'bin/elasticsearch'
  137. }
  138. // Create the empty dir (plugins) required by elasticsearch
  139. into("${archiveDir}/elasticsearch/") {
  140. from "$buildDir/elasticsearch"
  141. }
  142. into("${archiveDir}/lib/") {
  143. from jar
  144. }
  145. into("${archiveDir}/lib/extensions/") {
  146. from configurations.bundledPlugin
  147. }
  148. into("${archiveDir}/lib/jsw/") {
  149. from configurations.jsw
  150. }
  151. into("${archiveDir}/lib/scanner/") {
  152. from configurations.scanner
  153. }
  154. into("${archiveDir}/lib/common/") {
  155. from configurations.compile
  156. }
  157. into("${archiveDir}/web/") {
  158. duplicatesStrategy DuplicatesStrategy.FAIL
  159. // FIXME use configurations.web with correct artifacts
  160. from(tasks.getByPath(':server:sonar-web:yarn_run').outputs) { a ->
  161. if (official) {
  162. project(':private:branding').fileTree('src').visit { b ->
  163. if (!b.isDirectory()) {
  164. a.exclude b.relativePath.toString()
  165. }
  166. }
  167. }
  168. }
  169. if (official) {
  170. from project(':private:branding').file('src')
  171. }
  172. }
  173. into("${archiveDir}/lib/jdbc/mssql/") {
  174. from configurations.jdbc_mssql
  175. }
  176. into("${archiveDir}/lib/jdbc/postgresql/") {
  177. from configurations.jdbc_postgresql
  178. }
  179. into("${archiveDir}/lib/jdbc/h2/") {
  180. from configurations.jdbc_h2
  181. }
  182. into("${archiveDir}/lib/") {
  183. from configurations.shutdowner
  184. }
  185. }
  186. // Create the empty dir required by elasticsearch
  187. zip.doFirst {
  188. new File(buildDir, 'elasticsearch/plugins').mkdirs()
  189. }
  190. // Check the size of the archive
  191. zip.doLast {
  192. def minLength = 270000000
  193. def maxLength = 290000000
  194. def length = archiveFile.get().asFile.length()
  195. if (length < minLength)
  196. throw new GradleException("$archiveName size ($length) too small. Min is $minLength")
  197. if (length > maxLength)
  198. throw new GradleException("$distsDir/$archiveName size ($length) too large. Max is $maxLength")
  199. }
  200. assemble.dependsOn zip
  201. // the script start.sh unpacks OSS distribution into $buildDir/distributions/sonarqube-oss.
  202. // This directory should be deleted when the zip is changed.
  203. task cleanLocalUnzippedDir(dependsOn: zip) {
  204. def unzippedDir = file("$buildDir/distributions/sonarqube-$version")
  205. inputs.files(file("$buildDir/distributions/sonar-application-${version}.zip"))
  206. outputs.upToDateWhen { true }
  207. doLast {
  208. println("delete directory ${unzippedDir}")
  209. project.delete(unzippedDir)
  210. }
  211. }
  212. assemble.dependsOn cleanLocalUnzippedDir
  213. artifacts { zip zip }
  214. artifactoryPublish.skip = false
  215. publishing {
  216. publications {
  217. mavenJava(MavenPublication) {
  218. artifact zip
  219. }
  220. }
  221. }