Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

build.gradle 24KB

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