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

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