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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. import groovy.json.JsonOutput
  2. import static org.gradle.api.JavaVersion.VERSION_17
  3. plugins {
  4. // Ordered alphabetically
  5. id 'com.github.hierynomus.license' version '0.16.1'
  6. id "com.github.hierynomus.license-report" version "0.16.1" apply false
  7. id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
  8. id 'com.google.protobuf' version '0.8.19' apply false
  9. id 'com.jfrog.artifactory' version '4.31.8'
  10. id "de.undercouch.download" version "5.4.0" apply false
  11. id 'io.spring.dependency-management' version '1.1.0'
  12. id "org.cyclonedx.bom" version "1.7.4" apply false
  13. id 'org.sonarqube' version '4.2.1.3168'
  14. }
  15. if (!JavaVersion.current().isCompatibleWith(VERSION_17)) {
  16. throw new GradleException("JDK 17+ is required to perform this build. It's currently " + System.getProperty("java.home") + ".")
  17. }
  18. /**
  19. * The BOM related tasks are disabled by default, activated by:
  20. * - running in the CI and being on a main branch or a nightly build,
  21. * - or using '-Dbom' project property
  22. * - or by explicit call to 'cyclonedxBom' Gradle task
  23. */
  24. def bomTasks = "cyclonedxBom"
  25. def ghBranch = System.getenv()["GITHUB_BRANCH"]
  26. def isMainBranch = ghBranch in ['master'] || ghBranch ==~ 'branch-[\\d.]+'
  27. def isNightlyBuild = ghBranch == "branch-nightly-build"
  28. boolean enableBom = System.getenv('CI') == "true" && (isMainBranch || isNightlyBuild) ||
  29. System.getProperty("bom") != null ||
  30. gradle.startParameter.taskNames.findAll({ it.matches(".*:($bomTasks)") })
  31. allprojects {
  32. apply plugin: 'com.jfrog.artifactory'
  33. apply plugin: 'maven-publish'
  34. ext.versionInSources = version
  35. ext.buildNumber = System.getProperty("buildNumber")
  36. // when no buildNumber is provided, then project version must end with '-SNAPSHOT'
  37. if (ext.buildNumber == null) {
  38. version = "${version}-SNAPSHOT".toString()
  39. ext.versionWithoutBuildNumber = version
  40. } else {
  41. ext.versionWithoutBuildNumber = version
  42. version = (version.toString().count('.') == 1 ? "${version}.0.${ext.buildNumber}" : "${version}.${ext.buildNumber}").toString()
  43. }
  44. task cacheDependencies {
  45. doLast {
  46. configurations.each { conf ->
  47. if (conf.isCanBeResolved()) {
  48. if (conf.getName() != 'appZip')
  49. conf.resolve()
  50. }
  51. }
  52. }
  53. }
  54. ext {
  55. release = project.hasProperty('release') && project.getProperty('release')
  56. official = project.hasProperty('official') && project.getProperty('official')
  57. }
  58. ext.enableBom = enableBom
  59. if (!enableBom) {
  60. tasks.matching { it.name.matches(bomTasks) }.all({
  61. logger.info("{} disabled", it.name);
  62. it.enabled = false
  63. })
  64. }
  65. repositories {
  66. def repository = project.hasProperty('qa') ? 'sonarsource-qa' : 'sonarsource'
  67. // The environment variables ARTIFACTORY_PRIVATE_USERNAME and ARTIFACTORY_PRIVATE_PASSWORD are used on QA env (Jenkins)
  68. // On local box, please add artifactoryUsername and artifactoryPassword to ~/.gradle/gradle.properties
  69. def artifactoryUsername = System.env.'ARTIFACTORY_PRIVATE_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '')
  70. def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '')
  71. maven {
  72. if (artifactoryUsername && artifactoryPassword) {
  73. credentials {
  74. username artifactoryUsername
  75. password artifactoryPassword
  76. }
  77. } else {
  78. // Workaround for artifactory
  79. // https://www.jfrog.com/jira/browse/RTFACT-13797
  80. repository = 'public'
  81. }
  82. url "https://repox.jfrog.io/repox/${repository}"
  83. }
  84. ivy {
  85. if (artifactoryUsername && artifactoryPassword) {
  86. credentials {
  87. username artifactoryUsername
  88. password artifactoryPassword
  89. }
  90. url "https://repox.jfrog.io/repox/sonarsource-bucket"
  91. patternLayout {
  92. artifact '/[organisation]/[module]/[module]-[revision].[ext]'
  93. }
  94. } else {
  95. // For public build
  96. url "https://artifacts.elastic.co/downloads/"
  97. patternLayout {
  98. artifact '/[organisation]/[module]-[revision].[ext]'
  99. }
  100. }
  101. metadataSources { artifact() }
  102. }
  103. }
  104. task allDependencies {
  105. dependsOn 'dependencies'
  106. }
  107. artifactory {
  108. clientConfig.setIncludeEnvVars(true)
  109. clientConfig.setEnvVarsExcludePatterns('*pass*,*psw*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*login*,*key*,*signing*,*auth*,*pwd*')
  110. contextUrl = System.getenv('ARTIFACTORY_URL')
  111. publish {
  112. repository {
  113. repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO')
  114. username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME') ?: project.properties.artifactoryUsername
  115. password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD') ?: project.properties.artifactoryPaswword
  116. }
  117. defaults {
  118. properties = [
  119. 'build.name': 'sonar-enterprise',
  120. 'build.number': System.getenv('BUILD_NUMBER'),
  121. 'pr.branch.target': System.getenv('GITHUB_BASE_BRANCH'),
  122. 'pr.number': System.getenv('PULL_REQUEST'),
  123. 'vcs.branch': ghBranch,
  124. 'vcs.revision': System.getenv('GIT_SHA1'),
  125. 'version': version
  126. ]
  127. publications('mavenJava')
  128. publishPom = true
  129. publishIvy = false
  130. }
  131. }
  132. clientConfig.info.setBuildName('sonar-enterprise')
  133. clientConfig.info.setBuildNumber(System.getenv('BUILD_NUMBER'))
  134. // Define the artifacts to be deployed to https://binaries.sonarsource.com on releases
  135. clientConfig.info.addEnvironmentProperty('ARTIFACTS_TO_PUBLISH',
  136. "${project.group}:sonar-application:zip," +
  137. "com.sonarsource.sonarqube:sonarqube-developer:zip," +
  138. "com.sonarsource.sonarqube:sonarqube-datacenter:zip," +
  139. "com.sonarsource.sonarqube:sonarqube-enterprise:zip")
  140. // The name of this variable is important because it's used by the delivery process when extracting version from Artifactory build info.
  141. clientConfig.info.addEnvironmentProperty('PROJECT_VERSION', "${version}")
  142. }
  143. }
  144. apply plugin: 'org.sonarqube'
  145. sonar {
  146. properties {
  147. property 'sonar.projectName', projectTitle
  148. property 'sonar.projectVersion', "${versionInSources}-SNAPSHOT"
  149. property 'sonar.buildString', version
  150. }
  151. }
  152. tasks.named('wrapper') {
  153. distributionType = Wrapper.DistributionType.ALL
  154. }
  155. subprojects {
  156. apply plugin: 'com.github.hierynomus.license'
  157. apply plugin: 'io.spring.dependency-management'
  158. apply plugin: 'jacoco'
  159. apply plugin: 'java-library'
  160. apply plugin: 'idea'
  161. apply plugin: 'signing'
  162. // do not deploy to Artifactory by default
  163. artifactoryPublish.skip = true
  164. compileJava.options.encoding = "UTF-8"
  165. compileTestJava.options.encoding = "UTF-8"
  166. def testFixtureSrc = 'src/testFixtures'
  167. if (file(testFixtureSrc).exists()) {
  168. apply plugin: 'java-test-fixtures'
  169. }
  170. ext {
  171. protobufVersion = '3.22.2'
  172. springVersion = '5.3.27'
  173. }
  174. sonar {
  175. properties {
  176. property 'sonar.moduleKey', project.group + ':' + project.name
  177. }
  178. }
  179. sourceSets {
  180. test {
  181. resources {
  182. srcDirs += ['src/it/resources']
  183. }
  184. java {
  185. srcDirs += ['src/it/java']
  186. }
  187. }
  188. }
  189. // Central place for definition dependency versions and exclusions.
  190. dependencyManagement {
  191. dependencies {
  192. // bundled plugin list -- keep it alphabetically ordered
  193. dependency 'com.sonarsource.abap:sonar-abap-plugin:3.12.0.4303'
  194. dependency 'com.sonarsource.cobol:sonar-cobol-plugin:5.3.0.6122'
  195. dependency 'com.sonarsource.cpp:sonar-cfamily-plugin:6.45.0.62016'
  196. dependency 'com.sonarsource.dbd:sonar-dbd-plugin:1.16.0.4300'
  197. dependency 'com.sonarsource.dbd:sonar-dbd-java-frontend-plugin:1.16.0.4300'
  198. dependency 'com.sonarsource.dbd:sonar-dbd-python-frontend-plugin:1.16.0.4300'
  199. dependency 'com.sonarsource.pli:sonar-pli-plugin:1.13.0.3651'
  200. dependency 'com.sonarsource.plsql:sonar-plsql-plugin:3.9.0.5181'
  201. dependency 'com.sonarsource.plugins.vb:sonar-vb-plugin:2.10.0.3598'
  202. dependency 'com.sonarsource.rpg:sonar-rpg-plugin:3.4.0.3394'
  203. dependency 'com.sonarsource.security:sonar-security-csharp-frontend-plugin:10.1.0.21056'
  204. dependency 'com.sonarsource.security:sonar-security-java-frontend-plugin:10.1.0.21056'
  205. dependency 'com.sonarsource.security:sonar-security-php-frontend-plugin:10.1.0.21056'
  206. dependency 'com.sonarsource.security:sonar-security-plugin:10.1.0.21056'
  207. dependency 'com.sonarsource.security:sonar-security-python-frontend-plugin:10.1.0.21056'
  208. dependency 'com.sonarsource.security:sonar-security-js-frontend-plugin:10.1.0.21056'
  209. dependency 'com.sonarsource.slang:sonar-apex-plugin:1.13.0.4374'
  210. dependency 'com.sonarsource.swift:sonar-swift-plugin:4.9.0.5915'
  211. dependency 'com.sonarsource.tsql:sonar-tsql-plugin:1.9.0.5692'
  212. dependency 'org.sonarsource.config:sonar-config-plugin:1.2.0.267'
  213. dependency 'org.sonarsource.dotnet:sonar-csharp-plugin:9.3.0.71466'
  214. dependency 'org.sonarsource.dotnet:sonar-vbnet-plugin:9.3.0.71466'
  215. dependency 'org.sonarsource.flex:sonar-flex-plugin:2.9.0.3375'
  216. dependency 'org.sonarsource.html:sonar-html-plugin:3.8.0.3510'
  217. dependency 'org.sonarsource.jacoco:sonar-jacoco-plugin:1.3.0.1538'
  218. dependency 'org.sonarsource.java:sonar-java-plugin:7.20.0.31692'
  219. dependency 'org.sonarsource.javascript:sonar-javascript-plugin:10.3.1.21905'
  220. dependency 'org.sonarsource.php:sonar-php-plugin:3.30.0.9766'
  221. dependency 'org.sonarsource.plugins.cayc:sonar-cayc-plugin:2.0.0.334'
  222. dependency 'org.sonarsource.python:sonar-python-plugin:4.3.0.11660'
  223. dependency 'org.sonarsource.slang:sonar-go-plugin:1.13.0.4374'
  224. dependency 'org.sonarsource.kotlin:sonar-kotlin-plugin:2.15.0.2579'
  225. dependency 'org.sonarsource.slang:sonar-ruby-plugin:1.13.0.4374'
  226. dependency 'org.sonarsource.slang:sonar-scala-plugin:1.13.0.4374'
  227. dependency "org.sonarsource.api.plugin:sonar-plugin-api:$pluginApiVersion"
  228. dependency "org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures:$pluginApiVersion"
  229. dependency 'org.sonarsource.xml:sonar-xml-plugin:2.8.1.4006'
  230. dependency 'org.sonarsource.iac:sonar-iac-plugin:1.17.0.3976'
  231. dependency 'org.sonarsource.text:sonar-text-plugin:2.1.0.1163'
  232. // please keep this list alphabetically ordered
  233. dependencySet(group: 'ch.qos.logback', version: '1.3.5') {
  234. entry 'logback-access'
  235. entry 'logback-classic'
  236. entry 'logback-core'
  237. }
  238. dependency('commons-beanutils:commons-beanutils:1.9.4') {
  239. exclude 'commons-logging:commons-logging'
  240. }
  241. dependency 'commons-codec:commons-codec:1.15'
  242. dependency 'commons-dbutils:commons-dbutils:1.7'
  243. dependency 'commons-io:commons-io:2.11.0'
  244. dependency 'commons-lang:commons-lang:2.6'
  245. imports { mavenBom 'com.fasterxml.jackson:jackson-bom:2.15.1' }
  246. dependency 'com.eclipsesource.minimal-json:minimal-json:0.9.5'
  247. dependencySet(group: 'com.github.scribejava', version: '8.3.3') {
  248. entry 'scribejava-apis'
  249. entry 'scribejava-core'
  250. }
  251. dependency 'com.github.everit-org.json-schema:org.everit.json.schema:1.14.0'
  252. // This project is no longer maintained and was forked
  253. // by https://github.com/java-diff-utils/java-diff-utils
  254. // (io.github.java-diff-utils:java-diff-utils).
  255. dependency 'com.googlecode.java-diff-utils:diffutils:1.3.0'
  256. dependency('com.googlecode.json-simple:json-simple:1.1.1') {
  257. exclude 'junit:junit'
  258. }
  259. dependency 'io.prometheus:simpleclient:0.16.0'
  260. dependency 'io.prometheus:simpleclient_common:0.16.0'
  261. dependency 'io.prometheus:simpleclient_servlet:0.16.0'
  262. dependency 'com.google.code.findbugs:jsr305:3.0.2'
  263. dependency 'com.google.code.gson:gson:2.10.1'
  264. dependency('com.google.guava:guava:31.1-jre') {
  265. exclude 'com.google.errorprone:error_prone_annotations'
  266. exclude 'com.google.guava:listenablefuture'
  267. exclude 'com.google.j2objc:j2objc-annotations'
  268. exclude 'org.checkerframework:checker-qual'
  269. exclude 'org.codehaus.mojo:animal-sniffer-annotations'
  270. }
  271. dependency "com.google.protobuf:protobuf-java:${protobufVersion}"
  272. dependency 'com.h2database:h2:2.1.214'
  273. dependencySet(group: 'com.hazelcast', version: '5.2.3') {
  274. entry 'hazelcast'
  275. }
  276. // Documentation must be updated if mssql-jdbc is updated: https://github.com/SonarSource/sonarqube/commit/03e4773ebf6cba854cdcf57a600095f65f4f53e7
  277. dependency('com.microsoft.sqlserver:mssql-jdbc:12.2.0.jre11') {
  278. exclude 'com.fasterxml.jackson.core:jackson-databind'
  279. }
  280. dependency 'com.onelogin:java-saml:2.9.0'
  281. dependency 'com.oracle.database.jdbc:ojdbc11:21.9.0.0'
  282. dependency 'org.aspectj:aspectjtools:1.9.19'
  283. dependencySet(group: 'com.squareup.okhttp3', version: '4.10.0') {
  284. entry 'okhttp'
  285. entry 'mockwebserver'
  286. }
  287. dependency 'org.json:json:20230227'
  288. dependency 'com.tngtech.java:junit-dataprovider:1.13.1'
  289. dependencySet(group: 'io.jsonwebtoken', version: '0.11.5') {
  290. entry 'jjwt-api'
  291. entry 'jjwt-impl'
  292. entry 'jjwt-jackson'
  293. }
  294. dependency 'com.auth0:java-jwt:4.4.0'
  295. dependency 'io.netty:netty-all:4.1.90.Final'
  296. dependency 'com.sun.mail:javax.mail:1.6.2'
  297. dependency 'javax.annotation:javax.annotation-api:1.3.2'
  298. dependency 'javax.inject:javax.inject:1'
  299. dependency 'javax.servlet:javax.servlet-api:4.0.1'
  300. dependency 'javax.xml.bind:jaxb-api:2.3.1'
  301. dependency 'junit:junit:4.13.2'
  302. dependency 'org.xmlunit:xmlunit-core:2.9.1'
  303. dependency 'org.xmlunit:xmlunit-matchers:2.9.1'
  304. dependency 'net.jpountz.lz4:lz4:1.3.0'
  305. dependency 'net.lightbody.bmp:littleproxy:1.1.0-beta-bmp-17'
  306. dependency 'org.awaitility:awaitility:4.2.0'
  307. dependency 'org.apache.commons:commons-csv:1.10.0'
  308. dependency 'org.apache.commons:commons-email:1.5'
  309. dependency 'com.zaxxer:HikariCP:5.0.1'
  310. dependency('org.apache.httpcomponents:httpclient:4.5.14') {
  311. exclude 'commons-logging:commons-logging'
  312. }
  313. // Be aware that Log4j is used by Elasticsearch client
  314. dependencySet(group: 'org.apache.logging.log4j', version: '2.20.0') {
  315. entry 'log4j-core'
  316. entry 'log4j-api'
  317. entry 'log4j-to-slf4j'
  318. }
  319. dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.74') {
  320. entry 'tomcat-embed-core'
  321. entry('tomcat-embed-jasper') {
  322. exclude 'org.eclipse.jdt.core.compiler:ecj'
  323. }
  324. }
  325. dependency 'org.assertj:assertj-core:3.24.2'
  326. dependency 'org.assertj:assertj-guava:3.24.2'
  327. dependency('org.codehaus.sonar:sonar-channel:4.2') {
  328. exclude 'org.slf4j:slf4j-api'
  329. }
  330. dependency 'org.codehaus.sonar:sonar-classloader:1.0'
  331. dependency 'com.fasterxml.staxmate:staxmate:2.4.0'
  332. dependencySet(group: 'org.eclipse.jetty', version: '9.4.6.v20170531') {
  333. entry 'jetty-proxy'
  334. entry 'jetty-server'
  335. entry 'jetty-servlet'
  336. }
  337. // "elasticsearchDownloadUrlFile" and "elasticsearchDownloadSha512" must also be updated in gradle.properties
  338. dependency('org.elasticsearch.client:elasticsearch-rest-high-level-client:7.17.9') {
  339. exclude 'org.apache.logging.log4j:log4j-core'
  340. }
  341. dependency 'org.elasticsearch.plugin:transport-netty4-client:7.17.9'
  342. dependency 'org.elasticsearch:mocksocket:1.2'
  343. dependency 'org.codelibs.elasticsearch.module:analysis-common:7.17.9'
  344. dependency 'org.codelibs.elasticsearch.module:reindex:7.17.9'
  345. dependency 'org.eclipse.jgit:org.eclipse.jgit:6.5.0.202303070854-r'
  346. dependency 'org.tmatesoft.svnkit:svnkit:1.10.11'
  347. dependency 'org.hamcrest:hamcrest-all:1.3'
  348. dependency 'org.jsoup:jsoup:1.15.4'
  349. dependency 'org.mindrot:jbcrypt:0.4'
  350. dependency('org.mockito:mockito-core:5.2.0') {
  351. exclude 'org.hamcrest:hamcrest-core'
  352. }
  353. dependency "org.springframework:spring-test:${springVersion}"
  354. dependency 'org.mybatis:mybatis:3.5.13'
  355. dependencySet(group: 'org.slf4j', version: '2.0.7') {
  356. entry 'jcl-over-slf4j'
  357. entry 'jul-to-slf4j'
  358. entry 'log4j-over-slf4j'
  359. entry 'slf4j-api'
  360. }
  361. dependency 'org.postgresql:postgresql:42.6.0'
  362. dependency 'org.reflections:reflections:0.10.2'
  363. dependency 'org.simpleframework:simple:5.1.6'
  364. dependency 'org.sonarsource.git.blame:git-files-blame:1.0.1.169'
  365. dependency 'org.sonarsource.orchestrator:sonar-orchestrator:3.42.0.312'
  366. dependency 'org.sonarsource.update-center:sonar-update-center-common:1.29.0.1000'
  367. dependency("org.springframework:spring-context:${springVersion}") {
  368. exclude 'commons-logging:commons-logging'
  369. }
  370. dependency ("org.springframework:spring-webmvc:${springVersion}") {
  371. exclude 'commons-logging:commons-logging'
  372. }
  373. dependency 'org.springdoc:springdoc-openapi-ui:1.7.0'
  374. dependency 'org.subethamail:subethasmtp:3.1.7'
  375. dependency 'org.yaml:snakeyaml:2.0'
  376. // please keep this list alphabetically ordered
  377. }
  378. }
  379. // global exclusions
  380. configurations.all {
  381. // do not conflict with com.sun.mail:javax.mail
  382. exclude group: 'javax.mail', module: 'mail'
  383. }
  384. tasks.withType(Javadoc) {
  385. options.addStringOption('Xdoclint:none', '-quiet')
  386. options.encoding = 'UTF-8'
  387. title = project.name + ' ' + versionWithoutBuildNumber
  388. }
  389. task sourcesJar(type: Jar, dependsOn: classes) {
  390. archiveClassifier = 'sources'
  391. from sourceSets.main.allSource
  392. }
  393. task javadocJar(type: Jar, dependsOn: javadoc) {
  394. archiveClassifier = 'javadoc'
  395. from javadoc.destinationDir
  396. }
  397. // generate code before opening project in IDE (Eclipse or Intellij)
  398. task ide() {
  399. // empty by default. Dependencies are added to the task
  400. // when needed (see protobuf modules for example)
  401. }
  402. jacocoTestReport {
  403. reports {
  404. xml.required = true
  405. csv.required = false
  406. html.required = false
  407. }
  408. }
  409. normalization {
  410. runtimeClasspath {
  411. // Following classpath resources contain volatile data that changes in each CI build (build number, commit id, time),
  412. // so we exclude them from calculation of build cache key of test tasks:
  413. ignore 'META-INF/MANIFEST.MF'
  414. ignore 'sonar-api-version.txt'
  415. ignore 'sq-version.txt'
  416. }
  417. }
  418. ext.failedTests = []
  419. test {
  420. jvmArgs '-Dfile.encoding=UTF8'
  421. maxHeapSize = '1G'
  422. systemProperty 'java.awt.headless', true
  423. testLogging {
  424. events "skipped", "failed" // verbose log for failed and skipped tests (by default the name of the tests are not logged)
  425. exceptionFormat 'full' // log the full stack trace (default is the 1st line of the stack trace)
  426. }
  427. jacoco {
  428. enabled = true // do not disable recording of code coverage, so that remote Gradle cache entry can be used locally
  429. includes = ['com.sonar.*', 'com.sonarsource.*', 'org.sonar.*', 'org.sonarqube.*', 'org.sonarsource.*']
  430. }
  431. if (project.hasProperty('maxParallelTests')) {
  432. maxParallelForks = project.maxParallelTests as int
  433. }
  434. if (project.hasProperty('parallelTests')) {
  435. // See https://guides.gradle.org/performance/#parallel_test_execution
  436. maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
  437. }
  438. afterTest { descriptor, result ->
  439. if (result.resultType == TestResult.ResultType.FAILURE) {
  440. String failedTest = " ${descriptor.className} > ${descriptor.name}"
  441. failedTests << failedTest
  442. }
  443. }
  444. }
  445. gradle.buildFinished {
  446. if (!failedTests.empty) {
  447. println "\nFailed tests:"
  448. failedTests.each { failedTest ->
  449. println failedTest
  450. }
  451. println ""
  452. }
  453. }
  454. def protoMainSrc = 'src/main/protobuf'
  455. def protoTestSrc = 'src/test/protobuf'
  456. if (file(protoMainSrc).exists() || file(protoTestSrc).exists()) {
  457. // protobuf must be applied after java
  458. apply plugin: 'com.google.protobuf'
  459. sourceSets.main.proto.srcDir protoMainSrc // in addition to the default 'src/main/proto'
  460. sourceSets.test.proto.srcDir protoTestSrc // in addition to the default 'src/test/proto'
  461. protobuf {
  462. protoc {
  463. artifact = "com.google.protobuf:protoc:${protobufVersion}"
  464. }
  465. }
  466. jar {
  467. exclude('**/*.proto')
  468. }
  469. idea {
  470. module {
  471. sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  472. testSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  473. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  474. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  475. }
  476. }
  477. ide.dependsOn(['generateProto', 'generateTestProto'])
  478. }
  479. if (official) {
  480. jar {
  481. // do not break incremental build on non official versions
  482. manifest {
  483. attributes(
  484. 'Version': "${version}",
  485. 'Implementation-Build': System.getenv('GIT_SHA1'),
  486. 'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  487. )
  488. }
  489. }
  490. }
  491. license {
  492. header = rootProject.file('HEADER')
  493. strictCheck true
  494. encoding = 'UTF-8'
  495. mapping {
  496. java = 'SLASHSTAR_STYLE'
  497. js = 'SLASHSTAR_STYLE'
  498. ts = 'SLASHSTAR_STYLE'
  499. tsx = 'SLASHSTAR_STYLE'
  500. css = 'SLASHSTAR_STYLE'
  501. }
  502. includes(['**/*.java', '**/*.js', '**/*.ts', '**/*.tsx', '**/*.css'])
  503. }
  504. tasks.withType(GenerateModuleMetadata) {
  505. enabled = false
  506. }
  507. publishing {
  508. publications {
  509. mavenJava(MavenPublication) {
  510. pom {
  511. name = 'SonarQube'
  512. description = project.description
  513. url = 'http://www.sonarqube.org/'
  514. organization {
  515. name = 'SonarSource'
  516. url = 'http://www.sonarsource.com'
  517. }
  518. licenses {
  519. license {
  520. name = 'GNU LGPL 3'
  521. url = 'http://www.gnu.org/licenses/lgpl.txt'
  522. distribution = 'repo'
  523. }
  524. }
  525. scm {
  526. url = 'https://github.com/SonarSource/sonarqube'
  527. }
  528. developers {
  529. developer {
  530. id = 'sonarsource-team'
  531. name = 'SonarSource Team'
  532. }
  533. }
  534. }
  535. }
  536. }
  537. }
  538. tasks.withType(Test) {
  539. configurations {
  540. utMonitoring
  541. }
  542. dependencies {
  543. testImplementation project(":ut-monitoring")
  544. utMonitoring 'org.aspectj:aspectjweaver:1.9.19'
  545. }
  546. }
  547. if (isNightlyBuild) {
  548. tasks.withType(Test) {
  549. doFirst {
  550. ext {
  551. aspectJWeaver = configurations.utMonitoring.resolvedConfiguration.resolvedArtifacts.find { it.name == 'aspectjweaver' }
  552. }
  553. jvmArgs "-javaagent:${aspectJWeaver.file}"
  554. }
  555. }
  556. }
  557. signing {
  558. def signingKeyId = findProperty("signingKeyId")
  559. def signingKey = findProperty("signingKey")
  560. def signingPassword = findProperty("signingPassword")
  561. useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
  562. required {
  563. return isMainBranch && gradle.taskGraph.hasTask(":artifactoryPublish")
  564. }
  565. sign publishing.publications
  566. }
  567. tasks.withType(Sign) {
  568. onlyIf {
  569. return !artifactoryPublish.skip && isMainBranch && gradle.taskGraph.hasTask(":artifactoryPublish")
  570. }
  571. }
  572. }
  573. gradle.projectsEvaluated { gradle ->
  574. // yarn_run tasks can't all run in parallel without random issues
  575. // this script ensure all yarn_run tasks run sequentially
  576. def yarnRunTasks = allprojects.findResults { it -> it.tasks.findByName('yarn_run') }
  577. yarnRunTasks.drop(1).eachWithIndex { it, i -> it.mustRunAfter(yarnRunTasks[0..i]) }
  578. }
  579. ext.osAdaptiveCommand = { commands ->
  580. def newCommands = []
  581. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  582. newCommands = ['cmd', '/c']
  583. }
  584. newCommands.addAll(commands)
  585. return newCommands
  586. }
  587. tasks.named('sonarqube') {
  588. long taskStart
  589. doFirst {
  590. taskStart = System.currentTimeMillis()
  591. }
  592. doLast {
  593. long taskDuration = System.currentTimeMillis() - taskStart
  594. File outputFile = new File("/tmp/analysis-monitoring.log")
  595. outputFile.append(JsonOutput.toJson([category: "Analysis", suite: "Standalone", operation: "total", duration: taskDuration]) + '\n')
  596. }
  597. }