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

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