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

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