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

6 years ago
6 years ago
6 years ago
6 years ago
SONAR-12686 upgrade es client to 7.9.3 and move to HTTP - add should minimum match eq 1 to user index queries ES 7.X changed behaviour in case filter query with bool it defaults to '0' https://www.elastic.co/guide/en/elasticsearch/reference/7.x/breaking-changes-7.0.html#_the_filter_context_has_been_removed - fix issue index routing param ES 7.X helped discover this bug as new setting has been auto configured which is 'index.number_of_routing_shards'. This has changed how documents are distributed across shards depending on how many shards the index has. Without that change issues docs has been incorrectly routed to the same shard hash as projects and it worked no matter what routing key you used projectUuid or auth_projectUuid. - update ngram and edge_ngram names to match with es 7.x nGram and edgeNgram has been deprecated in favour of ngram and edge_ngram https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#deprecated-ngram-edgengram-token-filter-cannot-be-used - remove `_all : enabled` usage from UT This field was already deprecated in 6.X, now it has been removed. https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#all-meta-field-removed - add Elasticsearch High Level REST client dependency - use sonar.search.port for ES HTTP - main process use ES Rest client to check ES status - sonar.cluster.search.hosts has HTTP ports on APP nodes also sonar.search.port and sonar.search.host MUST be configured on each Search node with the host and HTTP port of the current node - use Elasticsearch high level rest client - use in EsTester - use as primary es client - use indices api to get all indices name instead of cluster api - use cluster health api to check cluster state - support raw requests for 'nodes/_stats' and '_cluster/stats' - support raw requests for 'indices/_stats' - leave netty4plugin as testCompile dependency it is used in UTs - all ES non-test calls go through EsClient class - add rest client ES profiling
4 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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/repository-encrypted/**'
  92. exclude 'elasticsearch/modules/search-business-rules/**'
  93. exclude 'elasticsearch/modules/searchable-snapshots/**'
  94. exclude 'elasticsearch/modules/snapshot-repo-test-kit/**'
  95. exclude 'elasticsearch/modules/spatial/**'
  96. exclude 'elasticsearch/modules/transform/**'
  97. exclude 'elasticsearch/modules/unsigned-long/**'
  98. exclude 'elasticsearch/modules/vectors/**'
  99. exclude 'elasticsearch/modules/wildcard/**'
  100. exclude 'elasticsearch/modules/x-pack-*/**'
  101. }
  102. into("${archiveDir}/conf/") {
  103. from file('src/main/assembly/conf/sonar.properties')
  104. filter(ReplaceTokens, tokens: [
  105. 'searchDefaultHeapSize': '512MB',
  106. 'searchJavaOpts' : '-Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError',
  107. 'ceDefaultHeapSize' : '512MB',
  108. 'ceJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError',
  109. 'webDefaultHeapSize' : '512MB',
  110. 'webJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError'
  111. ])
  112. }
  113. into("${archiveDir}/conf/") {
  114. from file('src/main/assembly/conf/wrapper.conf')
  115. filter(ReplaceTokens, tokens: [
  116. 'sqversion': version
  117. ])
  118. }
  119. into("${archiveDir}/elasticsearch/") {
  120. from file('src/main/assembly/elasticsearch-patch')
  121. include 'bin/elasticsearch'
  122. }
  123. // Create the empty dir (plugins) required by elasticsearch
  124. into("${archiveDir}/elasticsearch/") {
  125. from "$buildDir/elasticsearch"
  126. }
  127. into("${archiveDir}/lib/extensions/") {
  128. from configurations.bundledPlugin
  129. }
  130. into("${archiveDir}/lib/jsw/") {
  131. from configurations.jsw
  132. }
  133. into("${archiveDir}/lib/scanner/") {
  134. from configurations.scanner
  135. }
  136. into("${archiveDir}/lib/") {
  137. from shadowJar
  138. }
  139. into("${archiveDir}/web/") {
  140. duplicatesStrategy DuplicatesStrategy.FAIL
  141. // FIXME use configurations.web with correct artifacts
  142. from(tasks.getByPath(':server:sonar-web:yarn_run').outputs) { a ->
  143. if (official) {
  144. project(':private:branding').fileTree('src').visit { b ->
  145. if (!b.isDirectory()) {
  146. a.exclude b.relativePath.toString()
  147. }
  148. }
  149. }
  150. }
  151. if (official) {
  152. from project(':private:branding').file('src')
  153. }
  154. }
  155. into("${archiveDir}/lib/jdbc/mssql/") {
  156. from configurations.jdbc_mssql
  157. }
  158. into("${archiveDir}/lib/jdbc/postgresql/") {
  159. from configurations.jdbc_postgresql
  160. }
  161. into("${archiveDir}/lib/jdbc/h2/") {
  162. from configurations.jdbc_h2
  163. }
  164. into("${archiveDir}/lib/") {
  165. from configurations.shutdowner
  166. }
  167. }
  168. // Create the empty dir required by elasticsearch
  169. zip.doFirst {
  170. new File(buildDir, 'elasticsearch/plugins').mkdirs()
  171. }
  172. // Check the size of the archive
  173. zip.doLast {
  174. def minLength = 270000000
  175. def maxLength = 290000000
  176. def length = archiveFile.get().asFile.length()
  177. if (length < minLength)
  178. throw new GradleException("$archiveName size ($length) too small. Min is $minLength")
  179. if (length > maxLength)
  180. throw new GradleException("$distsDir/$archiveName size ($length) too large. Max is $maxLength")
  181. }
  182. assemble.dependsOn zip
  183. // the script start.sh unpacks OSS distribution into $buildDir/distributions/sonarqube-oss.
  184. // This directory should be deleted when the zip is changed.
  185. task cleanLocalUnzippedDir(dependsOn: zip) {
  186. def unzippedDir = file("$buildDir/distributions/sonarqube-$version")
  187. inputs.files(file("$buildDir/distributions/sonar-application-${version}.zip"))
  188. outputs.upToDateWhen { true }
  189. doLast {
  190. println("delete directory ${unzippedDir}")
  191. project.delete(unzippedDir)
  192. }
  193. }
  194. assemble.dependsOn cleanLocalUnzippedDir
  195. artifacts { zip zip }
  196. artifactoryPublish.skip = false
  197. publishing {
  198. publications {
  199. mavenJava(MavenPublication) {
  200. artifact zip
  201. }
  202. }
  203. }