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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. ext {
  27. slangVersion = '1.5.0.315'
  28. dotnetVersion = '7.15.0.8572'
  29. }
  30. dependencies {
  31. // please keep list ordered
  32. compile 'org.slf4j:slf4j-api'
  33. compile 'org.elasticsearch.client:transport'
  34. compile project(':server:sonar-ce')
  35. compile project(':server:sonar-main')
  36. compile project(':server:sonar-process')
  37. compile project(':server:sonar-server')
  38. compile project(':sonar-core')
  39. compile project(path: ':sonar-plugin-api', configuration: 'shadow')
  40. compile project(':sonar-plugin-api-impl')
  41. compileOnly 'com.google.code.findbugs:jsr305'
  42. jsw 'tanukisoft:wrapper:3.2.3'
  43. scanner project(path: ':sonar-scanner-engine-shaded', configuration: 'shadow')
  44. web project(':server:sonar-vsts')
  45. web project(':server:sonar-web')
  46. shutdowner project(':sonar-shutdowner')
  47. jdbc_h2 'com.h2database:h2'
  48. jdbc_mssql 'com.microsoft.sqlserver:mssql-jdbc'
  49. jdbc_postgresql 'org.postgresql:postgresql'
  50. bundledPlugin 'org.sonarsource.auth.github:sonar-auth-github-plugin:1.5.0.870@jar'
  51. bundledPlugin 'org.sonarsource.auth.saml:sonar-auth-saml-plugin:1.1.0.181@jar'
  52. bundledPlugin 'org.sonarsource.css:sonar-css-plugin:1.1.1.1010@jar'
  53. bundledPlugin "org.sonarsource.dotnet:sonar-csharp-plugin:${dotnetVersion}@jar"
  54. bundledPlugin "org.sonarsource.dotnet:sonar-vbnet-plugin:${dotnetVersion}@jar"
  55. bundledPlugin 'org.sonarsource.flex:sonar-flex-plugin:2.5.1.1831@jar'
  56. bundledPlugin 'org.sonarsource.go:sonar-go-plugin:1.1.1.2000@jar'
  57. bundledPlugin 'org.sonarsource.html:sonar-html-plugin:3.1.0.1615@jar'
  58. bundledPlugin 'org.sonarsource.java:sonar-java-plugin:5.13.1.18282@jar'
  59. bundledPlugin 'org.sonarsource.jacoco:sonar-jacoco-plugin:1.0.2.475@jar'
  60. bundledPlugin 'org.sonarsource.javascript:sonar-javascript-plugin:5.2.1.7778@jar'
  61. bundledPlugin 'org.sonarsource.ldap:sonar-ldap-plugin:2.2.0.608@jar'
  62. bundledPlugin 'org.sonarsource.php:sonar-php-plugin:3.2.0.4868@jar'
  63. bundledPlugin 'org.sonarsource.python:sonar-python-plugin:1.14.1.3143@jar'
  64. bundledPlugin "org.sonarsource.slang:sonar-kotlin-plugin:${slangVersion}@jar"
  65. bundledPlugin "org.sonarsource.slang:sonar-ruby-plugin:${slangVersion}@jar"
  66. bundledPlugin 'org.sonarsource.scm.git:sonar-scm-git-plugin:1.8.0.1574@jar'
  67. bundledPlugin 'org.sonarsource.scm.svn:sonar-scm-svn-plugin:1.9.0.1295@jar'
  68. bundledPlugin "org.sonarsource.slang:sonar-scala-plugin:${slangVersion}@jar"
  69. bundledPlugin 'org.sonarsource.typescript:sonar-typescript-plugin:1.9.0.3766@jar'
  70. bundledPlugin 'org.sonarsource.xml:sonar-xml-plugin:2.0.1.2020@jar'
  71. }
  72. jar {
  73. manifest {
  74. attributes(
  75. 'Class-Path': configurations.compile.resolvedConfiguration.files.collect { "common/${it.getName()}" }.join(' '),
  76. 'Main-Class': 'org.sonar.application.App'
  77. )
  78. }
  79. }
  80. task zip(type: Zip, dependsOn: [configurations.compile]) {
  81. duplicatesStrategy DuplicatesStrategy.EXCLUDE
  82. def archiveDir = "sonarqube-$version"
  83. into("${archiveDir}/") {
  84. from file('src/main/assembly')
  85. exclude 'conf/sonar.properties'
  86. exclude 'elasticsearch-patch'
  87. // elasticsearch script will be replaced by patched version below
  88. exclude 'elasticsearch/bin/elasticsearch'
  89. exclude 'elasticsearch/bin/elasticsearch.bat'
  90. exclude 'elasticsearch/bin/elasticsearch-env.bat'
  91. exclude 'elasticsearch/bin/elasticsearch-service.bat'
  92. exclude 'elasticsearch/bin/elasticsearch-service-*.exe'
  93. exclude 'elasticsearch/bin/elasticsearch-certgen*'
  94. exclude 'elasticsearch/bin/elasticsearch-certutil*'
  95. exclude 'elasticsearch/bin/elasticsearch-cli*'
  96. exclude 'elasticsearch/bin/elasticsearch-croneval*'
  97. exclude 'elasticsearch/bin/elasticsearch-keystore*'
  98. exclude 'elasticsearch/bin/elasticsearch-migrate*'
  99. exclude 'elasticsearch/bin/elasticsearch-plugin*'
  100. exclude 'elasticsearch/bin/elasticsearch-saml-metadata*'
  101. exclude 'elasticsearch/bin/elasticsearch-setup-passwords*'
  102. exclude 'elasticsearch/bin/elasticsearch-shard*'
  103. exclude 'elasticsearch/bin/elasticsearch-sql-cli*'
  104. exclude 'elasticsearch/bin/elasticsearch-syskeygen*'
  105. exclude 'elasticsearch/bin/elasticsearch-translog*'
  106. exclude 'elasticsearch/bin/elasticsearch-users*'
  107. exclude 'elasticsearch/bin/x-pack/**'
  108. exclude 'elasticsearch/bin/x-pack*'
  109. exclude 'elasticsearch/lib/tools/**'
  110. exclude 'elasticsearch/modules/aggs-matrix-stats/**'
  111. exclude 'elasticsearch/modules/ingest-common/**'
  112. exclude 'elasticsearch/modules/ingest-geoip/**'
  113. exclude 'elasticsearch/modules/ingest-user-agent/**'
  114. exclude 'elasticsearch/modules/lang-expression/**'
  115. exclude 'elasticsearch/modules/lang-groovy/**'
  116. exclude 'elasticsearch/modules/lang-mustache/**'
  117. exclude 'elasticsearch/modules/rank-eval/**'
  118. exclude 'elasticsearch/modules/tribe/**'
  119. exclude 'elasticsearch/modules/x-pack-*/**'
  120. }
  121. into("${archiveDir}/conf/") {
  122. from file('src/main/assembly/conf/sonar.properties')
  123. filter(ReplaceTokens, tokens: [
  124. 'searchDefaultHeapSize': '512MB',
  125. 'searchJavaOpts' : '-Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError',
  126. 'ceDefaultHeapSize' : '512MB',
  127. 'ceJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError',
  128. 'webDefaultHeapSize' : '512MB',
  129. 'webJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError'
  130. ])
  131. }
  132. into("${archiveDir}/elasticsearch/") {
  133. from file('src/main/assembly/elasticsearch-patch')
  134. include 'bin/elasticsearch'
  135. }
  136. // Create the empty dir (plugins) required by elasticsearch
  137. into("${archiveDir}/elasticsearch/") {
  138. from "$buildDir/elasticsearch"
  139. }
  140. into("${archiveDir}/lib/") {
  141. from jar
  142. }
  143. into("${archiveDir}/extensions/plugins/") {
  144. from configurations.bundledPlugin
  145. }
  146. into("${archiveDir}/lib/jsw/") {
  147. from configurations.jsw
  148. }
  149. into("${archiveDir}/lib/scanner/") {
  150. from configurations.scanner
  151. }
  152. into("${archiveDir}/lib/common/") {
  153. from configurations.compile
  154. }
  155. into("${archiveDir}/web/") {
  156. duplicatesStrategy DuplicatesStrategy.FAIL
  157. // FIXME use configurations.web with correct artifacts
  158. from(tasks.getByPath(':server:sonar-web:yarn_run').outputs) { a ->
  159. if (official) {
  160. project(':private:branding').fileTree('src').visit { b ->
  161. if (!b.isDirectory) {
  162. a.exclude b.relativePath.toString()
  163. }
  164. }
  165. }
  166. }
  167. from tasks.getByPath(':server:sonar-vsts:yarn_run').outputs
  168. if (official) {
  169. from project(':private:branding').file('src')
  170. }
  171. }
  172. into("${archiveDir}/lib/jdbc/mssql/") {
  173. from configurations.jdbc_mssql
  174. }
  175. into("${archiveDir}/lib/jdbc/postgresql/") {
  176. from configurations.jdbc_postgresql
  177. }
  178. into("${archiveDir}/lib/jdbc/h2/") {
  179. from configurations.jdbc_h2
  180. }
  181. into("${archiveDir}/lib/") {
  182. from configurations.shutdowner
  183. }
  184. }
  185. // Create the empty dir required by elasticsearch
  186. zip.doFirst {
  187. new File(buildDir, 'elasticsearch/plugins').mkdirs()
  188. }
  189. // Check the size of the archive
  190. zip.doLast {
  191. def minLength = 198000000
  192. def maxLength = 206000000
  193. def length = archiveFile.get().asFile.length()
  194. if (length < minLength)
  195. throw new GradleException("$archiveName size ($length) too small. Min is $minLength")
  196. if (length > maxLength)
  197. throw new GradleException("$distsDir/$archiveName size ($length) too large. Max is $maxLength")
  198. }
  199. assemble.dependsOn zip
  200. // the script start.sh unpacks OSS distribution into $buildDir/distributions/sonarqube-oss.
  201. // This directory should be deleted when the zip is changed.
  202. task cleanLocalUnzippedDir(dependsOn: zip) {
  203. def unzippedDir = file("$buildDir/distributions/sonarqube-$version")
  204. inputs.files(file("$buildDir/distributions/sonar-application-${version}.zip"))
  205. outputs.upToDateWhen { true }
  206. doLast {
  207. println("delete directory ${unzippedDir}")
  208. project.delete(unzippedDir)
  209. }
  210. }
  211. assemble.dependsOn cleanLocalUnzippedDir
  212. artifacts { zip zip }
  213. artifactoryPublish.skip = false
  214. publishing {
  215. publications {
  216. mavenJava(MavenPublication) {
  217. artifact zip
  218. }
  219. }
  220. }