Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

build.gradle 25KB

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