您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

build.gradle 8.3KB

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