Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. import groovy.json.JsonOutput
  2. import groovy.text.SimpleTemplateEngine
  3. import org.sonar.build.BlackBoxTest
  4. import static org.gradle.api.JavaVersion.VERSION_17
  5. plugins {
  6. // Ordered alphabetically
  7. id 'com.github.hierynomus.license' version '0.16.1'
  8. id "com.github.hierynomus.license-report" version "0.16.1" apply false
  9. id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
  10. id 'com.google.protobuf' version '0.8.19' apply false
  11. id 'com.jfrog.artifactory' version '5.1.10'
  12. id "de.undercouch.download" version "5.6.0" apply false
  13. id 'io.spring.dependency-management' version '1.1.4'
  14. id "org.cyclonedx.bom" version "1.7.4" apply false
  15. id 'org.sonarqube' version '5.0.0.4638'
  16. }
  17. if (!JavaVersion.current().isCompatibleWith(VERSION_17)) {
  18. throw new GradleException("JDK 17+ is required to perform this build. It's currently " + System.getProperty("java.home") + ".")
  19. }
  20. /**
  21. * The BOM related tasks are disabled by default, activated by:
  22. * - running in the CI and being on a main branch or a nightly build,
  23. * - or using '-Dbom' project property
  24. * - or by explicit call to 'cyclonedxBom' Gradle task
  25. */
  26. def bomTasks = "cyclonedxBom"
  27. def ghBranch = System.getenv()["GITHUB_BRANCH"]
  28. def isMainBranch = ghBranch in ['master'] || ghBranch ==~ 'branch-[\\d.]+'
  29. def isNightlyBuild = ghBranch == "branch-nightly-build"
  30. boolean enableBom = System.getenv('CI') == "true" && (isMainBranch || isNightlyBuild) ||
  31. System.getProperty("bom") != null ||
  32. gradle.startParameter.taskNames.findAll({ it.matches(".*:($bomTasks)") })
  33. allprojects {
  34. apply plugin: 'com.jfrog.artifactory'
  35. apply plugin: 'maven-publish'
  36. ext.versionInSources = version
  37. ext.buildNumber = System.getProperty("buildNumber")
  38. // when no buildNumber is provided, then project version must end with '-SNAPSHOT'
  39. if (ext.buildNumber == null) {
  40. version = "${version}-SNAPSHOT".toString()
  41. ext.versionWithoutBuildNumber = version
  42. } else {
  43. ext.versionWithoutBuildNumber = version
  44. version = (version.toString().count('.') == 1 ? "${version}.0.${ext.buildNumber}" : "${version}.${ext.buildNumber}").toString()
  45. }
  46. task cacheDependencies {
  47. doLast {
  48. configurations.each { conf ->
  49. if (conf.isCanBeResolved()) {
  50. if (conf.getName() != 'appZip')
  51. conf.resolve()
  52. }
  53. }
  54. }
  55. }
  56. ext {
  57. release = project.hasProperty('release') && project.getProperty('release')
  58. official = project.hasProperty('official') && project.getProperty('official')
  59. testMonitoringEnabled = project.hasProperty('withTestMonitoring')
  60. }
  61. ext.enableBom = enableBom
  62. if (!enableBom) {
  63. tasks.matching { it.name.matches(bomTasks) }.all({
  64. logger.info("{} disabled", it.name);
  65. it.enabled = false
  66. })
  67. }
  68. repositories {
  69. def repository = project.hasProperty('qa') ? 'sonarsource-qa' : 'sonarsource'
  70. // The environment variables ARTIFACTORY_PRIVATE_USERNAME and ARTIFACTORY_PRIVATE_PASSWORD are used on QA env (Jenkins)
  71. // On local box, please add artifactoryUsername and artifactoryPassword to ~/.gradle/gradle.properties
  72. def artifactoryUsername = System.env.'ARTIFACTORY_PRIVATE_USERNAME' ?: (project.hasProperty('artifactoryUsername') ? project.getProperty('artifactoryUsername') : '')
  73. def artifactoryPassword = System.env.'ARTIFACTORY_PRIVATE_PASSWORD' ?: (project.hasProperty('artifactoryPassword') ? project.getProperty('artifactoryPassword') : '')
  74. def artifactoryUrl = System.getenv('ARTIFACTORY_URL') ?: (project.hasProperty('artifactoryUrl') ? project.getProperty('artifactoryUrl') : '')
  75. if (artifactoryPassword) {
  76. if (artifactoryUrl == '') {
  77. throw new GradleException('Invalid artifactoryUrl')
  78. }
  79. maven {
  80. authentication {
  81. header(HttpHeaderAuthentication)
  82. }
  83. credentials(HttpHeaderCredentials) {
  84. name = "Authorization"
  85. value = "Bearer $artifactoryPassword"
  86. }
  87. url "${artifactoryUrl}/${repository}"
  88. }
  89. } else {
  90. mavenCentral()
  91. maven {
  92. url 'https://jitpack.io'
  93. }
  94. maven {
  95. url 'https://maven.codelibs.org/'
  96. }
  97. }
  98. ivy {
  99. if (artifactoryUsername && artifactoryPassword) {
  100. url "${artifactoryUrl}/sonarsource-bucket"
  101. authentication {
  102. header(HttpHeaderAuthentication)
  103. }
  104. credentials(HttpHeaderCredentials) {
  105. name = "Authorization"
  106. value = "Bearer $artifactoryPassword"
  107. }
  108. patternLayout {
  109. artifact '/[organisation]/[module]/[module]-[revision].[ext]'
  110. }
  111. } else {
  112. // For public build
  113. url "https://artifacts.elastic.co/downloads/"
  114. patternLayout {
  115. artifact '/[organisation]/[module]-[revision].[ext]'
  116. }
  117. }
  118. metadataSources { artifact() }
  119. }
  120. }
  121. task allDependencies {
  122. dependsOn 'dependencies'
  123. }
  124. artifactory {
  125. clientConfig.setIncludeEnvVars(true)
  126. clientConfig.setEnvVarsExcludePatterns('*pass*,*psw*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*login*,*key*,*signing*,*auth*,*pwd*')
  127. contextUrl = System.getenv('ARTIFACTORY_URL')
  128. publish {
  129. repository {
  130. repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO')
  131. username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME') ?: project.properties.artifactoryUsername
  132. password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD') ?: project.properties.artifactoryPaswword
  133. }
  134. defaults {
  135. properties = [
  136. 'build.name': 'sonar-enterprise',
  137. 'build.number': System.getenv('BUILD_NUMBER'),
  138. 'pr.branch.target': System.getenv('GITHUB_BASE_BRANCH'),
  139. 'pr.number': System.getenv('PULL_REQUEST'),
  140. 'vcs.branch': ghBranch,
  141. 'vcs.revision': System.getenv('GIT_SHA1'),
  142. 'version': version
  143. ]
  144. publications('mavenJava')
  145. publishPom = true
  146. publishIvy = false
  147. }
  148. }
  149. clientConfig.info.setBuildName('sonar-enterprise')
  150. clientConfig.info.setBuildNumber(System.getenv('BUILD_NUMBER'))
  151. // Define the artifacts to be deployed to https://binaries.sonarsource.com on releases
  152. clientConfig.info.addEnvironmentProperty('ARTIFACTS_TO_PUBLISH',
  153. "${project.group}:sonar-application:zip," +
  154. "com.sonarsource.sonarqube:sonarqube-developer:zip," +
  155. "com.sonarsource.sonarqube:sonarqube-datacenter:zip," +
  156. "com.sonarsource.sonarqube:sonarqube-enterprise:zip")
  157. // The name of this variable is important because it's used by the delivery process when extracting version from Artifactory build info.
  158. clientConfig.info.addEnvironmentProperty('PROJECT_VERSION', "${version}")
  159. }
  160. }
  161. apply plugin: 'org.sonarqube'
  162. sonar {
  163. properties {
  164. property 'sonar.projectName', projectTitle
  165. property 'sonar.projectVersion', "${versionInSources}-SNAPSHOT"
  166. property 'sonar.buildString', version
  167. }
  168. }
  169. tasks.named('wrapper') {
  170. distributionType = Wrapper.DistributionType.ALL
  171. }
  172. subprojects {
  173. apply plugin: 'com.github.hierynomus.license'
  174. apply plugin: 'io.spring.dependency-management'
  175. apply plugin: 'jacoco'
  176. apply plugin: 'java-library'
  177. apply plugin: 'idea'
  178. apply plugin: 'signing'
  179. // do not deploy to Artifactory by default
  180. artifactoryPublish.skip = true
  181. compileJava.options.encoding = "UTF-8"
  182. compileTestJava.options.encoding = "UTF-8"
  183. def testFixtureSrc = 'src/testFixtures'
  184. if (file(testFixtureSrc).exists()) {
  185. apply plugin: 'java-test-fixtures'
  186. }
  187. ext {
  188. protobufVersion = '3.24.2'
  189. springVersion = '5.3.31'
  190. elasticSearchClientVersion = '7.17.20'
  191. }
  192. sonar {
  193. properties {
  194. property 'sonar.moduleKey', project.group + ':' + project.name
  195. }
  196. }
  197. sourceSets {
  198. test {
  199. resources {
  200. srcDirs += ['src/it/resources']
  201. }
  202. java {
  203. srcDirs += ['src/it/java']
  204. }
  205. }
  206. bbt {
  207. resources {
  208. srcDirs = ['src/bbt/resources']
  209. }
  210. java {
  211. srcDirs = ['src/bbt/java']
  212. }
  213. }
  214. }
  215. // Central place for definition dependency versions and exclusions.
  216. dependencyManagement {
  217. dependencies {
  218. // bundled plugin list -- keep it alphabetically ordered
  219. dependency 'com.sonarsource.abap:sonar-abap-plugin:3.14.0.5470'
  220. dependency 'com.sonarsource.cobol:sonar-cobol-plugin:5.6.0.7604'
  221. dependency 'com.sonarsource.cpp:sonar-cfamily-plugin:6.54.0.69031'
  222. dependency 'com.sonarsource.dbd:sonar-dbd-plugin:1.26.0.8705'
  223. dependency 'com.sonarsource.dbd:sonar-dbd-java-frontend-plugin:1.26.0.8705'
  224. dependency 'com.sonarsource.dbd:sonar-dbd-python-frontend-plugin:1.26.0.8705'
  225. dependency 'com.sonarsource.pli:sonar-pli-plugin:1.15.0.4810'
  226. dependency 'com.sonarsource.plsql:sonar-plsql-plugin:3.13.0.6725'
  227. dependency 'com.sonarsource.plugins.vb:sonar-vb-plugin:2.13.0.5130'
  228. dependency 'com.sonarsource.rpg:sonar-rpg-plugin:3.8.0.4662'
  229. dependency 'com.sonarsource.security:sonar-security-csharp-frontend-plugin:10.5.0.30668'
  230. dependency 'com.sonarsource.security:sonar-security-java-frontend-plugin:10.5.0.30668'
  231. dependency 'com.sonarsource.security:sonar-security-php-frontend-plugin:10.5.0.30668'
  232. dependency 'com.sonarsource.security:sonar-security-plugin:10.5.0.30668'
  233. dependency 'com.sonarsource.security:sonar-security-python-frontend-plugin:10.5.0.30668'
  234. dependency 'com.sonarsource.security:sonar-security-js-frontend-plugin:10.5.0.30668'
  235. dependency 'com.sonarsource.slang:sonar-apex-plugin:1.15.0.4655'
  236. dependency 'org.sonarsource.slang:sonar-go-plugin:1.15.0.4655'
  237. dependency 'org.sonarsource.slang:sonar-ruby-plugin:1.15.0.4655'
  238. dependency 'org.sonarsource.slang:sonar-scala-plugin:1.15.0.4655'
  239. dependency 'com.sonarsource.swift:sonar-swift-plugin:4.12.0.7262'
  240. dependency 'com.sonarsource.tsql:sonar-tsql-plugin:1.13.0.7207'
  241. dependency 'org.sonarsource.dotnet:sonar-csharp-plugin:9.25.0.90414'
  242. dependency 'org.sonarsource.dotnet:sonar-vbnet-plugin:9.25.0.90414'
  243. dependency 'org.sonarsource.flex:sonar-flex-plugin:2.12.0.4568'
  244. dependency 'org.sonarsource.html:sonar-html-plugin:3.16.0.5274'
  245. dependency 'org.sonarsource.jacoco:sonar-jacoco-plugin:1.3.0.1538'
  246. dependency 'org.sonarsource.java:sonar-java-plugin:7.34.0.35958'
  247. dependency 'org.sonarsource.javascript:sonar-javascript-plugin:10.14.0.26080'
  248. dependency 'org.sonarsource.php:sonar-php-plugin:3.35.0.11659'
  249. dependency 'org.sonarsource.plugins.cayc:sonar-cayc-plugin:2.3.0.1782'
  250. dependency 'org.sonarsource.python:sonar-python-plugin:4.18.0.15334'
  251. dependency 'org.sonarsource.kotlin:sonar-kotlin-plugin:2.20.0.4382'
  252. dependency "org.sonarsource.api.plugin:sonar-plugin-api:$pluginApiVersion"
  253. dependency "org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures:$pluginApiVersion"
  254. dependency 'org.sonarsource.xml:sonar-xml-plugin:2.10.0.4108'
  255. dependency 'org.sonarsource.iac:sonar-iac-plugin:1.30.0.10357'
  256. dependency 'org.sonarsource.text:sonar-text-plugin:2.10.0.2188'
  257. dependency 'com.sonarsource.text:sonar-text-enterprise-plugin:2.10.0.2188'
  258. dependency 'com.sonarsource.jcl:sonar-jcl-plugin:1.1.0.855'
  259. // please keep this list alphabetically ordered
  260. dependencySet(group: 'ch.qos.logback', version: '1.5.3') {
  261. entry 'logback-classic'
  262. entry 'logback-core'
  263. }
  264. // TODO switch to dependency 'ch.qos.logback.access:tomcat:2.0.1' when upgrading to Tomcat 10+
  265. dependency 'ch.qos.logback:logback-access:1.3.14'
  266. dependency('commons-beanutils:commons-beanutils:1.9.4') {
  267. exclude 'commons-logging:commons-logging'
  268. }
  269. dependency 'commons-codec:commons-codec:1.16.1'
  270. dependency 'commons-dbutils:commons-dbutils:1.8.1'
  271. dependency 'commons-io:commons-io:2.16.1'
  272. imports { mavenBom 'com.fasterxml.jackson:jackson-bom:2.17.0' }
  273. dependency 'com.eclipsesource.minimal-json:minimal-json:0.9.5'
  274. dependencySet(group: 'com.github.scribejava', version: '8.3.3') {
  275. entry 'scribejava-apis'
  276. entry 'scribejava-core'
  277. }
  278. dependency('com.github.erosb:json-sKema:0.15.0') {
  279. // this version of json-sKema does not make use of commons-collections, so we can exclude it safely
  280. exclude 'commons-collections:commons-collections'
  281. }
  282. // This project is no longer maintained and was forked
  283. // by https://github.com/java-diff-utils/java-diff-utils
  284. // (io.github.java-diff-utils:java-diff-utils).
  285. dependency 'com.googlecode.java-diff-utils:diffutils:1.3.0'
  286. dependency('com.googlecode.json-simple:json-simple:1.1.1') {
  287. exclude 'junit:junit'
  288. }
  289. dependency 'com.squareup.okio:okio:3.9.0'
  290. dependency 'io.github.hakky54:sslcontext-kickstart:8.3.5'
  291. dependency 'io.prometheus:simpleclient:0.16.0'
  292. dependency 'io.prometheus:simpleclient_common:0.16.0'
  293. dependency 'io.prometheus:simpleclient_servlet:0.16.0'
  294. dependency 'com.google.code.findbugs:jsr305:3.0.2'
  295. dependency 'com.google.code.gson:gson:2.10.1'
  296. dependency('com.google.guava:guava:33.1.0-jre') {
  297. exclude 'com.google.errorprone:error_prone_annotations'
  298. exclude 'com.google.guava:listenablefuture'
  299. exclude 'com.google.j2objc:j2objc-annotations'
  300. exclude 'org.checkerframework:checker-qual'
  301. exclude 'org.codehaus.mojo:animal-sniffer-annotations'
  302. }
  303. dependency "com.google.protobuf:protobuf-java:${protobufVersion}"
  304. dependency 'com.h2database:h2:2.2.224'
  305. dependencySet(group: 'com.hazelcast', version: '5.4.0') {
  306. entry 'hazelcast'
  307. }
  308. // Documentation must be updated if mssql-jdbc is updated: https://github.com/SonarSource/sonarqube/commit/03e4773ebf6cba854cdcf57a600095f65f4f53e7
  309. dependency('com.microsoft.sqlserver:mssql-jdbc:12.6.1.jre11') {
  310. exclude 'com.fasterxml.jackson.core:jackson-databind'
  311. }
  312. dependency 'com.onelogin:java-saml:2.9.0'
  313. dependency 'com.oracle.database.jdbc:ojdbc11:23.3.0.23.09'
  314. dependency 'com.datadoghq:dd-java-agent:1.30.1'
  315. dependency 'org.aspectj:aspectjtools:1.9.22'
  316. // If this gets updated the dependency on okio 3.5.0 should be reviewed
  317. dependencySet(group: 'com.squareup.okhttp3', version: '4.12.0') {
  318. entry 'okhttp'
  319. entry 'mockwebserver'
  320. entry 'okhttp-tls'
  321. entry 'logging-interceptor'
  322. }
  323. dependency 'org.json:json:20240303'
  324. // To be removed after migration to JUnit5 is finished
  325. dependency 'com.tngtech.java:junit-dataprovider:1.13.1'
  326. dependency 'com.tngtech.junit.dataprovider:junit-jupiter-params-dataprovider:2.10'
  327. dependencySet(group: 'io.jsonwebtoken', version: '0.12.5') {
  328. entry 'jjwt-api'
  329. entry 'jjwt-impl'
  330. entry 'jjwt-jackson'
  331. }
  332. dependency 'com.auth0:java-jwt:4.4.0'
  333. dependency 'io.netty:netty-all:4.1.109.Final'
  334. dependency 'com.sun.mail:javax.mail:1.6.2'
  335. dependency 'javax.annotation:javax.annotation-api:1.3.2'
  336. dependency 'javax.inject:javax.inject:1'
  337. dependency 'javax.servlet:javax.servlet-api:4.0.1'
  338. dependency 'javax.xml.bind:jaxb-api:2.3.1'
  339. dependency 'junit:junit:4.13.2'
  340. // JUnit 5
  341. dependencySet(group: 'org.junit.jupiter', version: '5.10.2') {
  342. entry 'junit-jupiter-api'
  343. entry 'junit-jupiter-engine'
  344. entry 'junit-jupiter-params'
  345. entry 'junit-vintage-engine'
  346. }
  347. dependency 'org.junit-pioneer:junit-pioneer:2.2.0'
  348. dependency 'org.xmlunit:xmlunit-core:2.9.1'
  349. dependency 'org.xmlunit:xmlunit-matchers:2.9.1'
  350. dependency 'org.lz4:lz4-java:1.8.0'
  351. dependency 'net.lightbody.bmp:littleproxy:1.1.0-beta-bmp-17'
  352. dependency 'org.awaitility:awaitility:4.2.1'
  353. dependency 'org.apache.commons:commons-collections4:4.4'
  354. dependency 'org.apache.commons:commons-csv:1.10.0'
  355. dependency 'org.apache.commons:commons-lang3:3.14.0'
  356. dependency 'org.apache.commons:commons-email:1.6.0'
  357. dependency 'org.apache.commons:commons-text:1.12.0'
  358. dependency 'com.zaxxer:HikariCP:5.1.0'
  359. dependency('org.apache.httpcomponents:httpclient:4.5.14') {
  360. exclude 'commons-logging:commons-logging'
  361. }
  362. // Be aware that Log4j is used by Elasticsearch client
  363. dependencySet(group: 'org.apache.logging.log4j', version: '2.23.1') {
  364. entry 'log4j-core'
  365. entry 'log4j-api'
  366. entry 'log4j-to-slf4j'
  367. }
  368. dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.87') {
  369. entry 'tomcat-embed-core'
  370. entry('tomcat-embed-jasper') {
  371. exclude 'org.eclipse.jdt.core.compiler:ecj'
  372. }
  373. }
  374. //transitive dependency of SVNKit, to be re-assessed when updating SVNKit
  375. dependency 'org.apache.sshd:sshd-core:2.12.1'
  376. dependency 'org.assertj:assertj-core:3.25.3'
  377. dependency 'org.assertj:assertj-guava:3.25.3'
  378. dependency('org.codehaus.sonar:sonar-channel:4.2') {
  379. exclude 'org.slf4j:slf4j-api'
  380. }
  381. dependency 'com.fasterxml.staxmate:staxmate:2.4.1'
  382. dependencySet(group: 'org.eclipse.jetty', version: '9.4.6.v20170531') {
  383. entry 'jetty-proxy'
  384. entry 'jetty-server'
  385. entry 'jetty-servlet'
  386. }
  387. dependency("org.elasticsearch.client:elasticsearch-rest-high-level-client:${elasticSearchClientVersion}") {
  388. exclude 'org.apache.logging.log4j:log4j-core'
  389. }
  390. dependency "org.elasticsearch.plugin:transport-netty4-client:${elasticSearchClientVersion}"
  391. dependency 'org.elasticsearch:mocksocket:1.2'
  392. dependency 'org.eclipse.jgit:org.eclipse.jgit:6.9.0.202403050737-r'
  393. dependency "org.codelibs.elasticsearch.module:analysis-common:7.17.18"
  394. dependency "org.codelibs.elasticsearch.module:reindex:7.17.18"
  395. dependency 'org.tmatesoft.svnkit:svnkit:1.10.11'
  396. dependency 'org.hamcrest:hamcrest-all:1.3'
  397. dependency 'org.jsoup:jsoup:1.17.2'
  398. dependency 'org.mindrot:jbcrypt:0.4'
  399. dependency('org.mockito:mockito-core:5.11.0') {
  400. exclude 'org.hamcrest:hamcrest-core'
  401. }
  402. dependency('org.mockito:mockito-junit-jupiter:5.11.0') {
  403. exclude 'org.junit.jupiter:junit-jupiter-api'
  404. }
  405. dependency "org.springframework:spring-test:${springVersion}"
  406. dependency 'org.mybatis:mybatis:3.5.16'
  407. dependencySet(group: 'org.slf4j', version: '2.0.13') {
  408. entry 'jcl-over-slf4j'
  409. entry 'jul-to-slf4j'
  410. entry 'log4j-over-slf4j'
  411. entry 'slf4j-api'
  412. }
  413. dependency 'org.postgresql:postgresql:42.7.3'
  414. dependency 'org.reflections:reflections:0.10.2'
  415. dependency 'org.simpleframework:simple:5.1.6'
  416. dependency 'org.sonarsource.git.blame:git-files-blame:1.0.2.275'
  417. dependency('org.sonarsource.orchestrator:sonar-orchestrator-junit4:4.9.0.1920') {
  418. exclude 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml'
  419. }
  420. dependency('org.sonarsource.orchestrator:sonar-orchestrator-junit5:4.9.0.1920') {
  421. exclude 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml'
  422. }
  423. dependency 'org.junit.platform:junit-platform-suite-api:1.10.2'
  424. dependency 'org.junit.platform:junit-platform-suite-engine:1.10.2'
  425. dependency 'com.sonarsource.pdfreport:security-report-pdf-generation:1.0.0.98'
  426. dependency 'org.sonarsource.update-center:sonar-update-center-common:1.32.0.2441'
  427. dependency("org.springframework:spring-context:${springVersion}") {
  428. exclude 'commons-logging:commons-logging'
  429. }
  430. dependency ("org.springframework:spring-webmvc:${springVersion}") {
  431. exclude 'commons-logging:commons-logging'
  432. }
  433. dependency 'org.springdoc:springdoc-openapi-webmvc-core:1.8.0'
  434. dependency 'org.subethamail:subethasmtp:3.1.7'
  435. dependency 'org.yaml:snakeyaml:2.2'
  436. dependency 'org.hibernate:hibernate-validator:6.2.5.Final'
  437. dependency 'javax.el:javax.el-api:3.0.0'
  438. dependency 'org.glassfish:jakarta.el:3.0.4'
  439. dependency 'org.kohsuke:github-api:1.321'
  440. dependency 'org.wiremock:wiremock-standalone:3.5.4'
  441. // please keep this list alphabetically ordered
  442. }
  443. }
  444. configurations {
  445. bbtCompile.extendsFrom testCompile
  446. bbtRuntime.extendsFrom testRuntime
  447. bbtImplementation.extendsFrom testImplementation
  448. // global exclusions
  449. all {
  450. // do not conflict with com.sun.mail:javax.mail
  451. exclude group: 'javax.mail', module: 'mail'
  452. }
  453. }
  454. tasks.withType(Javadoc) {
  455. options.addStringOption('Xdoclint:none', '-quiet')
  456. options.encoding = 'UTF-8'
  457. title = project.name + ' ' + versionWithoutBuildNumber
  458. }
  459. task sourcesJar(type: Jar, dependsOn: classes) {
  460. archiveClassifier = 'sources'
  461. from sourceSets.main.allSource
  462. }
  463. task javadocJar(type: Jar, dependsOn: javadoc) {
  464. archiveClassifier = 'javadoc'
  465. from javadoc.destinationDir
  466. }
  467. // generate code before opening project in IDE (Eclipse or Intellij)
  468. task ide() {
  469. // empty by default. Dependencies are added to the task
  470. // when needed (see protobuf modules for example)
  471. }
  472. task generatePackageInfo {
  473. doLast {
  474. def allPathsContainingJavaFiles = [] as Set
  475. fileTree('src/main/java/').matching() {
  476. include "*/**/*.java"
  477. exclude "*/**/package-info.java"
  478. }.forEach {
  479. allPathsContainingJavaFiles << it.toPath().toFile().getParent();
  480. }
  481. allPathsContainingJavaFiles.each {
  482. String packageInfoPath = it + "/package-info.java"
  483. File packageInfoFile = new File (packageInfoPath)
  484. if (!packageInfoFile.exists()) {
  485. logger.info("Creating file: " + packageInfoPath)
  486. def packageName = packageInfoFile.getParent().replaceAll("[\\\\ /]", ".").takeAfter("src.main.java.");
  487. String packageInfoContent = applyPackageInfoTemplate(packageName)
  488. packageInfoFile << packageInfoContent
  489. }
  490. }
  491. def allPackageInfoFiles = [] as Set
  492. fileTree('src/main/java/').matching() {
  493. include "*/**/package-info.java"
  494. }.forEach {
  495. allPackageInfoFiles << it.toPath().toFile();
  496. }
  497. allPackageInfoFiles.forEach {
  498. File packageInfoFile = it;
  499. if (!allPathsContainingJavaFiles.contains(packageInfoFile.getParent())) {
  500. logger.warn("Deleting package info file: " + packageInfoFile)
  501. packageInfoFile.delete();
  502. }
  503. }
  504. }
  505. }
  506. build.dependsOn(generatePackageInfo)
  507. generatePackageInfo.finalizedBy(licenseFormat)
  508. jacocoTestReport {
  509. reports {
  510. xml.required = true
  511. csv.required = false
  512. html.required = false
  513. }
  514. }
  515. normalization {
  516. runtimeClasspath {
  517. // Following classpath resources contain volatile data that changes in each CI build (build number, commit id, time),
  518. // so we exclude them from calculation of build cache key of test tasks:
  519. ignore 'META-INF/MANIFEST.MF'
  520. ignore 'sonar-api-version.txt'
  521. ignore 'sq-version.txt'
  522. }
  523. }
  524. ext.failedTests = []
  525. test {
  526. jvmArgs '-Dfile.encoding=UTF8'
  527. maxHeapSize = '1500m'
  528. systemProperty 'java.awt.headless', true
  529. // Some tests are asserting on localized messages or dates
  530. systemProperty 'user.language', 'en'
  531. systemProperty 'user.country', 'US'
  532. environment 'LANGUAGE', 'en_US'
  533. testLogging {
  534. events "skipped", "failed" // verbose log for failed and skipped tests (by default the name of the tests are not logged)
  535. exceptionFormat 'full' // log the full stack trace (default is the 1st line of the stack trace)
  536. }
  537. jacoco {
  538. enabled = true // do not disable recording of code coverage, so that remote Gradle cache entry can be used locally
  539. includes = ['com.sonar.*', 'com.sonarsource.*', 'org.sonar.*', 'org.sonarqube.*', 'org.sonarsource.*']
  540. }
  541. if (project.hasProperty('maxParallelTests')) {
  542. maxParallelForks = project.maxParallelTests as int
  543. }
  544. if (project.hasProperty('parallelTests')) {
  545. // See https://guides.gradle.org/performance/#parallel_test_execution
  546. maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
  547. }
  548. afterTest { descriptor, result ->
  549. if (result.resultType == TestResult.ResultType.FAILURE) {
  550. String failedTest = " ${descriptor.className} > ${descriptor.name}"
  551. failedTests << failedTest
  552. }
  553. }
  554. }
  555. gradle.buildFinished {
  556. if (!failedTests.empty) {
  557. println "\nFailed tests:"
  558. failedTests.each { failedTest ->
  559. println failedTest
  560. }
  561. println ""
  562. }
  563. }
  564. def protoMainSrc = 'src/main/protobuf'
  565. def protoTestSrc = 'src/test/protobuf'
  566. if (file(protoMainSrc).exists() || file(protoTestSrc).exists()) {
  567. // protobuf must be applied after java
  568. apply plugin: 'com.google.protobuf'
  569. sourceSets.main.proto.srcDir protoMainSrc // in addition to the default 'src/main/proto'
  570. sourceSets.test.proto.srcDir protoTestSrc // in addition to the default 'src/test/proto'
  571. protobuf {
  572. protoc {
  573. artifact = "com.google.protobuf:protoc:${protobufVersion}"
  574. }
  575. }
  576. jar {
  577. exclude('**/*.proto')
  578. }
  579. idea {
  580. module {
  581. sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  582. testSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  583. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  584. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  585. }
  586. }
  587. ide.dependsOn(['generateProto', 'generateTestProto'])
  588. }
  589. if (official) {
  590. jar {
  591. // do not break incremental build on non official versions
  592. manifest {
  593. attributes(
  594. 'Version': "${version}",
  595. 'Implementation-Build': System.getenv('GIT_SHA1'),
  596. 'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  597. )
  598. }
  599. }
  600. }
  601. license {
  602. header = rootProject.file('HEADER')
  603. ignoreFailures = project.hasProperty('ignoreLicenseFailures') ? project.getProperty('ignoreLicenseFailures').toBoolean() : true
  604. strictCheck true
  605. encoding = 'UTF-8'
  606. mapping {
  607. java = 'SLASHSTAR_STYLE'
  608. js = 'SLASHSTAR_STYLE'
  609. ts = 'SLASHSTAR_STYLE'
  610. tsx = 'SLASHSTAR_STYLE'
  611. css = 'SLASHSTAR_STYLE'
  612. }
  613. includes(['**/*.java', '**/*.js', '**/*.ts', '**/*.tsx', '**/*.css'])
  614. }
  615. tasks.withType(GenerateModuleMetadata) {
  616. enabled = false
  617. }
  618. publishing {
  619. publications {
  620. mavenJava(MavenPublication) {
  621. pom {
  622. name = 'SonarQube'
  623. description = project.description
  624. url = 'https://www.sonarsource.com/products/sonarqube'
  625. organization {
  626. name = 'SonarSource'
  627. url = 'https://www.sonarsource.com'
  628. }
  629. licenses {
  630. license {
  631. name = 'GNU LGPL 3'
  632. url = 'http://www.gnu.org/licenses/lgpl.txt'
  633. distribution = 'repo'
  634. }
  635. }
  636. scm {
  637. url = 'https://github.com/SonarSource/sonarqube'
  638. }
  639. developers {
  640. developer {
  641. id = 'sonarsource-team'
  642. name = 'SonarSource Team'
  643. }
  644. }
  645. }
  646. }
  647. }
  648. }
  649. tasks.withType(Test) {
  650. configurations {
  651. utMonitoring
  652. testMonitoring
  653. ddAgent
  654. }
  655. dependencies {
  656. testImplementation project(":ut-monitoring")
  657. testImplementation project(":test-monitoring")
  658. utMonitoring 'org.aspectj:aspectjweaver:1.9.22'
  659. testMonitoring 'org.aspectj:aspectjweaver:1.9.22'
  660. ddAgent 'com.datadoghq:dd-java-agent'
  661. }
  662. if (System.getenv('CI') == "true") {
  663. doFirst {
  664. ext {
  665. ddJavaAgent = configurations.ddAgent.resolvedConfiguration.resolvedArtifacts.find { it.name == 'dd-java-agent' }
  666. }
  667. jvmArgs "-javaagent:${ddJavaAgent.file}"
  668. jvmArgs "-Ddatadog.slf4j.simpleLogger.logFile=${project.projectDir}/build/datadog.log"
  669. }
  670. }
  671. }
  672. tasks.withType(BlackBoxTest) {
  673. jacoco.enabled = false
  674. testClassesDirs = sourceSets.bbt.output.classesDirs
  675. classpath = sourceSets.bbt.runtimeClasspath
  676. configurations {
  677. includeInTestResources
  678. }
  679. dependencies {
  680. bbtRuntimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
  681. bbtRuntimeOnly 'com.oracle.database.jdbc:ojdbc11'
  682. bbtRuntimeOnly 'org.postgresql:postgresql'
  683. bbtRuntimeOnly project(':plugins:sonar-xoo-plugin')
  684. bbtImplementation 'org.sonarsource.orchestrator:sonar-orchestrator-junit4'
  685. bbtImplementation project(":sonar-testing-harness")
  686. bbtImplementation project(":private:it-common")
  687. bbtImplementation testFixtures(project(":sonar-ws"))
  688. }
  689. }
  690. if (isNightlyBuild) {
  691. tasks.withType(Test) {
  692. doFirst {
  693. ext {
  694. aspectJWeaver = configurations.utMonitoring.resolvedConfiguration.resolvedArtifacts.find { it.name == 'aspectjweaver' }
  695. }
  696. jvmArgs "-javaagent:${aspectJWeaver.file}"
  697. }
  698. }
  699. }
  700. if (ext.testMonitoringEnabled) {
  701. tasks.withType(Test) {
  702. doFirst {
  703. ext {
  704. aspectJWeaver = configurations.testMonitoring.resolvedConfiguration.resolvedArtifacts.find { it.name == 'aspectjweaver' }
  705. }
  706. jvmArgs "-javaagent:${aspectJWeaver.file}"
  707. }
  708. }
  709. }
  710. signing {
  711. def signingKeyId = findProperty("signingKeyId")
  712. def signingKey = findProperty("signingKey")
  713. def signingPassword = findProperty("signingPassword")
  714. useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
  715. required {
  716. return isMainBranch && gradle.taskGraph.hasTask(":artifactoryPublish")
  717. }
  718. sign publishing.publications
  719. }
  720. tasks.withType(Sign) {
  721. onlyIf {
  722. return !artifactoryPublish.skip && isMainBranch && gradle.taskGraph.hasTask(":artifactoryPublish")
  723. }
  724. }
  725. }
  726. static def applyPackageInfoTemplate(packageName) {
  727. def engine = new SimpleTemplateEngine()
  728. def templateText = "@ParametersAreNonnullByDefault\n" +
  729. "package $packageName;\n" +
  730. "\n" +
  731. "import javax.annotation.ParametersAreNonnullByDefault;\n"
  732. def templateParams = ["packageName": packageName]
  733. engine.createTemplate(templateText).make(templateParams).toString()
  734. }
  735. gradle.projectsEvaluated { gradle ->
  736. // yarn_run tasks can't all run in parallel without random issues
  737. // this script ensure all yarn_run tasks run sequentially
  738. def yarnRunTasks = allprojects.findResults { it -> it.tasks.findByName('yarn_run') }
  739. yarnRunTasks.drop(1).eachWithIndex { it, i -> it.mustRunAfter(yarnRunTasks[0..i]) }
  740. }
  741. ext.osAdaptiveCommand = { commands ->
  742. def newCommands = []
  743. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  744. newCommands = ['cmd', '/c']
  745. }
  746. newCommands.addAll(commands)
  747. return newCommands
  748. }
  749. tasks.named('sonarqube') {
  750. onlyIf {
  751. System.getenv('CI') == "true"
  752. }
  753. long taskStart
  754. doFirst {
  755. taskStart = System.currentTimeMillis()
  756. }
  757. doLast {
  758. long taskDuration = System.currentTimeMillis() - taskStart
  759. File outputFile = new File("/tmp/analysis-monitoring.log")
  760. outputFile.append(JsonOutput.toJson([category: "Analysis", suite: "Standalone", operation: "total", duration: taskDuration]) + '\n')
  761. }
  762. }