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

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