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

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