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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  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.0'
  10. id "de.undercouch.download" version "5.3.0" apply false
  11. id 'io.spring.dependency-management' version '1.1.0'
  12. id "org.cyclonedx.bom" version "1.7.3" 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.21.12'
  143. springVersion = '5.3.26'
  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.xml:sonar-xml-plugin:2.7.0.3820'
  199. dependency 'org.sonarsource.iac:sonar-iac-plugin:1.15.0.3752'
  200. dependency 'org.sonarsource.text:sonar-text-plugin:2.0.2.1090'
  201. // please keep this list alphabetically ordered
  202. dependencySet(group: 'ch.qos.logback', version: '1.3.5') {
  203. entry 'logback-access'
  204. entry 'logback-classic'
  205. entry 'logback-core'
  206. }
  207. dependency('commons-beanutils:commons-beanutils:1.9.4') {
  208. exclude 'commons-logging:commons-logging'
  209. }
  210. dependency 'commons-codec:commons-codec:1.15'
  211. dependency 'commons-dbutils:commons-dbutils:1.7'
  212. dependency 'commons-io:commons-io:2.11.0'
  213. dependency 'commons-lang:commons-lang:2.6'
  214. imports { mavenBom 'com.fasterxml.jackson:jackson-bom:2.14.1' }
  215. dependency 'com.eclipsesource.minimal-json:minimal-json:0.9.5'
  216. dependencySet(group: 'com.github.scribejava', version: '8.3.3') {
  217. entry 'scribejava-apis'
  218. entry 'scribejava-core'
  219. }
  220. dependency 'com.github.everit-org.json-schema:org.everit.json.schema:1.14.0'
  221. // This project is no longer maintained and was forked
  222. // by https://github.com/java-diff-utils/java-diff-utils
  223. // (io.github.java-diff-utils:java-diff-utils).
  224. dependency 'com.googlecode.java-diff-utils:diffutils:1.3.0'
  225. dependency('com.googlecode.json-simple:json-simple:1.1.1') {
  226. exclude 'junit:junit'
  227. }
  228. dependency 'io.prometheus:simpleclient:0.16.0'
  229. dependency 'io.prometheus:simpleclient_common:0.16.0'
  230. dependency 'io.prometheus:simpleclient_servlet:0.16.0'
  231. dependency 'com.google.code.findbugs:jsr305:3.0.2'
  232. dependency 'com.google.code.gson:gson:2.10.1'
  233. dependency('com.google.guava:guava:31.1-jre') {
  234. exclude 'com.google.errorprone:error_prone_annotations'
  235. exclude 'com.google.guava:listenablefuture'
  236. exclude 'com.google.j2objc:j2objc-annotations'
  237. exclude 'org.checkerframework:checker-qual'
  238. exclude 'org.codehaus.mojo:animal-sniffer-annotations'
  239. }
  240. dependency "com.google.protobuf:protobuf-java:${protobufVersion}"
  241. dependency 'com.h2database:h2:2.1.214'
  242. dependencySet(group: 'com.hazelcast', version: '5.2.1') {
  243. entry 'hazelcast'
  244. }
  245. // Documentation must be updated if mssql-jdbc is updated: https://github.com/SonarSource/sonarqube/commit/03e4773ebf6cba854cdcf57a600095f65f4f53e7
  246. dependency('com.microsoft.sqlserver:mssql-jdbc:11.2.3.jre17') {
  247. exclude 'com.fasterxml.jackson.core:jackson-databind'
  248. }
  249. dependency 'com.onelogin:java-saml:2.9.0'
  250. dependency 'com.oracle.database.jdbc:ojdbc11:21.8.0.0'
  251. dependency 'org.aspectj:aspectjtools:1.9.19'
  252. dependencySet(group: 'com.squareup.okhttp3', version: '4.10.0') {
  253. entry 'okhttp'
  254. entry 'mockwebserver'
  255. }
  256. dependency 'org.json:json:20220924'
  257. dependency 'com.tngtech.java:junit-dataprovider:1.13.1'
  258. dependencySet(group: 'io.jsonwebtoken', version: '0.11.5') {
  259. entry 'jjwt-api'
  260. entry 'jjwt-impl'
  261. entry 'jjwt-jackson'
  262. }
  263. dependency 'com.auth0:java-jwt:4.2.2'
  264. dependency 'io.netty:netty-all:4.1.87.Final'
  265. dependency 'com.sun.mail:javax.mail:1.6.2'
  266. dependency 'javax.annotation:javax.annotation-api:1.3.2'
  267. dependency 'javax.inject:javax.inject:1'
  268. dependency 'javax.servlet:javax.servlet-api:4.0.1'
  269. dependency 'javax.xml.bind:jaxb-api:2.3.1'
  270. dependency 'junit:junit:4.13.2'
  271. dependency 'org.xmlunit:xmlunit-core:2.9.1'
  272. dependency 'org.xmlunit:xmlunit-matchers:2.9.1'
  273. dependency 'net.jpountz.lz4:lz4:1.3.0'
  274. dependency 'net.lightbody.bmp:littleproxy:1.1.0-beta-bmp-17'
  275. dependency 'org.awaitility:awaitility:4.2.0'
  276. dependency 'org.apache.commons:commons-csv:1.9.0'
  277. dependency 'org.apache.commons:commons-email:1.5'
  278. dependency 'com.zaxxer:HikariCP:5.0.1'
  279. dependency('org.apache.httpcomponents:httpclient:4.5.14') {
  280. exclude 'commons-logging:commons-logging'
  281. }
  282. // Be aware that Log4j is used by Elasticsearch client
  283. dependencySet(group: 'org.apache.logging.log4j', version: '2.19.0') {
  284. entry 'log4j-core'
  285. entry 'log4j-api'
  286. entry 'log4j-to-slf4j'
  287. }
  288. dependencySet(group: 'org.apache.tomcat.embed', version: '9.0.70') {
  289. entry 'tomcat-embed-core'
  290. entry('tomcat-embed-jasper') {
  291. exclude 'org.eclipse.jdt.core.compiler:ecj'
  292. }
  293. }
  294. dependency 'org.assertj:assertj-core:3.24.2'
  295. dependency 'org.assertj:assertj-guava:3.24.2'
  296. dependency('org.codehaus.sonar:sonar-channel:4.2') {
  297. exclude 'org.slf4j:slf4j-api'
  298. }
  299. dependency 'org.codehaus.sonar:sonar-classloader:1.0'
  300. dependency 'com.fasterxml.staxmate:staxmate:2.4.0'
  301. dependencySet(group: 'org.eclipse.jetty', version: '9.4.6.v20170531') {
  302. entry 'jetty-proxy'
  303. entry 'jetty-server'
  304. entry 'jetty-servlet'
  305. }
  306. // "elasticsearchDownloadUrlFile" and "elasticsearchDownloadSha512" must also be updated in gradle.properties
  307. dependency('org.elasticsearch.client:elasticsearch-rest-high-level-client:7.17.8') {
  308. exclude 'org.apache.logging.log4j:log4j-core'
  309. }
  310. dependency 'org.elasticsearch.plugin:transport-netty4-client:7.17.8'
  311. dependency 'org.elasticsearch:mocksocket:1.2'
  312. dependency 'org.codelibs.elasticsearch.module:analysis-common:7.17.1'
  313. dependency 'org.codelibs.elasticsearch.module:reindex:7.17.1'
  314. dependency 'org.eclipse.jgit:org.eclipse.jgit:6.4.0.202211300538-r'
  315. dependency 'org.tmatesoft.svnkit:svnkit:1.10.9'
  316. dependency 'org.hamcrest:hamcrest-all:1.3'
  317. dependency 'org.jsoup:jsoup:1.15.3'
  318. dependency 'org.mindrot:jbcrypt:0.4'
  319. dependency('org.mockito:mockito-core:5.0.0') {
  320. exclude 'org.hamcrest:hamcrest-core'
  321. }
  322. dependency "org.springframework:spring-test:${springVersion}"
  323. dependency 'org.mybatis:mybatis:3.5.11'
  324. dependencySet(group: 'org.slf4j', version: '2.0.6') {
  325. entry 'jcl-over-slf4j'
  326. entry 'jul-to-slf4j'
  327. entry 'log4j-over-slf4j'
  328. entry 'slf4j-api'
  329. }
  330. dependency 'org.postgresql:postgresql:42.5.1'
  331. dependency 'org.reflections:reflections:0.10.2'
  332. dependency 'org.simpleframework:simple:5.1.6'
  333. dependency 'org.sonarsource.git.blame:git-files-blame:1.0.1.169'
  334. dependency 'org.sonarsource.orchestrator:sonar-orchestrator:3.42.0.312'
  335. dependency 'org.sonarsource.update-center:sonar-update-center-common:1.29.0.1000'
  336. dependency("org.springframework:spring-context:${springVersion}") {
  337. exclude 'commons-logging:commons-logging'
  338. }
  339. dependency ("org.springframework:spring-webmvc:${springVersion}") {
  340. exclude 'commons-logging:commons-logging'
  341. }
  342. dependency 'org.springdoc:springdoc-openapi-ui:1.6.14'
  343. dependency 'org.subethamail:subethasmtp:3.1.7'
  344. dependency 'org.yaml:snakeyaml:1.33'
  345. // please keep this list alphabetically ordered
  346. }
  347. }
  348. // global exclusions
  349. configurations.all {
  350. // do not conflict with com.sun.mail:javax.mail
  351. exclude group: 'javax.mail', module: 'mail'
  352. }
  353. tasks.withType(Javadoc) {
  354. options.addStringOption('Xdoclint:none', '-quiet')
  355. options.encoding = 'UTF-8'
  356. title = project.name + ' ' + versionWithoutBuildNumber
  357. }
  358. task sourcesJar(type: Jar, dependsOn: classes) {
  359. archiveClassifier = 'sources'
  360. from sourceSets.main.allSource
  361. }
  362. task javadocJar(type: Jar, dependsOn: javadoc) {
  363. archiveClassifier = 'javadoc'
  364. from javadoc.destinationDir
  365. }
  366. // generate code before opening project in IDE (Eclipse or Intellij)
  367. task ide() {
  368. // empty by default. Dependencies are added to the task
  369. // when needed (see protobuf modules for example)
  370. }
  371. jacocoTestReport {
  372. reports {
  373. xml.required = true
  374. csv.required = false
  375. html.required = false
  376. }
  377. }
  378. normalization {
  379. runtimeClasspath {
  380. // Following classpath resources contain volatile data that changes in each CI build (build number, commit id, time),
  381. // so we exclude them from calculation of build cache key of test tasks:
  382. ignore 'META-INF/MANIFEST.MF'
  383. ignore 'sonar-api-version.txt'
  384. ignore 'sq-version.txt'
  385. }
  386. }
  387. ext.failedTests = []
  388. test {
  389. jvmArgs '-Dfile.encoding=UTF8'
  390. maxHeapSize = '1G'
  391. systemProperty 'java.awt.headless', true
  392. testLogging {
  393. events "skipped", "failed" // verbose log for failed and skipped tests (by default the name of the tests are not logged)
  394. exceptionFormat 'full' // log the full stack trace (default is the 1st line of the stack trace)
  395. }
  396. jacoco {
  397. enabled = true // do not disable recording of code coverage, so that remote Gradle cache entry can be used locally
  398. includes = ['com.sonar.*', 'com.sonarsource.*', 'org.sonar.*', 'org.sonarqube.*', 'org.sonarsource.*']
  399. }
  400. if (project.hasProperty('maxParallelTests')) {
  401. maxParallelForks = project.maxParallelTests as int
  402. }
  403. if (project.hasProperty('parallelTests')) {
  404. // See https://guides.gradle.org/performance/#parallel_test_execution
  405. maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
  406. }
  407. afterTest { descriptor, result ->
  408. if (result.resultType == TestResult.ResultType.FAILURE) {
  409. String failedTest = " ${descriptor.className} > ${descriptor.name}"
  410. failedTests << failedTest
  411. }
  412. }
  413. }
  414. gradle.buildFinished {
  415. if (!failedTests.empty) {
  416. println "\nFailed tests:"
  417. failedTests.each { failedTest ->
  418. println failedTest
  419. }
  420. println ""
  421. }
  422. }
  423. def protoMainSrc = 'src/main/protobuf'
  424. def protoTestSrc = 'src/test/protobuf'
  425. if (file(protoMainSrc).exists() || file(protoTestSrc).exists()) {
  426. // protobuf must be applied after java
  427. apply plugin: 'com.google.protobuf'
  428. sourceSets.main.proto.srcDir protoMainSrc // in addition to the default 'src/main/proto'
  429. sourceSets.test.proto.srcDir protoTestSrc // in addition to the default 'src/test/proto'
  430. protobuf {
  431. protoc {
  432. artifact = "com.google.protobuf:protoc:${protobufVersion}"
  433. }
  434. }
  435. jar {
  436. exclude('**/*.proto')
  437. }
  438. idea {
  439. module {
  440. sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  441. testSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  442. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
  443. generatedSourceDirs += file("${protobuf.generatedFilesBaseDir}/test/java")
  444. }
  445. }
  446. ide.dependsOn(['generateProto', 'generateTestProto'])
  447. }
  448. if (official) {
  449. jar {
  450. // do not break incremental build on non official versions
  451. manifest {
  452. attributes(
  453. 'Version': "${version}",
  454. 'Implementation-Build': System.getenv('GIT_SHA1'),
  455. 'Build-Time': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  456. )
  457. }
  458. }
  459. }
  460. license {
  461. header = rootProject.file('HEADER')
  462. strictCheck true
  463. encoding = 'UTF-8'
  464. mapping {
  465. java = 'SLASHSTAR_STYLE'
  466. js = 'SLASHSTAR_STYLE'
  467. ts = 'SLASHSTAR_STYLE'
  468. tsx = 'SLASHSTAR_STYLE'
  469. css = 'SLASHSTAR_STYLE'
  470. }
  471. includes(['**/*.java', '**/*.js', '**/*.ts', '**/*.tsx', '**/*.css'])
  472. }
  473. tasks.withType(GenerateModuleMetadata) {
  474. enabled = false
  475. }
  476. publishing {
  477. publications {
  478. mavenJava(MavenPublication) {
  479. pom {
  480. name = 'SonarQube'
  481. description = project.description
  482. url = 'http://www.sonarqube.org/'
  483. organization {
  484. name = 'SonarSource'
  485. url = 'http://www.sonarsource.com'
  486. }
  487. licenses {
  488. license {
  489. name = 'GNU LGPL 3'
  490. url = 'http://www.gnu.org/licenses/lgpl.txt'
  491. distribution = 'repo'
  492. }
  493. }
  494. scm {
  495. url = 'https://github.com/SonarSource/sonarqube'
  496. }
  497. developers {
  498. developer {
  499. id = 'sonarsource-team'
  500. name = 'SonarSource Team'
  501. }
  502. }
  503. }
  504. }
  505. }
  506. }
  507. if (isNightlyBuild) {
  508. tasks.withType(Test) {
  509. configurations {
  510. utMonitoring
  511. }
  512. dependencies {
  513. testImplementation project(":ut-monitoring")
  514. utMonitoring 'org.aspectj:aspectjweaver:1.9.19'
  515. }
  516. doFirst {
  517. ext {
  518. aspectJWeaver = configurations.utMonitoring.resolvedConfiguration.resolvedArtifacts.find { it.name == 'aspectjweaver' }
  519. }
  520. jvmArgs "-javaagent:${aspectJWeaver.file}"
  521. }
  522. }
  523. }
  524. signing {
  525. def signingKeyId = findProperty("signingKeyId")
  526. def signingKey = findProperty("signingKey")
  527. def signingPassword = findProperty("signingPassword")
  528. useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
  529. required {
  530. return isMainBranch && gradle.taskGraph.hasTask(":artifactoryPublish")
  531. }
  532. sign publishing.publications
  533. }
  534. tasks.withType(Sign) {
  535. onlyIf {
  536. return !artifactoryPublish.skip && isMainBranch && gradle.taskGraph.hasTask(":artifactoryPublish")
  537. }
  538. }
  539. }
  540. gradle.projectsEvaluated { gradle ->
  541. // yarn_run tasks can't all run in parallel without random issues
  542. // this script ensure all yarn_run tasks run sequentially
  543. def yarnRunTasks = allprojects.findResults { it -> it.tasks.findByName('yarn_run') }
  544. yarnRunTasks.drop(1).eachWithIndex { it, i -> it.mustRunAfter(yarnRunTasks[0..i]) }
  545. }
  546. ext.osAdaptiveCommand = { commands ->
  547. def newCommands = []
  548. if (System.properties['os.name'].toLowerCase().contains('windows')) {
  549. newCommands = ['cmd', '/c']
  550. }
  551. newCommands.addAll(commands)
  552. return newCommands
  553. }
  554. tasks.named('sonarqube') {
  555. long taskStart
  556. doFirst {
  557. taskStart = System.currentTimeMillis()
  558. }
  559. doLast {
  560. long taskDuration = System.currentTimeMillis() - taskStart
  561. File outputFile = new File("/tmp/analysis-monitoring.log")
  562. outputFile.append(JsonOutput.toJson([category: "Analysis", suite: "Standalone", operation: "total", duration: taskDuration]) + '\n')
  563. }
  564. }