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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. plugins {
  2. // Ordered alphabeticly
  3. id 'com.github.ben-manes.versions' version '0.28.0'
  4. id 'com.github.hierynomus.license' version '0.14.0'
  5. id 'com.github.johnrengelman.shadow' version '5.2.0' apply false
  6. id 'com.google.protobuf' version '0.8.12' apply false
  7. id 'com.jfrog.artifactory' version '4.15.1'
  8. id 'com.github.node-gradle.node' version '1.5.3' apply false
  9. id 'io.spring.dependency-management' version '1.0.9.RELEASE'
  10. id 'net.rdrei.android.buildtimetracker' version '0.11.0'
  11. id 'org.sonarqube' version '2.8'
  12. }
  13. // display a summary of task durations at the end of the build
  14. if (project.hasProperty('time-tracker')) {
  15. apply plugin: 'build-time-tracker'
  16. buildtimetracker {
  17. reporters {
  18. summary {
  19. ordered true
  20. threshold 1000
  21. barstyle 'ascii'
  22. }
  23. }
  24. }
  25. }
  26. if (!JavaVersion.current().java11Compatible) {
  27. throw new GradleException("JDK 11+ is required to perform this build. It's currently " + System.getProperty("java.home") + ".")
  28. }
  29. allprojects {
  30. apply plugin: 'com.jfrog.artifactory'
  31. apply plugin: 'maven-publish'
  32. ext.versionInSources = version
  33. ext.buildNumber = System.getProperty("buildNumber")
  34. // when no buildNumber is provided, then project version must end with '-SNAPSHOT'
  35. if (ext.buildNumber == null) {
  36. version = "${version}-SNAPSHOT".toString()
  37. ext.versionWithoutBuildNumber = version
  38. } else {
  39. ext.versionWithoutBuildNumber = version
  40. version = (version.toString().count('.') == 1 ? "${version}.0.${ext.buildNumber}" : "${version}.${ext.buildNumber}").toString()
  41. }
  42. ext {
  43. release = project.hasProperty('release') && project.getProperty('release')
  44. official = project.hasProperty('official') && project.getProperty('official')
  45. }
  46. repositories {
  47. def repository = project.hasProperty('qa') ? 'sonarsource-qa' : 'sonarsource'
  48. maven {
  49. url "https://repox.jfrog.io/repox/${repository}"
  50. // The environment variables ARTIFACTORY_PRIVATE_USERNAME and ARTIFACTORY_PRIVATE_PASSWORD are used on QA env (Jenkins)
  51. // On local box, please add artifactoryUsername and artifactoryPassword to ~/.gradle/gradle.properties
  52. def artifactoryUsername = System.env.'ARTIFACTORY_PRIVATE_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '')
  53. def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '')
  54. if (artifactoryUsername && artifactoryPassword) {
  55. credentials {
  56. username artifactoryUsername
  57. password artifactoryPassword
  58. }
  59. }
  60. }
  61. }
  62. task allDependencies {
  63. dependsOn 'dependencies'
  64. }
  65. }
  66. apply plugin: 'org.sonarqube'
  67. sonarqube {
  68. properties {
  69. property 'sonar.projectName', projectTitle
  70. property 'sonar.projectVersion', "${versionInSources}-SNAPSHOT"
  71. property 'sonar.buildString', version
  72. }
  73. }
  74. subprojects {
  75. apply plugin: 'com.github.hierynomus.license'
  76. apply plugin: 'io.spring.dependency-management'
  77. apply plugin: 'jacoco'
  78. apply plugin: 'java'
  79. apply plugin: 'idea'
  80. sourceCompatibility = 1.8
  81. targetCompatibility = 1.8
  82. // do not deploy to Artifactory by default
  83. artifactoryPublish.skip = true
  84. def testFixtureSrc = 'src/testFixtures'
  85. if (file(testFixtureSrc).exists()) {
  86. apply plugin: 'java-test-fixtures'
  87. }
  88. ext {
  89. protobufVersion = '3.11.4'
  90. }
  91. sonarqube {
  92. properties {
  93. property 'sonar.moduleKey', project.group + ':' + project.name
  94. }
  95. }
  96. // Central place for definition dependency versions and exclusions.
  97. dependencyManagement {
  98. dependencies {
  99. // bundled plugin list -- keep it alphabetically ordered
  100. // comment is used by the Plugin Update bot to identify bundled plugins to check updates for
  101. //
  102. // !!! do not use variable for version number, bot in charge of updating plugin does not support them !!
  103. //
  104. // comment format is: // bundled_plugin:[updateCenterKey]:[githubRepository]
  105. // updateCenterKey: Update Center Plugin key, last release will be resolved from repox when not provided
  106. // githubRepository: name of github repository of the plugin in the SonarSource organisation
  107. dependency 'com.sonarsource.abap:sonar-abap-plugin:3.8.0.2034' // bundled_plugin:abap:sonar-abap
  108. dependency 'com.sonarsource.cobol:sonar-cobol-plugin:4.4.0.3403' // bundled_plugin:cobol:sonar-cobol
  109. dependency 'com.sonarsource.cpp:sonar-cfamily-plugin:6.7.0.15300' // bundled_plugin:cpp:sonar-cpp
  110. dependency 'com.sonarsource.pli:sonar-pli-plugin:1.10.0.1880' // bundled_plugin:pli:sonar-pli
  111. dependency 'com.sonarsource.plsql:sonar-plsql-plugin:3.4.1.2576' // bundled_plugin:plsql:sonar-plsql
  112. dependency 'com.sonarsource.plugins.vb:sonar-vb-plugin:2.6.0.1875' // bundled_plugin:vb:sonar-vb
  113. dependency 'com.sonarsource.rpg:sonar-rpg-plugin:2.3.0.1187' // bundled_plugin:rpg:sonar-rpg
  114. dependency 'com.sonarsource.security:sonar-security-csharp-frontend-plugin:8.2.1.1259' // bundled_plugin::sonar-security
  115. dependency 'com.sonarsource.security:sonar-security-java-frontend-plugin:8.2.1.1259' // bundled_plugin::sonar-security
  116. dependency 'com.sonarsource.security:sonar-security-php-frontend-plugin:8.2.1.1259' // bundled_plugin::sonar-security
  117. dependency 'com.sonarsource.security:sonar-security-plugin:8.2.1.1259' // bundled_plugin::sonar-security
  118. dependency 'com.sonarsource.security:sonar-security-python-frontend-plugin:8.2.1.1259' // bundled_plugin::sonar-security
  119. dependency 'com.sonarsource.slang:sonar-apex-plugin:1.7.0.883' // bundled_plugin:sonarapex:slang-enterprise
  120. dependency 'com.sonarsource.swift:sonar-swift-plugin:4.2.2.77' // bundled_plugin:swift:sonar-swift
  121. dependency 'com.sonarsource.tsql:sonar-tsql-plugin:1.4.0.3334' // bundled_plugin:tsql:sonar-tsql
  122. dependency 'org.sonarsource.css:sonar-css-plugin:1.2.0.1325' // bundled_plugin:cssfamily:sonar-css
  123. dependency 'org.sonarsource.dotnet:sonar-csharp-plugin:8.5.0.15942' // bundled_plugin:csharp:sonar-dotnet
  124. dependency 'org.sonarsource.dotnet:sonar-vbnet-plugin:8.5.0.15942' // bundled_plugin:vbnet:sonar-dotnet
  125. dependency 'org.sonarsource.flex:sonar-flex-plugin:2.5.1.1831' // bundled_plugin:flex:sonar-flex
  126. dependency 'org.sonarsource.html:sonar-html-plugin:3.2.0.2082' // bundled_plugin:web:sonar-html
  127. dependency 'org.sonarsource.jacoco:sonar-jacoco-plugin:1.0.2.475' // bundled_plugin:jacoco:sonar-jacoco
  128. dependency 'org.sonarsource.java:sonar-java-plugin:6.2.0.21135' // bundled_plugin:java:sonar-java
  129. dependency 'org.sonarsource.javascript:sonar-javascript-plugin:6.2.0.12043' // bundled_plugin:javascript:SonarJS
  130. dependency 'org.sonarsource.php:sonar-php-plugin:3.3.0.5166' // bundled_plugin:php:sonar-php
  131. dependency 'org.sonarsource.python:sonar-python-plugin:2.7.0.5975' // bundled_plugin:python:sonar-python
  132. dependency 'org.sonarsource.scm.git:sonar-scm-git-plugin:1.11.0.11' // bundled_plugin:scmgit:sonar-scm-git
  133. dependency 'org.sonarsource.scm.svn:sonar-scm-svn-plugin:1.9.0.1295' // bundled_plugin:scmsvn:sonar-scm-svn
  134. dependency 'org.sonarsource.slang:sonar-go-plugin:1.6.0.719' // bundled_plugin:go:slang-enterprise
  135. dependency 'org.sonarsource.slang:sonar-kotlin-plugin:1.5.0.315' // bundled_plugin:kotlin:slang-enterprise
  136. dependency 'org.sonarsource.slang:sonar-ruby-plugin:1.5.0.315' // bundled_plugin:ruby:slang-enterprise
  137. dependency 'org.sonarsource.slang:sonar-scala-plugin:1.5.0.315' // bundled_plugin:sonarscala:slang-enterprise
  138. dependency 'org.sonarsource.typescript:sonar-typescript-plugin:2.1.0.4359' // bundled_plugin:typescript:SonarTS
  139. dependency 'org.sonarsource.xml:sonar-xml-plugin:2.0.1.2020' // bundled_plugin:xml:sonar-xml
  140. // please keep this list alphabetically ordered
  141. dependencySet(group: 'ch.qos.logback', version: '1.2.3') {
  142. entry 'logback-access'
  143. entry 'logback-classic'
  144. entry 'logback-core'
  145. }
  146. dependency('commons-beanutils:commons-beanutils:1.8.3') {
  147. exclude 'commons-logging:commons-logging'
  148. }
  149. dependency 'commons-codec:commons-codec:1.14'
  150. dependency 'commons-dbutils:commons-dbutils:1.7'
  151. dependency 'commons-io:commons-io:2.6'
  152. dependency 'commons-lang:commons-lang:2.6'
  153. dependencySet(group: 'com.fasterxml.jackson.core', version: '2.10.3') {
  154. entry 'jackson-core'
  155. entry 'jackson-annotations'
  156. entry 'jackson-databind'
  157. }
  158. dependency 'com.eclipsesource.minimal-json:minimal-json:0.9.5'
  159. dependencySet(group: 'com.github.scribejava', version: '6.9.0') {
  160. entry 'scribejava-apis'
  161. entry 'scribejava-core'
  162. }
  163. // This project is no longer maintained and was forked
  164. // by https://github.com/java-diff-utils/java-diff-utils
  165. // (io.github.java-diff-utils:java-diff-utils).
  166. dependency 'com.googlecode.java-diff-utils:diffutils:1.2'
  167. dependency('com.googlecode.json-simple:json-simple:1.1.1') {
  168. exclude 'junit:junit'
  169. }
  170. dependency 'com.google.code.findbugs:jsr305:3.0.2'
  171. dependency 'com.google.code.gson:gson:2.8.6'
  172. dependency('com.google.guava:guava:28.2-jre') {
  173. exclude 'com.google.errorprone:error_prone_annotations'
  174. exclude 'com.google.guava:listenablefuture'
  175. exclude 'com.google.j2objc:j2objc-annotations'
  176. exclude 'org.checkerframework:checker-qual'
  177. exclude 'org.codehaus.mojo:animal-sniffer-annotations'
  178. }
  179. dependency "com.google.protobuf:protobuf-java:${protobufVersion}"
  180. // Do not upgrade H2 to 1.4.200 because of instability: https://github.com/h2database/h2database/issues/2205
  181. dependency 'com.h2database:h2:1.4.199'
  182. dependencySet(group: 'com.hazelcast', version: '3.12.6') {
  183. entry 'hazelcast'
  184. entry 'hazelcast-client'
  185. }
  186. dependency 'com.ibm.icu:icu4j:3.4.4'
  187. dependency 'com.microsoft.sqlserver:mssql-jdbc:7.4.1.jre11'
  188. dependency 'com.oracle.database.jdbc:ojdbc8:19.3.0.0'
  189. dependencySet(group: 'com.squareup.okhttp3', version: '3.14.7') {
  190. entry 'okhttp'
  191. entry 'mockwebserver'
  192. }
  193. dependency 'com.tngtech.java:junit-dataprovider:1.13.1'
  194. dependency 'info.picocli:picocli:3.6.1'
  195. dependencySet(group: 'io.jsonwebtoken', version: '0.11.1') {
  196. entry 'jjwt-api'
  197. entry 'jjwt-impl'
  198. entry 'jjwt-jackson'
  199. }
  200. dependency 'io.netty:netty-all:4.1.48.Final'
  201. dependency 'com.sun.mail:javax.mail:1.5.6'
  202. dependency 'javax.annotation:javax.annotation-api:1.3.2'
  203. dependency 'javax.servlet:javax.servlet-api:3.1.0'
  204. dependency 'javax.xml.bind:jaxb-api:2.3.0'
  205. dependency 'junit:junit:4.13'
  206. dependency 'org.junit.jupiter:junit-jupiter-api:5.6.0'
  207. dependency 'net.jpountz.lz4:lz4:1.3.0'
  208. dependency 'net.lightbody.bmp:littleproxy:1.1.0-beta-bmp-17'
  209. dependency 'org.awaitility:awaitility:4.0.2'
  210. dependency 'org.apache.commons:commons-csv:1.7'
  211. dependency 'org.apache.commons:commons-email:1.5'
  212. dependency 'org.apache.commons:commons-dbcp2:2.7.0'
  213. dependency('org.apache.httpcomponents:httpclient:4.5.12'){
  214. exclude 'commons-logging:commons-logging'
  215. }
  216. // Be aware that Log4j is used by Elasticsearch client
  217. dependencySet(group: 'org.apache.logging.log4j', version: '2.8.2') {
  218. entry 'log4j-api'
  219. entry 'log4j-to-slf4j'
  220. entry 'log4j-core'
  221. }
  222. dependencySet(group: 'org.apache.tomcat.embed', version: '8.5.53') {
  223. entry 'tomcat-embed-core'
  224. entry('tomcat-embed-jasper') {
  225. exclude 'org.eclipse.jdt.core.compiler:ecj'
  226. }
  227. }
  228. dependency 'org.assertj:assertj-core:3.15.0'
  229. dependency 'org.assertj:assertj-guava:3.3.0'
  230. dependency('org.codehaus.sonar:sonar-channel:4.2') {
  231. exclude 'org.slf4j:slf4j-api'
  232. }
  233. dependency 'org.codehaus.sonar:sonar-classloader:1.0'
  234. dependency('org.codehaus.woodstox:woodstox-core-lgpl:4.4.1') {
  235. exclude 'javax.xml.stream:stax-api'
  236. }
  237. dependency 'org.codehaus.sonar.runner:sonar-runner-api:2.4'
  238. dependency('org.codehaus.sonar:sonar-squid:4.1') {
  239. exclude 'org.codehaus.sonar:sonar-check-api'
  240. }
  241. dependency('org.codehaus.staxmate:staxmate:2.0.1') {
  242. exclude 'org.codehaus.woodstox:stax2-api'
  243. exclude 'stax:stax-api'
  244. exclude 'org.codehaus.woodstox:woodstox-core-asl'
  245. }
  246. dependency('org.codehaus.woodstox:stax2-api:3.1.4') {
  247. exclude 'stax:stax-api'
  248. }
  249. dependencySet(group: 'org.eclipse.jetty', version: '9.4.6.v20170531') {
  250. entry 'jetty-proxy'
  251. entry 'jetty-server'
  252. entry 'jetty-servlet'
  253. }
  254. dependency('org.elasticsearch.client:transport:6.8.4') {
  255. exclude 'org.elasticsearch.plugin:lang-mustache-client'
  256. exclude 'commons-logging:commons-logging'
  257. exclude 'org.elasticsearch.plugin:reindex-client'
  258. exclude 'org.elasticsearch.plugin:rank-eval-client'
  259. }
  260. dependency 'org.elasticsearch:mocksocket:1.0'
  261. dependency 'org.codelibs.elasticsearch.module:analysis-common:6.8.4'
  262. dependency 'org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r'
  263. dependency 'org.hamcrest:hamcrest-all:1.3'
  264. dependency 'org.jsoup:jsoup:1.13.1'
  265. dependency 'org.mindrot:jbcrypt:0.4'
  266. dependency('org.mockito:mockito-core:3.3.3') {
  267. exclude 'org.hamcrest:hamcrest-core'
  268. }
  269. dependency 'org.mybatis:mybatis:3.5.4'
  270. dependency 'org.nanohttpd:nanohttpd:2.3.1'
  271. dependency 'org.picocontainer:picocontainer:2.15'
  272. dependencySet(group: 'org.slf4j', version: '1.7.30') {
  273. entry 'jcl-over-slf4j'
  274. entry 'jul-to-slf4j'
  275. entry 'log4j-over-slf4j'
  276. entry 'slf4j-api'
  277. }
  278. dependency 'org.postgresql:postgresql:42.2.11'
  279. dependency 'org.reflections:reflections:0.9.12'
  280. dependency 'org.simpleframework:simple:4.1.21'
  281. dependency 'org.sonarsource.orchestrator:sonar-orchestrator:3.27.0.2172'
  282. dependency 'org.sonarsource.update-center:sonar-update-center-common:1.23.0.723'
  283. dependency 'org.subethamail:subethasmtp:3.1.7'
  284. dependency 'org.yaml:snakeyaml:1.26'
  285. dependency 'xml-apis:xml-apis:1.4.01'
  286. // please keep this list alphabetically ordered
  287. }
  288. }
  289. // global exclusions
  290. configurations.all {
  291. // do not conflict with com.sun.mail:javax.mail
  292. exclude group: 'javax.mail', module: 'mail'
  293. }
  294. tasks.withType(JavaCompile) {
  295. options.compilerArgs.addAll(['--release', '8'])
  296. options.encoding = 'UTF-8'
  297. }
  298. tasks.withType(Javadoc) {
  299. options.addStringOption('Xdoclint:none', '-quiet')
  300. options.encoding = 'UTF-8'
  301. title = project.name + ' ' + versionWithoutBuildNumber
  302. }
  303. task sourcesJar(type: Jar, dependsOn: classes) {
  304. classifier = 'sources'
  305. from sourceSets.main.allSource
  306. }
  307. task javadocJar(type: Jar, dependsOn: javadoc) {
  308. classifier = 'javadoc'
  309. from javadoc.destinationDir
  310. }
  311. // generate code before opening project in IDE (Eclipse or Intellij)
  312. task ide() {
  313. // empty by default. Dependencies are added to the task
  314. // when needed (see protobuf modules for example)
  315. }
  316. jacocoTestReport {
  317. reports {
  318. xml.enabled true
  319. csv.enabled false
  320. html.enabled false
  321. }
  322. }
  323. normalization {
  324. runtimeClasspath {
  325. // Following classpath resources contain volatile data that changes in each CI build (build number, commit id, time),
  326. // so we exclude them from calculation of build cache key of test tasks:
  327. ignore 'META-INF/MANIFEST.MF'
  328. ignore 'sonar-api-version.txt'
  329. ignore 'sq-version.txt'
  330. }
  331. }
  332. test {
  333. jvmArgs '-Dfile.encoding=UTF8'
  334. maxHeapSize = '1G'
  335. systemProperty 'java.awt.headless', true
  336. testLogging {
  337. events "skipped", "failed" // verbose log for failed and skipped tests (by default the name of the tests are not logged)
  338. exceptionFormat 'full' // log the full stack trace (default is the 1st line of the stack trace)
  339. }
  340. jacoco {
  341. enabled = true // do not disable recording of code coverage, so that remote Gradle cache entry can be used locally
  342. includes = ['com.sonar.*', 'com.sonarsource.*', 'org.sonar.*', 'org.sonarqube.*', 'org.sonarsource.*']
  343. }
  344. if (project.hasProperty('maxParallelTests')) {
  345. maxParallelForks = project.maxParallelTests as int
  346. }
  347. if (project.hasProperty('parallelTests')) {
  348. // See https://guides.gradle.org/performance/#parallel_test_execution
  349. maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
  350. }
  351. }
  352. def protoMainSrc = 'src/main/protobuf'
  353. def protoTestSrc = 'src/test/protobuf'
  354. if (file(protoMainSrc).exists() || file(protoTestSrc).exists()) {
  355. // protobuf must be applied after java
  356. apply plugin: 'com.google.protobuf'
  357. sourceSets.main.proto.srcDir protoMainSrc // in addition to the default 'src/main/proto'
  358. sourceSets.test.proto.srcDir protoTestSrc // in addition to the default 'src/test/proto'
  359. protobuf {
  360. protoc {
  361. artifact = "com.google.protobuf:protoc:${protobufVersion}"
  362. }
  363. }
  364. jar {
  365. exclude('**/*.proto')
  366. }
  367. idea {
  368. module {
  369. sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  370. testSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  371. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  372. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  373. }
  374. }
  375. ide.dependsOn(['generateProto', 'generateTestProto'])
  376. }
  377. if (file('package.json').exists()) {
  378. apply plugin: 'com.github.node-gradle.node'
  379. node {
  380. version = '10.15.3'
  381. yarnVersion = '1.22.0'
  382. download = true
  383. }
  384. }
  385. if (official) {
  386. jar {
  387. // do not break incremental build on non official versions
  388. manifest {
  389. attributes(
  390. 'Version': "${version}",
  391. 'Implementation-Build': System.getenv('GIT_SHA1'),
  392. 'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  393. )
  394. }
  395. }
  396. }
  397. license {
  398. header = rootProject.file('HEADER')
  399. strictCheck true
  400. mapping {
  401. java = 'SLASHSTAR_STYLE'
  402. js = 'SLASHSTAR_STYLE'
  403. ts = 'SLASHSTAR_STYLE'
  404. tsx = 'SLASHSTAR_STYLE'
  405. css = 'SLASHSTAR_STYLE'
  406. }
  407. includes(['**/*.java', '**/*.js', '**/*.ts', '**/*.tsx', '**/*.css'])
  408. }
  409. publishing {
  410. publications {
  411. mavenJava(MavenPublication) {
  412. pom {
  413. name = 'SonarQube'
  414. description = project.description
  415. url = 'http://www.sonarqube.org/'
  416. organization {
  417. name = 'SonarSource'
  418. url = 'http://www.sonarsource.com'
  419. }
  420. licenses {
  421. license {
  422. name = 'GNU LGPL 3'
  423. url = 'http://www.gnu.org/licenses/lgpl.txt'
  424. distribution = 'repo'
  425. }
  426. }
  427. scm {
  428. url = 'https://github.com/SonarSource/sonarqube'
  429. }
  430. developers {
  431. developer {
  432. id = 'sonarsource-team'
  433. name = 'SonarSource Team'
  434. }
  435. }
  436. }
  437. }
  438. }
  439. }
  440. }
  441. // Yarn doesn't support concurrent access to its global cache,
  442. // i.e. parallel execution of several "yarn install" tasks,
  443. // since these tasks are independent, we can establish arbitrary total order
  444. // to prevent their concurrent execution.
  445. // Note that "task1.mustRunAfter(task2)" ordering has an effect only when both
  446. // tasks are scheduled for execution, therefore should be established between
  447. // all pairs of "yarn install" tasks to define their total order and to prevent
  448. // their concurrent execution even in case when one or more of these tasks not
  449. // scheduled.
  450. def yarnInstallTasks = allprojects.findResults { it -> it.tasks.findByName('yarn') }
  451. yarnInstallTasks.drop(1).eachWithIndex { it, i -> it.mustRunAfter(yarnInstallTasks[0..i]) }
  452. // by default, Yarn will update lock file if it is not up to date with "package.json"
  453. // using option "--frozen-lockfile" will disable this behavior and "yarn install" will fail if lock file is out of date
  454. // all "yarn install" tasks should be executed with this option for reproducibility of builds
  455. // and to prevent developers from forgetting to update lock file when they update "package.json"
  456. yarnInstallTasks.each { it -> it.args = ['--frozen-lockfile'] }
  457. artifactory {
  458. clientConfig.setIncludeEnvVars(true)
  459. clientConfig.setEnvVarsExcludePatterns('*password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*TOKEN*,*LOGIN*,*login*,*key*,*KEY*')
  460. contextUrl = System.getenv('ARTIFACTORY_URL')
  461. publish {
  462. repository {
  463. repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO')
  464. username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME') ?: project.properties.artifactoryUsername
  465. password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD') ?: project.properties.artifactoryPaswword
  466. }
  467. defaults {
  468. properties = [
  469. 'build.name': 'sonar-enterprise',
  470. 'build.number': System.getenv('BUILD_NUMBER'),
  471. 'pr.branch.target': System.getenv('GITHUB_BASE_BRANCH'),
  472. 'pr.number': System.getenv('PULL_REQUEST'),
  473. 'vcs.branch': System.getenv('GITHUB_BRANCH'),
  474. 'vcs.revision': System.getenv('GIT_SHA1'),
  475. 'version': version
  476. ]
  477. publications('mavenJava')
  478. publishPom = true
  479. publishIvy = false
  480. }
  481. }
  482. clientConfig.info.setBuildName('sonar-enterprise')
  483. clientConfig.info.setBuildNumber(System.getenv('BUILD_NUMBER'))
  484. // Define the artifacts to be deployed to https://binaries.sonarsource.com on releases
  485. clientConfig.info.addEnvironmentProperty('ARTIFACTS_TO_PUBLISH',
  486. "${project.group}:sonar-application:zip," +
  487. "com.sonarsource.sonarqube:sonarqube-developer:zip," +
  488. "com.sonarsource.sonarqube:sonarqube-datacenter:zip," +
  489. "com.sonarsource.sonarqube:sonarqube-enterprise:zip")
  490. // The name of this variable is important because it's used by the delivery process when extracting version from Artifactory build info.
  491. clientConfig.info.addEnvironmentProperty('PROJECT_VERSION', "${version}")
  492. }
  493. // https://github.com/ben-manes/gradle-versions-plugin
  494. apply plugin: 'com.github.ben-manes.versions'
  495. dependencyUpdates {
  496. rejectVersionIf {
  497. // Exclude dev versions from the list of dependency upgrades, for
  498. // example to replace:
  499. // org.slf4j:log4j-over-slf4j [1.7.25 -> 1.8.0-beta4]
  500. // by
  501. // org.slf4j:log4j-over-slf4j [1.7.25 -> 1.7.26]
  502. boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm', 'preview', 'jre12'].any { qualifier ->
  503. it.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
  504. }
  505. // Exclude upgrades on new major versions :
  506. // com.hazelcast:hazelcast [3.12.3 -> 4.0.0]
  507. rejected |= !it.candidate.version.substring(0, 2).equals(it.currentVersion.substring(0, 2))
  508. rejected
  509. }
  510. }