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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. import org.apache.tools.ant.filters.ReplaceTokens
  2. apply plugin: 'com.github.johnrengelman.shadow'
  3. sonarqube {
  4. properties {
  5. property 'sonar.projectName', "${projectTitle} :: Application"
  6. }
  7. }
  8. configurations {
  9. zip
  10. jsw
  11. scanner
  12. web
  13. shutdowner
  14. jdbc_mssql {
  15. transitive = false
  16. }
  17. jdbc_postgresql {
  18. transitive = false
  19. }
  20. jdbc_h2 {
  21. transitive = false
  22. }
  23. bundledPlugin {
  24. transitive = false
  25. }
  26. }
  27. jar.enabled = false
  28. shadowJar {
  29. baseName = 'sonar-application'
  30. classifier = null
  31. mergeServiceFiles()
  32. manifest {
  33. attributes('Main-Class': 'org.sonar.application.App')
  34. }
  35. }
  36. dependencies {
  37. // please keep list ordered
  38. compile 'org.slf4j:slf4j-api'
  39. compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client'
  40. compile project(':server:sonar-ce')
  41. compile project(':server:sonar-main')
  42. compile project(':server:sonar-process')
  43. compile project(':server:sonar-webserver')
  44. compile project(':sonar-core')
  45. compile project(path: ':sonar-plugin-api', configuration: 'shadow')
  46. compile project(':sonar-plugin-api-impl')
  47. compileOnly 'com.google.code.findbugs:jsr305'
  48. jsw 'tanukisoft:wrapper:3.2.3'
  49. scanner project(path: ':sonar-scanner-engine-shaded', configuration: 'shadow')
  50. web project(':server:sonar-web')
  51. shutdowner project(':sonar-shutdowner')
  52. jdbc_h2 'com.h2database:h2'
  53. jdbc_mssql 'com.microsoft.sqlserver:mssql-jdbc'
  54. jdbc_postgresql 'org.postgresql:postgresql'
  55. }
  56. // declare dependencies in configuration bundledPlugin to be packaged in lib/extensions
  57. apply from: 'bundled_plugins.gradle'
  58. task zip(type: Zip, dependsOn: [configurations.compile]) {
  59. duplicatesStrategy DuplicatesStrategy.EXCLUDE
  60. def archiveDir = "sonarqube-$version"
  61. into("${archiveDir}/") {
  62. from file('src/main/assembly')
  63. exclude 'conf/sonar.properties'
  64. exclude 'conf/wrapper.conf'
  65. exclude 'elasticsearch-patch'
  66. // elasticsearch script will be replaced by patched version below
  67. exclude 'elasticsearch/bin/elasticsearch'
  68. exclude 'elasticsearch/bin/elasticsearch-cli'
  69. exclude 'elasticsearch/bin/elasticsearch-keystore'
  70. exclude 'elasticsearch/bin/elasticsearch-node'
  71. exclude 'elasticsearch/bin/elasticsearch-shard'
  72. exclude 'elasticsearch/lib/tools/**'
  73. exclude 'elasticsearch/modules/aggs-matrix-stats/**'
  74. exclude 'elasticsearch/modules/geo/**'
  75. exclude 'elasticsearch/modules/ingest-common/**'
  76. exclude 'elasticsearch/modules/ingest-geoip/**'
  77. exclude 'elasticsearch/modules/ingest-user-agent/**'
  78. exclude 'elasticsearch/modules/kibana/**'
  79. exclude 'elasticsearch/modules/lang-expression/**'
  80. exclude 'elasticsearch/modules/lang-mustache/**'
  81. exclude 'elasticsearch/modules/mapper-extras/**'
  82. exclude 'elasticsearch/modules/rank-eval/**'
  83. exclude 'elasticsearch/modules/reindex/**'
  84. exclude 'elasticsearch/modules/repository-url/**'
  85. exclude 'elasticsearch/modules/tasks/**'
  86. exclude 'elasticsearch/modules/constant-keyword/**'
  87. exclude 'elasticsearch/modules/flattened/**'
  88. exclude 'elasticsearch/modules/frozen-indices/**'
  89. exclude 'elasticsearch/modules/mapper-version/**'
  90. exclude 'elasticsearch/modules/repositories-metering-api/**'
  91. exclude 'elasticsearch/modules/search-business-rules/**'
  92. exclude 'elasticsearch/modules/searchable-snapshots/**'
  93. exclude 'elasticsearch/modules/spatial/**'
  94. exclude 'elasticsearch/modules/transform/**'
  95. exclude 'elasticsearch/modules/unsigned-long/**'
  96. exclude 'elasticsearch/modules/vectors/**'
  97. exclude 'elasticsearch/modules/wildcard/**'
  98. exclude 'elasticsearch/modules/x-pack-*/**'
  99. exclude 'elasticsearch/modules/x-pack-analytics/**'
  100. exclude 'elasticsearch/modules/x-pack-async/**'
  101. exclude 'elasticsearch/modules/x-pack-async-search/**'
  102. exclude 'elasticsearch/modules/x-pack-autoscaling/**'
  103. exclude 'elasticsearch/modules/x-pack-ccr/**'
  104. exclude 'elasticsearch/modules/x-pack-core/**'
  105. exclude 'elasticsearch/modules/x-pack-data-streams/**'
  106. exclude 'elasticsearch/modules/x-pack-deprecation/**'
  107. exclude 'elasticsearch/modules/x-pack-enrich/**'
  108. exclude 'elasticsearch/modules/x-pack-eql/**'
  109. exclude 'elasticsearch/modules/x-pack-fleet/**'
  110. exclude 'elasticsearch/modules/x-pack-graph/**'
  111. exclude 'elasticsearch/modules/x-pack-identity-provider/**'
  112. exclude 'elasticsearch/modules/x-pack-ilm/**'
  113. exclude 'elasticsearch/modules/x-pack-ingest/**'
  114. exclude 'elasticsearch/modules/x-pack-logstash/**'
  115. exclude 'elasticsearch/modules/x-pack-ml/**'
  116. exclude 'elasticsearch/modules/x-pack-monitoring/**'
  117. exclude 'elasticsearch/modules/x-pack-ql/**'
  118. exclude 'elasticsearch/modules/x-pack-rollup/**'
  119. exclude 'elasticsearch/modules/x-pack-runtime-fields/**'
  120. exclude 'elasticsearch/modules/x-pack-security/**'
  121. exclude 'elasticsearch/modules/x-pack-sql/**'
  122. exclude 'elasticsearch/modules/x-pack-stack/**'
  123. exclude 'elasticsearch/modules/x-pack-voting-only-node/**'
  124. exclude 'elasticsearch/modules/x-pack-watcher/**'
  125. }
  126. into("${archiveDir}/conf/") {
  127. from file('src/main/assembly/conf/sonar.properties')
  128. filter(ReplaceTokens, tokens: [
  129. 'searchDefaultHeapSize': '512MB',
  130. 'searchJavaOpts' : '-Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError',
  131. 'ceDefaultHeapSize' : '512MB',
  132. 'ceJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError',
  133. 'webDefaultHeapSize' : '512MB',
  134. 'webJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError'
  135. ])
  136. }
  137. into("${archiveDir}/conf/") {
  138. from file('src/main/assembly/conf/wrapper.conf')
  139. filter(ReplaceTokens, tokens: [
  140. 'sqversion': version
  141. ])
  142. }
  143. into("${archiveDir}/elasticsearch/") {
  144. from file('src/main/assembly/elasticsearch-patch')
  145. include 'bin/elasticsearch'
  146. }
  147. // Create the empty dir (plugins) required by elasticsearch
  148. into("${archiveDir}/elasticsearch/") {
  149. from "$buildDir/elasticsearch"
  150. }
  151. into("${archiveDir}/lib/extensions/") {
  152. from configurations.bundledPlugin
  153. }
  154. into("${archiveDir}/lib/jsw/") {
  155. from configurations.jsw
  156. }
  157. into("${archiveDir}/lib/scanner/") {
  158. from configurations.scanner
  159. }
  160. into("${archiveDir}/lib/") {
  161. from shadowJar
  162. }
  163. into("${archiveDir}/web/") {
  164. duplicatesStrategy DuplicatesStrategy.FAIL
  165. // FIXME use configurations.web with correct artifacts
  166. from(tasks.getByPath(':server:sonar-web:yarn_run').outputs) { a ->
  167. if (official) {
  168. project(':private:branding').fileTree('src').visit { b ->
  169. if (!b.isDirectory()) {
  170. a.exclude b.relativePath.toString()
  171. }
  172. }
  173. }
  174. }
  175. if (official) {
  176. from project(':private:branding').file('src')
  177. }
  178. }
  179. into("${archiveDir}/lib/jdbc/mssql/") {
  180. from configurations.jdbc_mssql
  181. }
  182. into("${archiveDir}/lib/jdbc/postgresql/") {
  183. from configurations.jdbc_postgresql
  184. }
  185. into("${archiveDir}/lib/jdbc/h2/") {
  186. from configurations.jdbc_h2
  187. }
  188. into("${archiveDir}/lib/") {
  189. from configurations.shutdowner
  190. }
  191. }
  192. // Create the empty dir required by elasticsearch
  193. zip.doFirst {
  194. new File(buildDir, 'elasticsearch/plugins').mkdirs()
  195. }
  196. // Check the size of the archive
  197. zip.doLast {
  198. def minLength = 270000000
  199. def maxLength = 290000000
  200. def length = archiveFile.get().asFile.length()
  201. if (length < minLength)
  202. throw new GradleException("$archiveName size ($length) too small. Min is $minLength")
  203. if (length > maxLength)
  204. throw new GradleException("$distsDir/$archiveName size ($length) too large. Max is $maxLength")
  205. }
  206. assemble.dependsOn zip
  207. // the script start.sh unpacks OSS distribution into $buildDir/distributions/sonarqube-oss.
  208. // This directory should be deleted when the zip is changed.
  209. task cleanLocalUnzippedDir(dependsOn: zip) {
  210. def unzippedDir = file("$buildDir/distributions/sonarqube-$version")
  211. inputs.files(file("$buildDir/distributions/sonar-application-${version}.zip"))
  212. outputs.upToDateWhen { true }
  213. doLast {
  214. println("delete directory ${unzippedDir}")
  215. project.delete(unzippedDir)
  216. }
  217. }
  218. assemble.dependsOn cleanLocalUnzippedDir
  219. artifacts { zip zip }
  220. artifactoryPublish.skip = false
  221. publishing {
  222. publications {
  223. mavenJava(MavenPublication) {
  224. artifact zip
  225. }
  226. }
  227. }